diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1a2fb332..1d22ed06 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,5 +2,6 @@ \ No newline at end of file diff --git a/.idea/dictionaries/lukas.xml b/.idea/dictionaries/lukas.xml deleted file mode 100644 index f98181ce..00000000 --- a/.idea/dictionaries/lukas.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - lukasobermann - optolith - optolyth - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 03d9549e..22cdf9bd 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,5 +2,10 @@ \ No newline at end of file diff --git a/src/App/Containers/RCPSelectionsContainer.ts b/src/App/Containers/RCPSelectionsContainer.ts index ed163c6b..e78ae7ea 100644 --- a/src/App/Containers/RCPSelectionsContainer.ts +++ b/src/App/Containers/RCPSelectionsContainer.ts @@ -6,6 +6,7 @@ import { ReduxDispatch } from "../Actions/Actions"; import * as ProfessionActions from "../Actions/ProfessionActions"; import { HeroModelRecord } from "../Models/Hero/HeroModel"; import { Selections as SelectionsInterface } from "../Models/Hero/heroTypeHelpers"; +import { DropdownOption } from "../Models/View/DropdownOption"; import { Culture } from "../Models/Wiki/Culture"; import { L10nRecord } from "../Models/Wiki/L10n"; import { Profession } from "../Models/Wiki/Profession"; @@ -17,7 +18,6 @@ import { getCurrentCulture, getCurrentProfession, getCurrentProfessionVariant, g import { getAllSpellsForManualGuildMageSelect } from "../Selectors/spellsSelectors"; import { getWiki } from "../Selectors/stateSelectors"; import { RCPOptionSelectionsEnsure } from "../Views/RCPOptionSelections/RCPOptionSelectionsEnsure"; -import { DropdownOption } from "../Views/Universal/Dropdown"; interface OwnProps { hero: HeroModelRecord diff --git a/src/App/Models/Hero/Item.ts b/src/App/Models/Hero/Item.ts index 6cf60100..827fb626 100644 --- a/src/App/Models/Hero/Item.ts +++ b/src/App/Models/Hero/Item.ts @@ -2,7 +2,7 @@ import { List } from "../../../Data/List"; import { Just, Maybe, Nothing } from "../../../Data/Maybe"; import { elem, OrderedSet } from "../../../Data/OrderedSet"; import { fromDefault, makeLenses, Record } from "../../../Data/Record"; -import { DropdownOption } from "../../Views/Universal/Dropdown"; +import { DropdownOption } from "../View/DropdownOption"; import { ItemTemplate } from "../Wiki/ItemTemplate"; import { PrimaryAttributeDamageThreshold } from "../Wiki/sub/PrimaryAttributeDamageThreshold"; import { SourceLink } from "../Wiki/sub/SourceLink"; diff --git a/src/App/Models/View/DropdownOption.ts b/src/App/Models/View/DropdownOption.ts new file mode 100644 index 00000000..a9b11c74 --- /dev/null +++ b/src/App/Models/View/DropdownOption.ts @@ -0,0 +1,38 @@ +import { Maybe, Nothing } from "../../../Data/Maybe" +import { Accessors, fromDefault, OmitName, PartialMaybeOrNothing, Record, RecordCreator, StrictAccessors } from "../../../Data/Record" + +export type DropdownKey = string | number + +export interface DropdownOption { + "@@name": "DropdownOption" + id: Maybe + name: string + disabled: Maybe +} + +interface DropdownOptionAccessors extends Accessors { + id: + + (x: Record>, "id"> & { "@@name": string }>) => Maybe +} + +interface DropdownOptionStrictAccessors extends StrictAccessors { + id: (x: Record>) => Maybe +} + +interface DropdownOptionCreator extends RecordCreator { + + (x: PartialMaybeOrNothing>>): Record> + readonly default: Record + readonly AL: DropdownOptionAccessors + readonly A: DropdownOptionStrictAccessors + readonly is: + (x: B | Record>) => x is Record> +} + +export const DropdownOption: DropdownOptionCreator = + fromDefault ("DropdownOption") > ({ + id: Nothing, + name: "", + disabled: Nothing, + }) diff --git a/src/App/Models/View/RadioOption.ts b/src/App/Models/View/RadioOption.ts new file mode 100644 index 00000000..91a39d07 --- /dev/null +++ b/src/App/Models/View/RadioOption.ts @@ -0,0 +1,25 @@ +import { Maybe, Nothing } from "../../../Data/Maybe" +import { fromDefault, OmitName, PartialMaybeOrNothing, Record, RecordCreator } from "../../../Data/Record" + +export type RadioOptionValue = string | number + +export interface RadioOption { + "@@name": "RadioOption" + className: Maybe + disabled: Maybe + name: string + value: Maybe +} + +export interface RadioOptionCreator extends RecordCreator> { + + (x: PartialMaybeOrNothing>>): Record> +} + +export const RadioOption: RadioOptionCreator = + fromDefault ("RadioOption") > ({ + className: Nothing, + disabled: Nothing, + name: "", + value: Nothing, + }) diff --git a/src/App/Models/Wiki/ItemTemplate.ts b/src/App/Models/Wiki/ItemTemplate.ts index ca72e4de..8fd05c63 100644 --- a/src/App/Models/Wiki/ItemTemplate.ts +++ b/src/App/Models/Wiki/ItemTemplate.ts @@ -1,7 +1,7 @@ import { List } from "../../../Data/List"; import { Just, Maybe, Nothing } from "../../../Data/Maybe"; import { fromDefault, Record } from "../../../Data/Record"; -import { DropdownOption } from "../../Views/Universal/Dropdown"; +import { DropdownOption } from "../View/DropdownOption"; import { Erratum } from "./sub/Errata"; import { PrimaryAttributeDamageThreshold } from "./sub/PrimaryAttributeDamageThreshold"; import { SourceLink } from "./sub/SourceLink"; diff --git a/src/App/Models/Wiki/sub/SelectOption.ts b/src/App/Models/Wiki/sub/SelectOption.ts index eea8944b..cc1821e5 100644 --- a/src/App/Models/Wiki/sub/SelectOption.ts +++ b/src/App/Models/Wiki/sub/SelectOption.ts @@ -1,7 +1,7 @@ import { List } from "../../../../Data/List"; import { Just, Maybe, Nothing } from "../../../../Data/Maybe"; import { fromDefault, makeLenses, Record } from "../../../../Data/Record"; -import { DropdownOption } from "../../../Views/Universal/Dropdown"; +import { DropdownOption } from "../../View/DropdownOption"; import { AllRequirementObjects } from "../wikiTypeHelpers"; import { Application } from "./Application"; import { Erratum } from "./Errata"; diff --git a/src/App/Selectors/personalDataSelectors.ts b/src/App/Selectors/personalDataSelectors.ts index 88c76f5c..665bdc56 100644 --- a/src/App/Selectors/personalDataSelectors.ts +++ b/src/App/Selectors/personalDataSelectors.ts @@ -6,6 +6,7 @@ import { dec } from "../../Data/Num"; import { fst, Pair, snd } from "../../Data/Tuple"; import { curryN, uncurryN, uncurryN3 } from "../../Data/Tuple/Curry"; import { DisadvantageId, SocialStatusId } from "../Constants/Ids"; +import { DropdownOption } from "../Models/View/DropdownOption"; import { Culture } from "../Models/Wiki/Culture"; import { Race } from "../Models/Wiki/Race"; import { RaceVariant } from "../Models/Wiki/RaceVariant"; @@ -15,7 +16,6 @@ import { translate } from "../Utilities/I18n"; import { pipe, pipe_ } from "../Utilities/pipe"; import { mapGetToMaybeSlice } from "../Utilities/SelectorsUtils"; import { sortRecordsByName } from "../Utilities/sortBy"; -import { DropdownOption } from "../Views/Universal/Dropdown"; import { getCulture, getRace, getRaceVariant } from "./rcpSelectors"; import { getDisadvantages, getLocaleAsProp, getSocialDependencies } from "./stateSelectors"; diff --git a/src/App/Selectors/wikiSelectors.ts b/src/App/Selectors/wikiSelectors.ts index 67789b93..5aec2233 100644 --- a/src/App/Selectors/wikiSelectors.ts +++ b/src/App/Selectors/wikiSelectors.ts @@ -7,6 +7,7 @@ import { elems, keysSet } from "../../Data/OrderedMap"; import { Record } from "../../Data/Record"; import { uncurryN, uncurryN3, uncurryN4 } from "../../Data/Tuple/Curry"; import { CultureCombinedA_ } from "../Models/View/CultureCombined"; +import { DropdownOption } from "../Models/View/DropdownOption"; import { ProfessionCombined, ProfessionCombinedA_ } from "../Models/View/ProfessionCombined"; import { ProfessionVariantCombined } from "../Models/View/ProfessionVariantCombined"; import { RaceCombinedA_ } from "../Models/View/RaceCombined"; @@ -28,7 +29,6 @@ import { compareLocale, translate } from "../Utilities/I18n"; import { pipe, pipe_ } from "../Utilities/pipe"; import { filterByAvailabilityF } from "../Utilities/RulesUtils"; import { comparingR, sortByMulti, sortRecordsByName } from "../Utilities/sortBy"; -import { DropdownOption } from "../Views/Universal/Dropdown"; import { getAllCultures, getAllProfessions, getAllRaces } from "./rcpSelectors"; import { getWikiProfessionsCombinedSortOptions } from "./sortOptionsSelectors"; import { getLocaleAsProp, getWikiAdvantages, getWikiBlessings, getWikiBooks, getWikiCantrips, getWikiCombatTechniques, getWikiCombatTechniquesGroup, getWikiDisadvantages, getWikiFilterText, getWikiItemTemplates, getWikiItemTemplatesGroup, getWikiLiturgicalChants, getWikiLiturgicalChantsGroup, getWikiProfessionsGroup, getWikiSkills, getWikiSkillsGroup, getWikiSpecialAbilities, getWikiSpecialAbilitiesGroup, getWikiSpells, getWikiSpellsGroup } from "./stateSelectors"; diff --git a/src/App/Utilities/Activatable/activatableInactiveViewUtils.tsx b/src/App/Utilities/Activatable/activatableInactiveViewUtils.tsx index dffd609b..e4194ac9 100644 --- a/src/App/Utilities/Activatable/activatableInactiveViewUtils.tsx +++ b/src/App/Utilities/Activatable/activatableInactiveViewUtils.tsx @@ -15,6 +15,7 @@ import { AdvantageId, DisadvantageId, SpecialAbilityId } from "../../Constants/I import { ActivatableActivationOptions, ActivatableActivationOptionsL } from "../../Models/Actions/ActivatableActivationOptions"; import { ActivatableDependent } from "../../Models/ActiveEntries/ActivatableDependent"; import { ActiveObject } from "../../Models/ActiveEntries/ActiveObject"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { InactiveActivatable, InactiveActivatableA_ } from "../../Models/View/InactiveActivatable"; import { Disadvantage } from "../../Models/Wiki/Disadvantage"; import { L10nRecord } from "../../Models/Wiki/L10n"; @@ -25,7 +26,7 @@ import { SelectOption } from "../../Models/Wiki/sub/SelectOption"; import { WikiModel, WikiModelRecord } from "../../Models/Wiki/WikiModel"; import { Activatable } from "../../Models/Wiki/wikiTypeHelpers"; import { ActivatableAddListItemSelectedOptions } from "../../Views/Activatable/ActivatableAddListItem"; -import { Dropdown, DropdownOption } from "../../Views/Universal/Dropdown"; +import { Dropdown } from "../../Views/Universal/Dropdown"; import { TextField } from "../../Views/Universal/TextField"; import { getActiveWithNoCustomCost } from "../AdventurePoints/activatableCostUtils"; import { translate } from "../I18n"; diff --git a/src/App/Utilities/NumberUtils.ts b/src/App/Utilities/NumberUtils.ts index 64dda69a..6be47122 100644 --- a/src/App/Utilities/NumberUtils.ts +++ b/src/App/Utilities/NumberUtils.ts @@ -65,14 +65,8 @@ export const sign = signNullCustom ("0") /** * `signNeg :: Int -> String` * - * Correctly signs numbers. Basically, this makes negative numbers use the - * typographically correct minus sign instead of the default hyphen. - * - * ```haskell - * signNeg -1 === "−1" - * signNeg 0 === "0" - * signNeg 1 === "1" - * ``` + * Forces signing on the given number, but it does not add a `+` if the number + * is positive. Only a proper minus sign is added. */ export const signNeg = (x: number) => x < 0 ? `${minus}\u2060${Math.abs (x)}` : `${x}` diff --git a/src/App/Utilities/levelUtils.ts b/src/App/Utilities/levelUtils.ts index b4d3b9f8..5ae8592c 100644 --- a/src/App/Utilities/levelUtils.ts +++ b/src/App/Utilities/levelUtils.ts @@ -2,7 +2,7 @@ import { unfoldr } from "../../Data/List"; import { Just, Nothing } from "../../Data/Maybe"; import { Record } from "../../Data/Record"; import { Pair } from "../../Data/Tuple"; -import { DropdownOption } from "../Views/Universal/Dropdown"; +import { DropdownOption } from "../Models/View/DropdownOption"; import { toRoman } from "./NumberUtils"; const getElements = diff --git a/src/App/Utilities/rcpAdjustmentSelectionUtils.tsx b/src/App/Utilities/rcpAdjustmentSelectionUtils.tsx index 3bf776d6..8f1fc9f8 100644 --- a/src/App/Utilities/rcpAdjustmentSelectionUtils.tsx +++ b/src/App/Utilities/rcpAdjustmentSelectionUtils.tsx @@ -7,19 +7,17 @@ import { lookup, lookupF } from "../../Data/OrderedMap"; import { Record } from "../../Data/Record"; import { fst, Pair, snd } from "../../Data/Tuple"; import { SpecialAbilityId } from "../Constants/Ids"; +import { DropdownOption } from "../Models/View/DropdownOption"; import { Culture } from "../Models/Wiki/Culture"; import { L10nRecord } from "../Models/Wiki/L10n"; import { ProfessionRequireActivatable } from "../Models/Wiki/prerequisites/ActivatableRequirement"; import { Profession } from "../Models/Wiki/Profession"; -import { ProfessionSelections } from "../Models/Wiki/professionSelections/ProfessionAdjustmentSelections"; -import { TerrainKnowledgeSelection } from "../Models/Wiki/professionSelections/TerrainKnowledgeSelection"; import { SpecialAbility } from "../Models/Wiki/SpecialAbility"; import { SelectOption } from "../Models/Wiki/sub/SelectOption"; import { WikiModel, WikiModelRecord } from "../Models/Wiki/WikiModel"; -import { ProfessionPrerequisite, ProfessionSelectionIds } from "../Models/Wiki/wikiTypeHelpers"; -import { TerrainKnowledge } from "../Views/RCPOptionSelections/TerrainKnowledgeSelectionList"; +import { ProfessionPrerequisite } from "../Models/Wiki/wikiTypeHelpers"; import { Checkbox } from "../Views/Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Views/Universal/Dropdown"; +import { Dropdown } from "../Views/Universal/Dropdown"; import { findSelectOption } from "./Activatable/selectionUtils"; import { translate } from "./I18n"; import { pipe } from "./pipe"; @@ -74,24 +72,6 @@ export const getBuyScriptElement = ) : Nothing -export const getTerrainKnowledgeElement = - (wiki: WikiModelRecord) => - (terrainKnowledgeActive: Maybe) => - (setTerrainKnowledge: (terrainKnowledge: number) => void) => - pipe ( - ProfessionSelections.AL[ProfessionSelectionIds.TERRAIN_KNOWLEDGE], - Maybe.liftM2, Record, JSX.Element> - (wikiEntry => selection => ( - - )) - (lookupF (WA.specialAbilities (wiki)) (SpecialAbilityId.TerrainKnowledge)) - ) - export const getMotherTongueSelectionElement = (locale: L10nRecord) => (wiki: WikiModelRecord) => diff --git a/src/App/Views/Activatable/ActivatableRemoveListItem.tsx b/src/App/Views/Activatable/ActivatableRemoveListItem.tsx index d38f1272..76093a6c 100644 --- a/src/App/Views/Activatable/ActivatableRemoveListItem.tsx +++ b/src/App/Views/Activatable/ActivatableRemoveListItem.tsx @@ -10,13 +10,14 @@ import { Record } from "../../../Data/Record"; import { SpecialAbilityId } from "../../Constants/Ids"; import { ActivatableDeactivationOptions } from "../../Models/Actions/ActivatableDeactivationOptions"; import { ActiveActivatable, ActiveActivatableA_ } from "../../Models/View/ActiveActivatable"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { classListMaybe } from "../../Utilities/CSS"; import { translate } from "../../Utilities/I18n"; import { getLevelElementsWithMin } from "../../Utilities/levelUtils"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { renderMaybe } from "../../Utilities/ReactUtils"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { IconButton } from "../Universal/IconButton"; import { ListItem } from "../Universal/ListItem"; import { ListItemButtons } from "../Universal/ListItemButtons"; @@ -212,3 +213,4 @@ const ActivatableRemoveListItemM = ) export { ActivatableRemoveListItemM as ActivatableRemoveListItem }; + diff --git a/src/App/Views/Alerts/Alerts.tsx b/src/App/Views/Alerts/Alerts.tsx index 5b812df3..b09df3aa 100644 --- a/src/App/Views/Alerts/Alerts.tsx +++ b/src/App/Views/Alerts/Alerts.tsx @@ -1,8 +1,7 @@ -import * as React from "react"; import { Maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { PromptOptions } from "../../Actions/AlertActions"; -import { Alert, AlertProps } from "../Universal/Alert"; +import { Alert } from "../Universal/Alert"; export interface AlertsOwnProps { } @@ -16,9 +15,4 @@ export interface AlertsDispatchProps { export type AlertsProps = AlertsStateProps & AlertsDispatchProps & AlertsOwnProps -export const Alerts: React.FC = ({ options, close }) => ( - -) +export const Alerts = Alert diff --git a/src/App/Views/Attributes/AttributesAdjustment.tsx b/src/App/Views/Attributes/AttributesAdjustment.tsx index b0c9e841..f962e859 100644 --- a/src/App/Views/Attributes/AttributesAdjustment.tsx +++ b/src/App/Views/Attributes/AttributesAdjustment.tsx @@ -3,11 +3,12 @@ import { elem, flength, List } from "../../../Data/List"; import { fromMaybe, isNothing, joinMaybeList, Just, liftM2, mapMaybe, Maybe, Nothing } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { AttributeWithRequirements, AttributeWithRequirementsA_ } from "../../Models/View/AttributeWithRequirements"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { sign } from "../../Utilities/NumberUtils"; import { pipe_ } from "../../Utilities/pipe"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; export interface AttributesAdjustmentProps { adjustmentValue: Maybe diff --git a/src/App/Views/Cultures/Cultures.tsx b/src/App/Views/Cultures/Cultures.tsx index e3e450b0..1c9cfeaa 100644 --- a/src/App/Views/Cultures/Cultures.tsx +++ b/src/App/Views/Cultures/Cultures.tsx @@ -5,11 +5,12 @@ import { Record } from "../../../Data/Record"; import { WikiInfoContainer } from "../../Containers/WikiInfoContainer"; import { HeroModelRecord } from "../../Models/Hero/HeroModel"; import { CultureCombined, CultureCombinedA_ } from "../../Models/View/CultureCombined"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { CulturesSortOptions, CulturesVisibilityFilter } from "../../Utilities/Raw/JSON/Config"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { ListView } from "../Universal/List"; import { ListHeader } from "../Universal/ListHeader"; import { ListHeaderTag } from "../Universal/ListHeaderTag"; diff --git a/src/App/Views/Equipment/Equipment.tsx b/src/App/Views/Equipment/Equipment.tsx index faf675ba..85332edd 100644 --- a/src/App/Views/Equipment/Equipment.tsx +++ b/src/App/Views/Equipment/Equipment.tsx @@ -12,13 +12,14 @@ import { HeroModelRecord } from "../../Models/Hero/HeroModel"; import { fromItemTemplate, Item } from "../../Models/Hero/Item"; import { Purse } from "../../Models/Hero/Purse"; import { CombatTechniqueWithRequirements, CombatTechniqueWithRequirementsA_ } from "../../Models/View/CombatTechniqueWithRequirements"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { ItemTemplate } from "../../Models/Wiki/ItemTemplate"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { Aside } from "../Universal/Aside"; import { BorderButton } from "../Universal/BorderButton"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { ListView } from "../Universal/List"; import { ListHeader } from "../Universal/ListHeader"; import { ListHeaderTag } from "../Universal/ListHeaderTag"; diff --git a/src/App/Views/Equipment/ItemEditorArmorSection.tsx b/src/App/Views/Equipment/ItemEditorArmorSection.tsx index 4319ea4b..f5eb3c0f 100644 --- a/src/App/Views/Equipment/ItemEditorArmorSection.tsx +++ b/src/App/Views/Equipment/ItemEditorArmorSection.tsx @@ -3,13 +3,14 @@ import { imap } from "../../../Data/List"; import { Just, Maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { EditItem } from "../../Models/Hero/EditItem"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { ItemEditorInputValidation } from "../../Utilities/itemEditorInputValidationUtils"; import { getLossLevelElements } from "../../Utilities/ItemUtils"; import { sortRecordsByName } from "../../Utilities/sortBy"; import { Checkbox } from "../Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Hr } from "../Universal/Hr"; import { TextField } from "../Universal/TextField"; diff --git a/src/App/Views/Equipment/ItemEditorCommonSection.tsx b/src/App/Views/Equipment/ItemEditorCommonSection.tsx index 5839975f..cfcc7892 100644 --- a/src/App/Views/Equipment/ItemEditorCommonSection.tsx +++ b/src/App/Views/Equipment/ItemEditorCommonSection.tsx @@ -3,13 +3,14 @@ import { consF, imap, List, map, take } from "../../../Data/List"; import { isJust, isNothing, Just, Maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { EditItem } from "../../Models/Hero/EditItem"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { ItemTemplate, itemTemplateToDropdown } from "../../Models/Wiki/ItemTemplate"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { ItemEditorInputValidation } from "../../Utilities/itemEditorInputValidationUtils"; import { pipe_ } from "../../Utilities/pipe"; import { Checkbox } from "../Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Hr } from "../Universal/Hr"; import { IconButton } from "../Universal/IconButton"; import { TextField } from "../Universal/TextField"; diff --git a/src/App/Views/Equipment/ItemEditorMeleeSection.tsx b/src/App/Views/Equipment/ItemEditorMeleeSection.tsx index c5f4d39f..404047a1 100644 --- a/src/App/Views/Equipment/ItemEditorMeleeSection.tsx +++ b/src/App/Views/Equipment/ItemEditorMeleeSection.tsx @@ -9,6 +9,7 @@ import { fst, isTuple, snd } from "../../../Data/Tuple"; import { AttrId, CombatTechniqueId } from "../../Constants/Ids"; import { EditItem } from "../../Models/Hero/EditItem"; import { EditPrimaryAttributeDamageThreshold } from "../../Models/Hero/EditPrimaryAttributeDamageThreshold"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { Attribute } from "../../Models/Wiki/Attribute"; import { CombatTechnique } from "../../Models/Wiki/CombatTechnique"; import { L10nRecord } from "../../Models/Wiki/L10n"; @@ -18,7 +19,7 @@ import { getLossLevelElements } from "../../Utilities/ItemUtils"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { isString } from "../../Utilities/typeCheckUtils"; import { Checkbox } from "../Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Hr } from "../Universal/Hr"; import { Label } from "../Universal/Label"; import { TextField } from "../Universal/TextField"; diff --git a/src/App/Views/Equipment/ItemEditorRangedSection.tsx b/src/App/Views/Equipment/ItemEditorRangedSection.tsx index bb1ecc0d..03c5b8cb 100644 --- a/src/App/Views/Equipment/ItemEditorRangedSection.tsx +++ b/src/App/Views/Equipment/ItemEditorRangedSection.tsx @@ -6,6 +6,7 @@ import { ensure, Just, mapMaybe, Maybe } from "../../../Data/Maybe"; import { elems, OrderedMap } from "../../../Data/OrderedMap"; import { Record } from "../../../Data/Record"; import { EditItem } from "../../Models/Hero/EditItem"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { CombatTechnique } from "../../Models/Wiki/CombatTechnique"; import { ItemTemplate } from "../../Models/Wiki/ItemTemplate"; import { L10nRecord } from "../../Models/Wiki/L10n"; @@ -13,7 +14,7 @@ import { translate } from "../../Utilities/I18n"; import { ItemEditorInputValidation } from "../../Utilities/itemEditorInputValidationUtils"; import { getLossLevelElements } from "../../Utilities/ItemUtils"; import { pipe, pipe_ } from "../../Utilities/pipe"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Hr } from "../Universal/Hr"; import { Label } from "../Universal/Label"; import { TextField } from "../Universal/TextField"; diff --git a/src/App/Views/Heroes/HeroCreation.tsx b/src/App/Views/Heroes/HeroCreation.tsx index d97cac45..d4c5d1f7 100644 --- a/src/App/Views/Heroes/HeroCreation.tsx +++ b/src/App/Views/Heroes/HeroCreation.tsx @@ -5,6 +5,8 @@ import { elems, OrderedMap } from "../../../Data/OrderedMap"; import { OrderedSet, toggle } from "../../../Data/OrderedSet"; import { Record } from "../../../Data/Record"; import { Sex } from "../../Models/Hero/heroTypeHelpers"; +import { DropdownOption } from "../../Models/View/DropdownOption"; +import { RadioOption } from "../../Models/View/RadioOption"; import { Book } from "../../Models/Wiki/Book"; import { ExperienceLevel } from "../../Models/Wiki/ExperienceLevel"; import { L10nRecord } from "../../Models/Wiki/L10n"; @@ -12,10 +14,10 @@ import { translate } from "../../Utilities/I18n"; import { pipe_ } from "../../Utilities/pipe"; import { BookSelection } from "../Rules/BookSelection"; import { Dialog } from "../Universal/Dialog"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Hr } from "../Universal/Hr"; import { Scroll } from "../Universal/Scroll"; -import { Option, SegmentedControls } from "../Universal/SegmentedControls"; +import { SegmentedControls } from "../Universal/SegmentedControls"; import { TextField } from "../Universal/TextField"; const ELA = ExperienceLevel.A @@ -150,11 +152,11 @@ export const HeroCreation: React.FC = props => { active={msex} onClick={setSex} options={List ( - Option ({ + RadioOption ({ value: Just ("m"), name: translate (l10n) ("male"), }), - Option ({ + RadioOption ({ value: Just ("f"), name: translate (l10n) ("female"), }) diff --git a/src/App/Views/Heroes/Herolist.tsx b/src/App/Views/Heroes/Herolist.tsx index a6b04fb7..e5f1f2c0 100644 --- a/src/App/Views/Heroes/Herolist.tsx +++ b/src/App/Views/Heroes/Herolist.tsx @@ -6,6 +6,7 @@ import { OrderedSet } from "../../../Data/OrderedSet"; import { Record } from "../../../Data/Record"; import { HerolistItemContainer } from "../../Containers/HerolistItemContainer"; import { HeroModel, HeroModelRecord } from "../../Models/Hero/HeroModel"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { Book } from "../../Models/Wiki/Book"; import { ExperienceLevel } from "../../Models/Wiki/ExperienceLevel"; import { L10nRecord } from "../../Models/Wiki/L10n"; @@ -13,7 +14,7 @@ import { translate } from "../../Utilities/I18n"; import { pipe_ } from "../../Utilities/pipe"; import { HeroListVisibilityFilter } from "../../Utilities/Raw/JSON/Config"; import { BorderButton } from "../Universal/BorderButton"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { ListView } from "../Universal/List"; import { Options } from "../Universal/Options"; import { Page } from "../Universal/Page"; diff --git a/src/App/Views/HitZoneArmors/HitZoneArmorEditor.tsx b/src/App/Views/HitZoneArmors/HitZoneArmorEditor.tsx index e6500783..85f4395f 100644 --- a/src/App/Views/HitZoneArmors/HitZoneArmorEditor.tsx +++ b/src/App/Views/HitZoneArmors/HitZoneArmorEditor.tsx @@ -7,6 +7,7 @@ import { ensure, mapMaybe, Maybe, maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { EditHitZoneArmor } from "../../Models/Hero/EditHitZoneArmor"; import { Item, itemToDropdown } from "../../Models/Hero/Item"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { ItemTemplate, itemTemplateToDropdown } from "../../Models/Wiki/ItemTemplate"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; @@ -14,7 +15,6 @@ import { getLossLevelElements } from "../../Utilities/ItemUtils"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { sortRecordsByName } from "../../Utilities/sortBy"; import { Dialog } from "../Universal/Dialog"; -import { DropdownOption } from "../Universal/Dropdown"; import { TextField } from "../Universal/TextField"; import { HitZoneArmorEditorRow } from "./HitZoneArmorEditorRow"; diff --git a/src/App/Views/HitZoneArmors/HitZoneArmorEditorRow.tsx b/src/App/Views/HitZoneArmors/HitZoneArmorEditorRow.tsx index a5938c5d..fce8a8d1 100644 --- a/src/App/Views/HitZoneArmors/HitZoneArmorEditorRow.tsx +++ b/src/App/Views/HitZoneArmors/HitZoneArmorEditorRow.tsx @@ -2,9 +2,10 @@ import * as React from "react"; import { List } from "../../../Data/List"; import { Maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; export type HitZoneNames = "head" diff --git a/src/App/Views/LiturgicalChants/LiturgicalChants.tsx b/src/App/Views/LiturgicalChants/LiturgicalChants.tsx index 70febc9a..ed57f918 100644 --- a/src/App/Views/LiturgicalChants/LiturgicalChants.tsx +++ b/src/App/Views/LiturgicalChants/LiturgicalChants.tsx @@ -67,12 +67,6 @@ export type LiturgicalChantsProps = & LiturgicalChantsDispatchProps & LiturgicalChantsOwnProps -export interface LiturgicalChantsState { - showAddSlidein: boolean - currentId: Maybe - currentSlideinId: Maybe -} - type Combined = Record | Record export const LiturgicalChants: React.FC = props => { diff --git a/src/App/Views/NavBar/ApTooltip.tsx b/src/App/Views/NavBar/ApTooltip.tsx index fe267db7..3487bf42 100644 --- a/src/App/Views/NavBar/ApTooltip.tsx +++ b/src/App/Views/NavBar/ApTooltip.tsx @@ -6,7 +6,7 @@ import { AdventurePointsCategories } from "../../Models/View/AdventurePointsCate import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate, translateP } from "../../Utilities/I18n"; -export interface ApTooltipProps { +interface Props { l10n: L10nRecord adventurePoints: Record maximumForMagicalAdvantagesDisadvantages: Maybe @@ -16,7 +16,7 @@ export interface ApTooltipProps { const APCA = AdventurePointsCategories.A -export function ApTooltip (props: ApTooltipProps) { +export const ApTooltip: React.FC = props => { const { l10n, adventurePoints: ap, diff --git a/src/App/Views/NavBar/NavigationBar.tsx b/src/App/Views/NavBar/NavigationBar.tsx index f6b3804e..49b953e2 100644 --- a/src/App/Views/NavBar/NavigationBar.tsx +++ b/src/App/Views/NavBar/NavigationBar.tsx @@ -7,6 +7,7 @@ import { SettingsContainer } from "../../Containers/SettingsContainer"; import { HeroModelRecord } from "../../Models/Hero/HeroModel"; import { SubTab } from "../../Models/Hero/heroTypeHelpers"; import { AdventurePointsCategories } from "../../Models/View/AdventurePointsCategories"; +import { NavigationBarTabOptions } from "../../Models/View/NavigationBarTabOptions"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { TabId } from "../../Utilities/LocationUtils"; @@ -22,7 +23,6 @@ import { NavigationBarBack } from "./NavigationBarBack"; import { NavigationBarLeft } from "./NavigationBarLeft"; import { NavigationBarRight } from "./NavigationBarRight"; import { NavigationBarSubTabs } from "./NavigationBarSubTabs"; -import { NavigationBarTabProps } from "./NavigationBarTab"; import { NavigationBarTabs } from "./NavigationBarTabs"; import { NavigationBarWrapper } from "./NavigationBarWrapper"; @@ -41,7 +41,7 @@ export interface NavigationBarStateProps { isUndoAvailable: boolean isSettingsOpen: boolean isHeroSection: boolean - tabs: List + tabs: List> subtabs: Maybe> adventurePoints: Maybe> maximumForMagicalAdvantagesDisadvantages: Maybe diff --git a/src/App/Views/NavBar/NavigationBarBack.tsx b/src/App/Views/NavBar/NavigationBarBack.tsx index b9637a53..097c9aad 100644 --- a/src/App/Views/NavBar/NavigationBarBack.tsx +++ b/src/App/Views/NavBar/NavigationBarBack.tsx @@ -1,10 +1,10 @@ import * as React from "react"; -export interface NavigationBarBackProps { +interface Props { handleSetTab (): void } -export function NavigationBarBack (props: NavigationBarBackProps) { +export const NavigationBarBack: React.FC = props => { const { handleSetTab } = props return ( diff --git a/src/App/Views/NavBar/NavigationBarForGroup.tsx b/src/App/Views/NavBar/NavigationBarForGroup.tsx index a4f24eac..91abec3b 100644 --- a/src/App/Views/NavBar/NavigationBarForGroup.tsx +++ b/src/App/Views/NavBar/NavigationBarForGroup.tsx @@ -14,7 +14,7 @@ import { NavigationBarLeft } from "./NavigationBarLeft"; import { NavigationBarRight } from "./NavigationBarRight"; import { NavigationBarWrapper } from "./NavigationBarWrapper"; -export interface NavigationBarForGroupProps { +interface Props { l10n: L10nRecord groupName: string platform: string @@ -27,7 +27,7 @@ export interface NavigationBarForGroupProps { const toggleDevtools = remote.getCurrentWindow ().webContents.toggleDevTools -export const NavigationBarForGroup: React.FC = props => { +export const NavigationBarForGroup: React.FC = props => { const { l10n, groupName, diff --git a/src/App/Views/NavBar/NavigationBarLeft.tsx b/src/App/Views/NavBar/NavigationBarLeft.tsx index dfd195b7..420abd4f 100644 --- a/src/App/Views/NavBar/NavigationBarLeft.tsx +++ b/src/App/Views/NavBar/NavigationBarLeft.tsx @@ -1,8 +1,8 @@ import * as React from "react"; -export interface NavigationBarLeftProps { } +interface Props { } -export const NavigationBarLeft: React.FC = ({ children }) => ( +export const NavigationBarLeft: React.FC = ({ children }) => (
{children}
diff --git a/src/App/Views/NavBar/NavigationBarRight.tsx b/src/App/Views/NavBar/NavigationBarRight.tsx index 78e212b4..4d323c58 100644 --- a/src/App/Views/NavBar/NavigationBarRight.tsx +++ b/src/App/Views/NavBar/NavigationBarRight.tsx @@ -1,8 +1,8 @@ import * as React from "react"; -export interface NavigationBarRightProps { } +interface Props { } -export const NavigationBarRight: React.FC = ({ children }) => ( +export const NavigationBarRight: React.FC = ({ children }) => (
{children}
diff --git a/src/App/Views/NavBar/NavigationBarSubTab.tsx b/src/App/Views/NavBar/NavigationBarSubTab.tsx index c4fffd95..106caf46 100644 --- a/src/App/Views/NavBar/NavigationBarSubTab.tsx +++ b/src/App/Views/NavBar/NavigationBarSubTab.tsx @@ -3,13 +3,13 @@ import { SubTab } from "../../Models/Hero/heroTypeHelpers"; import { TabId } from "../../Utilities/LocationUtils"; import { Tab } from "../Universal/Tab"; -export interface NavigationBarSubTabProps { +interface Props { currentTab: TabId tab: SubTab setTab (tab: TabId): void } -export const NavigationBarSubTab: React.FC = props => { +export const NavigationBarSubTab: React.FC = props => { const { currentTab, tab, setTab } = props const { id, label, disabled } = tab diff --git a/src/App/Views/NavBar/NavigationBarSubTabs.tsx b/src/App/Views/NavBar/NavigationBarSubTabs.tsx index 34339cef..abf136ed 100644 --- a/src/App/Views/NavBar/NavigationBarSubTabs.tsx +++ b/src/App/Views/NavBar/NavigationBarSubTabs.tsx @@ -5,13 +5,13 @@ import { TabId } from "../../Utilities/LocationUtils"; import { pipe_ } from "../../Utilities/pipe"; import { NavigationBarSubTab } from "./NavigationBarSubTab"; -export interface NavigationBarSubTabsProps { +interface Props { currentTab: TabId tabs: List setTab (tab: TabId): void } -export const NavigationBarSubTabs: React.FC = props => { +export const NavigationBarSubTabs: React.FC = props => { const { currentTab, tabs, setTab } = props return ( diff --git a/src/App/Views/NavBar/NavigationBarTabs.tsx b/src/App/Views/NavBar/NavigationBarTabs.tsx index 431d75e1..1647e9da 100644 --- a/src/App/Views/NavBar/NavigationBarTabs.tsx +++ b/src/App/Views/NavBar/NavigationBarTabs.tsx @@ -1,15 +1,19 @@ import * as React from "react"; import { List, map, toArray } from "../../../Data/List"; +import { Record } from "../../../Data/Record"; +import { NavigationBarTabOptions } from "../../Models/View/NavigationBarTabOptions"; import { TabId } from "../../Utilities/LocationUtils"; import { pipe_ } from "../../Utilities/pipe"; -import { NavigationBarTab, NavigationBarTabProps } from "./NavigationBarTab"; +import { NavigationBarTab } from "./NavigationBarTab"; -export interface NavigationBarTabsProps { +const NBTOA = NavigationBarTabOptions.A + +interface Props { currentTab: TabId - tabs: List + tabs: List> } -export const NavigationBarTabs: React.FC = props => { +export const NavigationBarTabs: React.FC = props => { const { currentTab, tabs } = props return ( @@ -18,12 +22,9 @@ export const NavigationBarTabs: React.FC = props => { tabs, map (tab => ( )), toArray diff --git a/src/App/Views/NavBar/NavigationBarWrapper.tsx b/src/App/Views/NavBar/NavigationBarWrapper.tsx index 6a5461ff..51bff23b 100644 --- a/src/App/Views/NavBar/NavigationBarWrapper.tsx +++ b/src/App/Views/NavBar/NavigationBarWrapper.tsx @@ -1,8 +1,8 @@ import * as React from "react"; -export interface NavigationBarWrapperProps { } +interface Props { } -export const NavigationBarWrapper: React.FC = ({ children }) => ( +export const NavigationBarWrapper: React.FC = ({ children }) => (
{children} diff --git a/src/App/Views/Pact/Pact.tsx b/src/App/Views/Pact/Pact.tsx index f2db5e5f..c60b1c75 100644 --- a/src/App/Views/Pact/Pact.tsx +++ b/src/App/Views/Pact/Pact.tsx @@ -9,13 +9,14 @@ import { Record } from "../../../Data/Record"; import { Pair } from "../../../Data/Tuple"; import { HeroModelRecord } from "../../Models/Hero/HeroModel"; import { Pact } from "../../Models/Hero/Pact"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { toRoman } from "../../Utilities/NumberUtils"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { misNumberM, misStringM } from "../../Utilities/typeCheckUtils"; import { Checkbox } from "../Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Page } from "../Universal/Page"; import { TextField } from "../Universal/TextField"; @@ -83,12 +84,12 @@ export const PactSettings: React.FC = props => { options={pipe_ ( translate (l10n) ("pactcategories"), imap (i => (name: string) => DropdownOption ({ - id: Just (i + 1), - name, - })), + id: Just (i + 1), + name, + })), consF (DropdownOption ({ - name: translate (l10n) ("nopact"), - })) + name: translate (l10n) ("nopact"), + })) )} onChange={setPactCategory} value={fmapF (mpact) (Pact.A.category)} diff --git a/src/App/Views/Professions/ProfessionVariants.tsx b/src/App/Views/Professions/ProfessionVariants.tsx index 5a7236c1..748293cc 100644 --- a/src/App/Views/Professions/ProfessionVariants.tsx +++ b/src/App/Views/Professions/ProfessionVariants.tsx @@ -9,12 +9,13 @@ import { selectProfessionVariant } from "../../Actions/ProfessionVariantActions" import { Sex } from "../../Models/Hero/heroTypeHelpers"; import { ProfessionCombined, ProfessionCombinedA_ } from "../../Models/View/ProfessionCombined"; import { ProfessionVariantCombinedA_ } from "../../Models/View/ProfessionVariantCombined"; +import { RadioOption } from "../../Models/View/RadioOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { getNameBySex } from "../../Utilities/rcpUtils"; import { sortRecordsByName } from "../../Utilities/sortBy"; -import { Option, RadioButtonGroup } from "../Universal/RadioButtonGroup"; +import { RadioButtonGroup } from "../Universal/RadioButtonGroup"; export interface ProfessionVariantsProps { currentProfessionId: Maybe @@ -57,7 +58,7 @@ export const ProfessionVariants: React.FC = props => { const ap_tag = translate (l10n) ("adventurepoints.short") const ap = Maybe.sum (PCA_.ap (prof)) + PVCA_.ap (prof_var) - return Option ({ + return RadioOption ({ name: `${name} (${ap} ${ap_tag})`, value: Just (PVCA_.id (prof_var)), }) @@ -65,14 +66,14 @@ export const ProfessionVariants: React.FC = props => { sortRecordsByName (l10n), PCA_.isVariantRequired (prof) ? ident - : consF (Option ({ name: translate (l10n) ("novariant") })) + : consF (RadioOption ({ name: translate (l10n) ("novariant") })) )) )) (msex) (bind (professions) (find (pipe (PCA_.id, Maybe.elemF (currentProfessionId))))) return maybe (<>) - ((vars: List>>) => ( + ((vars: List>>) => ( = props => (PSA[ProfessionSelectionIds.SKILLS]) (prof_sels) - const terrainKnowledge = getTerrainKnowledgeElement (wiki) - (terrainKnowledgeActive) - (handleSetTerrainKnowledge) - (prof_sels) + const terrainKnowledge = + getSelPair (isTerrainKnowledgeSelectionValid (terrainKnowledgeActive)) + (selection => ( + + )) + (PSA[ProfessionSelectionIds.TERRAIN_KNOWLEDGE]) + (prof_sels) const guildMageUnfamiliarSpell = getGuildMageUnfamiliarSpellSelectionElement (l10n) @@ -441,6 +451,7 @@ export const RCPOptionSelections: React.FC = props => || !fst (cantrips) || !fst (curses) || !fst (skills) + || !fst (terrainKnowledge) || isNothing (attributeAdjustment) || (isMotherTongueSelectionNeeded && motherTongue === 0) || ( @@ -448,15 +459,6 @@ export const RCPOptionSelections: React.FC = props => && snd (isScriptSelectionNeeded) && mainScript === 0 ) - || ( - isJust (PSA[ProfessionSelectionIds.SPECIALIZATION] (prof_sels)) - && snd (specialization) === "" - && isNothing (fst (specialization)) - ) - || ( - isJust (PSA[ProfessionSelectionIds.TERRAIN_KNOWLEDGE] (prof_sels)) - && isNothing (terrainKnowledgeActive) - ) || ( PSA[ProfessionSelectionIds.GUILD_MAGE_UNFAMILIAR_SPELL] (prof_sels) && isNothing (selectedUnfamiliarSpell) @@ -521,7 +523,7 @@ export const RCPOptionSelections: React.FC = props => {maybeToNullable (guildMageUnfamiliarSpell)} {maybeToNullable (snd (cantrips))} {maybeToNullable (snd (skills))} - {maybeToNullable (terrainKnowledge)} + {maybeToNullable (snd (terrainKnowledge))} ) => DropdownOption ( name: Application.A.name (e), })) -const applicationsToRadio = map ((e: Record) => Option ({ +const applicationsToRadio = map ((e: Record) => RadioOption ({ name: Application.A.name (e), value: Just (Application.A.id (e)), })) diff --git a/src/App/Views/RCPOptionSelections/SkillSpecializationSelectionList.tsx b/src/App/Views/RCPOptionSelections/SkillSpecializationSelectionList.tsx index 17281c52..b891bc2e 100644 --- a/src/App/Views/RCPOptionSelections/SkillSpecializationSelectionList.tsx +++ b/src/App/Views/RCPOptionSelections/SkillSpecializationSelectionList.tsx @@ -5,6 +5,7 @@ import { bind, ensure, fromJust, fromMaybe, isJust, isNothing, Just, mapMaybe, M import { lookupF } from "../../../Data/OrderedMap"; import { Record } from "../../../Data/Record"; import { fst, Pair, snd, Tuple } from "../../../Data/Tuple"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { SpecializationSelection } from "../../Models/Wiki/professionSelections/SpecializationSelection"; import { Skill } from "../../Models/Wiki/Skill"; @@ -12,7 +13,7 @@ import { WikiModel, WikiModelRecord } from "../../Models/Wiki/WikiModel"; import { localizeOrList, translateP } from "../../Utilities/I18n"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { isString } from "../../Utilities/typeCheckUtils"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { SkillSpecializationSelectionApplications } from "./SkillSpecializationSelectionApplications"; const WA = WikiModel.A diff --git a/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionList.tsx b/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionList.tsx index bf5b2760..36ce4a2c 100644 --- a/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionList.tsx +++ b/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionList.tsx @@ -1,48 +1,78 @@ import * as React from "react"; import { fmap } from "../../../Data/Functor"; import { elem, List } from "../../../Data/List"; -import { ensure, mapMaybe, Maybe, maybeToNullable } from "../../../Data/Maybe"; +import { bindF, ensure, joinMaybeList, mapMaybe, Maybe, maybe } from "../../../Data/Maybe"; +import { lookup } from "../../../Data/OrderedMap"; import { Record } from "../../../Data/Record"; +import { Tuple } from "../../../Data/Tuple"; +import { SpecialAbilityId } from "../../Constants/Ids"; +import { TerrainKnowledgeSelection } from "../../Models/Wiki/professionSelections/TerrainKnowledgeSelection"; import { SpecialAbility } from "../../Models/Wiki/SpecialAbility"; import { SelectOption, selectToDropdownOption } from "../../Models/Wiki/sub/SelectOption"; +import { WikiModel, WikiModelRecord } from "../../Models/Wiki/WikiModel"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { isNumber } from "../../Utilities/typeCheckUtils"; import { Dropdown } from "../Universal/Dropdown"; -export interface TerrainKnowledgeProps { - active: Maybe - available: List - terrainKnowledge: Record - set (id: number): void -} - +const WA = WikiModel.A +const TKSA = TerrainKnowledgeSelection.A const SAA = SpecialAbility.A -export function TerrainKnowledge (props: TerrainKnowledgeProps) { - const { active, available, terrainKnowledge, set } = props +export const isTerrainKnowledgeSelectionValid = + (activeTerrain: Maybe) => + (selection: Record): Tuple<[boolean]> => { + const sid = TKSA.sid (selection) + + const is_terrain_valid = Maybe.any (List.elemF (sid)) (activeTerrain) + + return Tuple (is_terrain_valid) + } + +interface Props { + wiki: WikiModelRecord + active: Maybe + selection: Record + setTerrainId (id: number): void +} + +export const TerrainKnowledgeSelectionList: React.FC = props => { + const { active, selection, setTerrainId, wiki } = props + + const available = TKSA.sid (selection) + + const terrain_knowledge = React.useMemo ( + () => pipe_ ( + wiki, + WA.specialAbilities, + lookup (SpecialAbilityId.TerrainKnowledge) + ), + [ wiki ] + ) + + const terrains = React.useMemo ( + () => pipe_ ( + terrain_knowledge, + bindF (SAA.select), + joinMaybeList, + mapMaybe (pipe ( + ensure (pipe ( + SelectOption.A.id, + id => isNumber (id) && elem (id) (available) + )), + fmap (selectToDropdownOption) + )) + ), + [ available, terrain_knowledge ] + ) return (
-

{SAA.name (terrainKnowledge)}

- {pipe_ ( - terrainKnowledge, - SAA.select, - fmap (select => ( - isNumber (id) && elem (id) (available) - )), - fmap (selectToDropdownOption) - )) - (select)} - onChangeJust={set} - /> - )), - maybeToNullable - )} +

{maybe ("") (SAA.name) (terrain_knowledge)}

+
) } diff --git a/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionListItem.tsx b/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionListItem.tsx deleted file mode 100644 index 6ed6b6d6..00000000 --- a/src/App/Views/RCPOptionSelections/TerrainKnowledgeSelectionListItem.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import * as React from "react"; -import { isJust, isNothing, Just, Maybe, maybe, maybeRNullF, Nothing } from "../../../Data/Maybe"; -import { lte } from "../../../Data/Num"; -import { lookup, OrderedMap } from "../../../Data/OrderedMap"; -import { Record } from "../../../Data/Record"; -import { Spell } from "../../Models/Wiki/Spell"; -import { minus } from "../../Utilities/Chars"; -import { BorderButton } from "../Universal/BorderButton"; -import { Checkbox } from "../Universal/Checkbox"; - -const SA = Spell.A - -interface Props { - apLeft: number - curse: Record - active: OrderedMap - adjustCurseValue: (id: string) => (method: Maybe<"add" | "remove">) => void -} - -export const TerrainKnowledgeSelectionListItem: React.FC = props => { - const { active, apLeft, curse, adjustCurseValue } = props - - const id = SA.id (curse) - const name = SA.name (curse) - const ic = SA.ic (curse) - - const mvalue = lookup (id) (active) - - const handleToggle = React.useCallback ( - () => adjustCurseValue (id) (Nothing), - [ id, adjustCurseValue ] - ) - - const handleAddPoint = React.useCallback ( - () => adjustCurseValue (id) (Just ("add")), - [ id, adjustCurseValue ] - ) - - const handleRemovePoint = React.useCallback ( - () => adjustCurseValue (id) (Just ("remove")), - [ id, adjustCurseValue ] - ) - - return ( -
  • - - {name} - - {maybeRNullF (mvalue) (value => ({value}))} - - -
  • - ) -} diff --git a/src/App/Views/Races/RaceVariants.tsx b/src/App/Views/Races/RaceVariants.tsx index b491fa85..bb81dd95 100644 --- a/src/App/Views/Races/RaceVariants.tsx +++ b/src/App/Views/Races/RaceVariants.tsx @@ -5,11 +5,12 @@ import { bindF, ensure, Just, Maybe, maybe } from "../../../Data/Maybe"; import { Record } from "../../../Data/Record"; import { selectRaceVariant } from "../../Actions/RaceActions"; import { RaceCombined, RaceCombinedA_ } from "../../Models/View/RaceCombined"; +import { RadioOption } from "../../Models/View/RadioOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { RaceVariant } from "../../Models/Wiki/RaceVariant"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { sortRecordsByName } from "../../Utilities/sortBy"; -import { Option, RadioButtonGroup } from "../Universal/RadioButtonGroup"; +import { RadioButtonGroup } from "../Universal/RadioButtonGroup"; export interface RaceVariantsProps { currentId: Maybe @@ -34,7 +35,7 @@ export const RaceVariants: React.FC = props => { find (pipe (RaceCombinedA_.id, Maybe.elemF (currentId))), bindF (pipe ( RaceCombined.A.mappedVariants, - map (e => Option ({ + map (e => RadioOption ({ name: RaceVariant.A.name (e), value: Just (RaceVariant.A.id (e)), })), diff --git a/src/App/Views/Router/Router.tsx b/src/App/Views/Router/Router.tsx index aaceb1fa..bccf6f95 100644 --- a/src/App/Views/Router/Router.tsx +++ b/src/App/Views/Router/Router.tsx @@ -32,21 +32,21 @@ import { MainContent } from "../Universal/MainContent"; import { Page } from "../Universal/Page"; import { Scroll } from "../Universal/Scroll"; -export interface RouterProps { +interface Props { id: TabId l10n: L10nRecord mhero: Maybe } -export interface RouterState { +interface State { hasError?: { error: Error; info: any; } } -export class Router extends React.Component { - state: RouterState = {} +export class Router extends React.Component { + state: State = {} componentDidCatch (error: any, info: any) { this.setState (() => ({ hasError: { error, info } })) diff --git a/src/App/Views/Rules/BookSelection.tsx b/src/App/Views/Rules/BookSelection.tsx index 51b9846e..b3259e60 100644 --- a/src/App/Views/Rules/BookSelection.tsx +++ b/src/App/Views/Rules/BookSelection.tsx @@ -1,14 +1,15 @@ import * as React from "react"; import { List, map, toArray } from "../../../Data/List"; -import { member, OrderedSet } from "../../../Data/OrderedSet"; +import { OrderedSet } from "../../../Data/OrderedSet"; import { Record } from "../../../Data/Record"; import { Book } from "../../Models/Wiki/Book"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { pipe_ } from "../../Utilities/pipe"; import { Checkbox } from "../Universal/Checkbox"; +import { BookSelectionListItem } from "./BookSelectionListItem"; -export interface BookSelectionProps { +interface Props { l10n: L10nRecord sortedBooks: List> allRuleBooksEnabled: boolean @@ -17,7 +18,7 @@ export interface BookSelectionProps { switchEnableRuleBook (id: string): void } -export function BookSelection (props: BookSelectionProps) { +export const BookSelection: React.FC = props => { const { l10n, sortedBooks, @@ -37,27 +38,15 @@ export function BookSelection (props: BookSelectionProps) {
    {pipe_ ( sortedBooks, - map (e => { - const id = Book.A.id (e) - const name = Book.A.name (e) - const isCore = Book.A.isCore (e) - const isAdultContent = Book.A.isAdultContent (e) - - return ( - switchEnableRuleBook (id)} - label={name} - disabled={allRuleBooksEnabled && !isAdultContent || isCore} - /> - ) - }), + map (e => ( + + )), toArray )}
    diff --git a/src/App/Views/Rules/BookSelectionListItem.tsx b/src/App/Views/Rules/BookSelectionListItem.tsx new file mode 100644 index 00000000..a2e35a45 --- /dev/null +++ b/src/App/Views/Rules/BookSelectionListItem.tsx @@ -0,0 +1,42 @@ +import * as React from "react" +import { member, OrderedSet } from "../../../Data/OrderedSet" +import { Record } from "../../../Data/Record" +import { Book } from "../../Models/Wiki/Book" +import { Checkbox } from "../Universal/Checkbox" + +const BA = Book.A + +interface Props { + book: Record + enabledRuleBooks: OrderedSet + areAllRuleBooksEnabled: boolean + switchBookEnabled: (id: string) => void +} + +export const BookSelectionListItem: React.FC = props => { + const { areAllRuleBooksEnabled, book, enabledRuleBooks, switchBookEnabled } = props + + const id = BA.id (book) + const name = BA.name (book) + const isCore = BA.isCore (book) + const isAdultContent = BA.isAdultContent (book) + + const handleSwitch = React.useCallback ( + () => switchBookEnabled (id), + [ id, switchBookEnabled ] + ) + + return ( + + ) +} diff --git a/src/App/Views/Rules/Rules.tsx b/src/App/Views/Rules/Rules.tsx index 0f307cfd..1930de7e 100644 --- a/src/App/Views/Rules/Rules.tsx +++ b/src/App/Views/Rules/Rules.tsx @@ -4,12 +4,13 @@ import { fromMaybe, isJust, Just, liftM2, Maybe, Nothing } from "../../../Data/M import { Record } from "../../../Data/Record"; import { HeroModel, HeroModelRecord } from "../../Models/Hero/HeroModel"; import { Rules } from "../../Models/Hero/Rules"; +import { DropdownOption } from "../../Models/View/DropdownOption"; import { Book } from "../../Models/Wiki/Book"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { Locale } from "../../Utilities/Raw/JSON/Config"; import { Checkbox } from "../Universal/Checkbox"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; +import { Dropdown } from "../Universal/Dropdown"; import { Scroll } from "../Universal/Scroll"; import { BookSelection } from "./BookSelection"; @@ -36,9 +37,9 @@ export interface RulesDispatchProps { setGuildMageSpell (spellId: string): void } -export type RulesProps = RulesStateProps & RulesDispatchProps & RulesOwnProps +type Props = RulesStateProps & RulesDispatchProps & RulesOwnProps -export const RulesView: React.FC = props => { +export const RulesView: React.FC = props => { const { sortedBooks, changeAttributeValueLimit, @@ -71,7 +72,7 @@ export const RulesView: React.FC = props => { const handleHigherParadeValues = React.useCallback ( () => changeHigherParadeValues (Just (areHigherParadeValuesEnabled ? 0 : 2)), - [changeHigherParadeValues, areHigherParadeValuesEnabled] + [ changeHigherParadeValues, areHigherParadeValuesEnabled ] ) return ( diff --git a/src/App/Views/Settings/Settings.tsx b/src/App/Views/Settings/Settings.tsx index bbccd490..2c9d1a28 100644 --- a/src/App/Views/Settings/Settings.tsx +++ b/src/App/Views/Settings/Settings.tsx @@ -1,14 +1,16 @@ import * as React from "react"; import { List } from "../../../Data/List"; import { Just, Maybe, Nothing } from "../../../Data/Maybe"; +import { DropdownOption } from "../../Models/View/DropdownOption"; +import { RadioOption } from "../../Models/View/RadioOption"; import { L10nRecord } from "../../Models/Wiki/L10n"; import { translate } from "../../Utilities/I18n"; import { Theme } from "../../Utilities/Raw/JSON/Config"; import { BorderButton } from "../Universal/BorderButton"; import { Checkbox } from "../Universal/Checkbox"; import { Dialog } from "../Universal/Dialog"; -import { Dropdown, DropdownOption } from "../Universal/Dropdown"; -import { Option, SegmentedControls } from "../Universal/SegmentedControls"; +import { Dropdown } from "../Universal/Dropdown"; +import { SegmentedControls } from "../Universal/SegmentedControls"; export interface SettingsOwnProps { l10n: L10nRecord @@ -34,9 +36,9 @@ export interface SettingsDispatchProps { switchEnableAnimations (): void } -export type SettingsProps = SettingsStateProps & SettingsDispatchProps & SettingsOwnProps +type Props = SettingsStateProps & SettingsDispatchProps & SettingsOwnProps -export function Settings (props: SettingsProps) { +export const Settings: React.FC = props => { const { close, isEditingHeroAfterCreationPhaseEnabled, @@ -98,11 +100,11 @@ export function Settings (props: SettingsProps) {

    {translate (l10n) ("languagehint")}

    > +interface Props { l10n: L10nRecord + attributes: List> } -export function AttributeMods (props: AttributeModsProps) { - return ( - - - - - - - - - - - - - - - - {pipe_ ( - props.attributes, - map (e => ), - toArray - )} - -
    {minus}3{minus}2{minus}10+1+2+3
    -
    - ) -} +export const AttributeMods: React.FC = ({ attributes, l10n }) => ( + + + + + + + + + + + + + + + {pipe_ ( + attributes, + map (e => ), + toArray + )} + +
    + {sign (-3)}{sign (-2)}{sign (-1)}{sign (0)}{sign (1)}{sign (2)}{sign (3)}
    +
    +) diff --git a/src/App/Views/Sheets/AttributeModsListItem.tsx b/src/App/Views/Sheets/AttributeModsListItem.tsx index 0d889ecc..d1aa61f2 100644 --- a/src/App/Views/Sheets/AttributeModsListItem.tsx +++ b/src/App/Views/Sheets/AttributeModsListItem.tsx @@ -2,14 +2,14 @@ import * as React from "react"; import { Record } from "../../../Data/Record"; import { AttributeCombined, AttributeCombinedA_ } from "../../Models/View/AttributeCombined"; -interface AttributeModsListItemProps { +interface Props { attribute: Record } -export function AttributeModsListItem (props: AttributeModsListItemProps) { - const id = AttributeCombinedA_.id (props.attribute) - const short = AttributeCombinedA_.short (props.attribute) - const value = AttributeCombinedA_.value (props.attribute) +export const AttributeModsListItem: React.FC = ({ attribute }) => { + const id = AttributeCombinedA_.id (attribute) + const short = AttributeCombinedA_.short (attribute) + const value = AttributeCombinedA_.value (attribute) return ( diff --git a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheet.tsx b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheet.tsx index ee51cd55..24198849 100644 --- a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheet.tsx +++ b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheet.tsx @@ -23,7 +23,7 @@ import { SheetWrapper } from "../SheetWrapper"; import { BelongingsSheetItemsColumn } from "./BelongingsSheetItemsColumn"; import { BelongingsSheetPet } from "./BelongingsSheetPet"; -export interface BelongingsSheetProps { +interface Props { attributes: List> items: Maybe>> l10n: L10nRecord @@ -33,7 +33,7 @@ export interface BelongingsSheetProps { totalWeight: Maybe } -export function BelongingsSheet (props: BelongingsSheetProps) { +export const BelongingsSheet: React.FC = props => { const { attributes, items: mitems, @@ -41,6 +41,7 @@ export function BelongingsSheet (props: BelongingsSheetProps) { purse, totalPrice: maybeTotalPrice, totalWeight: maybeTotalWeight, + pet, } = props const strength = @@ -193,7 +194,11 @@ export function BelongingsSheet (props: BelongingsSheetProps) {
    - + ) diff --git a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetItemsColumn.tsx b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetItemsColumn.tsx index 4c22ac94..261367c3 100644 --- a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetItemsColumn.tsx +++ b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetItemsColumn.tsx @@ -11,7 +11,7 @@ import { localizeNumber, localizeWeight, translate } from "../../../Utilities/I1 import { pipe, pipe_ } from "../../../Utilities/pipe"; import { renderMaybe, renderMaybeWith } from "../../../Utilities/ReactUtils"; -export interface BelongingsSheetItemsColumnProps { +interface Props { columnSize: number items: List> l10n: L10nRecord @@ -19,7 +19,7 @@ export interface BelongingsSheetItemsColumnProps { const IFVA = ItemForView.A -export function BelongingsSheetItemsColumn (props: BelongingsSheetItemsColumnProps) { +export const BelongingsSheetItemsColumn: React.FC = props => { const { columnSize, l10n, items } = props return ( diff --git a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetPet.tsx b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetPet.tsx index 3cc94f85..f44098ea 100644 --- a/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetPet.tsx +++ b/src/App/Views/Sheets/BelongingsSheet/BelongingsSheetPet.tsx @@ -15,13 +15,13 @@ import { renderMaybe, renderMaybeWith } from "../../../Utilities/ReactUtils"; import { AvatarWrapper } from "../../Universal/AvatarWrapper"; import { TextBox } from "../../Universal/TextBox"; -export interface BelongingsSheetPetProps { +interface Props { attributes: List> l10n: L10nRecord pet: Maybe> } -export function BelongingsSheetPet (props: BelongingsSheetPetProps) { +export const BelongingsSheetPet: React.FC = props => { const { attributes, l10n, pet: mpet } = props return ( diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheet.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheet.tsx index 172c5bfd..dec951db 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheet.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheet.tsx @@ -27,7 +27,7 @@ import { CombatSheetSpecialAbilities } from "./CombatSheetSpecialAbilities"; import { CombatSheetStates } from "./CombatSheetStates"; import { CombatSheetTechniques } from "./CombatSheetTechniques"; -export interface CombatSheetProps { +interface Props { armors: Maybe>> attributes: List> combatSpecialAbilities: Maybe>>> @@ -41,7 +41,7 @@ export interface CombatSheetProps { states: List> } -export function CombatSheet (props: CombatSheetProps) { +export const CombatSheet: React.FC = props => { const { armors, attributes, @@ -60,7 +60,7 @@ export function CombatSheet (props: CombatSheetProps) { return ( - + >> l10n: L10nRecord } const AA = Armor.A -export function CombatSheetArmor (props: CombatSheetArmorProps) { +export const CombatSheetArmor: React.FC = props => { const { l10n, armors: marmors } = props const movement_tag = translate (l10n) ("movement.short") diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetArmorZones.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetArmorZones.tsx index 920c56c2..1382347a 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetArmorZones.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetArmorZones.tsx @@ -11,14 +11,14 @@ import { localizeNumber, localizeWeight, translate } from "../../../Utilities/I1 import { pipe, pipe_ } from "../../../Utilities/pipe"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetArmorZonesProps { +interface Props { armorZones: Maybe>> l10n: L10nRecord } const HZAFVA = HitZoneArmorForView.A -export function CombatSheetArmorZones (props: CombatSheetArmorZonesProps) { +export const CombatSheetArmorZones: React.FC = props => { const { l10n, armorZones: mhit_zone_armors } = props return ( @@ -81,16 +81,16 @@ export function CombatSheetArmorZones (props: CombatSheetArmorZonesProps) { {replicateR (2 - Maybe.sum (fmapF (mhit_zone_armors) (flength))) (i => ( - - - - - - - - - - + + + + + + + + + + ))} diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetLifePoints.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetLifePoints.tsx index d874381a..c8f98eba 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetLifePoints.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetLifePoints.tsx @@ -12,12 +12,12 @@ import { Box } from "../../Universal/Box"; import { LabelBox } from "../../Universal/LabelBox"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetLifePointsProps { +interface Props { derivedCharacteristics: List> l10n: L10nRecord } -export function CombatSheetLifePoints (props: CombatSheetLifePointsProps) { +export const CombatSheetLifePoints: React.FC = props => { const { derivedCharacteristics, l10n } = props const lifePoints = @@ -59,11 +59,11 @@ export function CombatSheetLifePoints (props: CombatSheetLifePointsProps) { {translate (l10n) ("pain3")}
    - 5 + {5} {translate (l10n) ("pain4")}
    - 0 + {0} {translate (l10n) ("dying")}
    diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetMeleeWeapons.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetMeleeWeapons.tsx index 736e7c86..1f2b638d 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetMeleeWeapons.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetMeleeWeapons.tsx @@ -15,14 +15,14 @@ import { pipe, pipe_ } from "../../../Utilities/pipe"; import { renderMaybe, renderMaybeWith } from "../../../Utilities/ReactUtils"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetMeleeWeaponsProps { +interface Props { l10n: L10nRecord meleeWeapons: Maybe>> } const MWA = MeleeWeapon.A -export function CombatSheetMeleeWeapons (props: CombatSheetMeleeWeaponsProps) { +export const CombatSheetMeleeWeapons: React.FC = props => { const { l10n, meleeWeapons: mmelee_weapons } = props return ( diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetRangedWeapons.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetRangedWeapons.tsx index 904f0247..09c62436 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetRangedWeapons.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetRangedWeapons.tsx @@ -12,14 +12,14 @@ import { pipe, pipe_ } from "../../../Utilities/pipe"; import { renderMaybe, renderMaybeWith } from "../../../Utilities/ReactUtils"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetRangedWeaponProps { +interface Props { l10n: L10nRecord rangedWeapons: Maybe>> } const RWA = RangedWeapon.A -export function CombatSheetRangedWeapons (props: CombatSheetRangedWeaponProps) { +export const CombatSheetRangedWeapons: React.FC = props => { const { l10n, rangedWeapons: mranged_weapons } = props return ( @@ -103,16 +103,16 @@ export function CombatSheetRangedWeapons (props: CombatSheetRangedWeaponProps) { {replicateR (2 - Maybe.sum (fmapF (mranged_weapons) (flength))) (i => ( - - - - - - - - - - + + + + + + + + + + ))} diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetShields.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetShields.tsx index 87f285be..ada40f98 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetShields.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetShields.tsx @@ -12,14 +12,14 @@ import { pipe, pipe_ } from "../../../Utilities/pipe"; import { renderMaybeWith } from "../../../Utilities/ReactUtils"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetShieldsProps { +interface Props { l10n: L10nRecord shieldsAndParryingWeapons: Maybe>> } const SOPWA = ShieldOrParryingWeapon.A -export function CombatSheetShields (props: CombatSheetShieldsProps) { +export const CombatSheetShields: React.FC = props => { const { l10n, shieldsAndParryingWeapons: msh_or_parry_weapons } = props return ( @@ -59,7 +59,9 @@ export function CombatSheetShields (props: CombatSheetShieldsProps) { {renderMaybeWith (toRoman) (SOPWA.loss (e))} - {sign (Maybe.sum (SOPWA.atMod (e)))}/{sign (Maybe.sum (SOPWA.paMod (e)))} + {sign (Maybe.sum (SOPWA.atMod (e)))} + {"/"} + {sign (Maybe.sum (SOPWA.paMod (e)))} {pipe_ ( @@ -80,12 +82,12 @@ export function CombatSheetShields (props: CombatSheetShieldsProps) { {replicateR (2 - Maybe.sum (fmapF (msh_or_parry_weapons) (flength))) (i => ( - - - - - - + + + + + + ))} diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetSpecialAbilities.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetSpecialAbilities.tsx index 09fa8244..63c3c1ee 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetSpecialAbilities.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetSpecialAbilities.tsx @@ -9,12 +9,12 @@ import { compressList } from "../../../Utilities/Activatable/activatableNameUtil import { translate } from "../../../Utilities/I18n"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetSpecialAbilitiesProps { +interface Props { combatSpecialAbilities: Maybe>>> l10n: L10nRecord } -export function CombatSheetSpecialAbilities (props: CombatSheetSpecialAbilitiesProps) { +export const CombatSheetSpecialAbilities: React.FC = props => { const { combatSpecialAbilities: maybeCombatSpecialAbilities, l10n } = props return ( diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetStates.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetStates.tsx index df11c9a0..aaf1408c 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetStates.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetStates.tsx @@ -8,13 +8,13 @@ import { translate } from "../../../Utilities/I18n"; import { toRoman } from "../../../Utilities/NumberUtils"; import { pipe_ } from "../../../Utilities/pipe"; -export interface CombatSheetStatesProps { +interface Props { l10n: L10nRecord conditions: List> states: List> } -export function CombatSheetStates (props: CombatSheetStatesProps) { +export const CombatSheetStates: React.FC = props => { const { l10n, conditions, states } = props const statesSplit = splitAt (9) (states) @@ -35,16 +35,16 @@ export function CombatSheetStates (props: CombatSheetStatesProps) {
    {NumIdName.A.name (e)}
    -
    +
    -
    +
    -
    +
    -
    +
    )), @@ -62,7 +62,7 @@ export function CombatSheetStates (props: CombatSheetStatesProps) {
    {NumIdName.A.name (e)}
    -
    +
    )), @@ -77,7 +77,7 @@ export function CombatSheetStates (props: CombatSheetStatesProps) {
    {NumIdName.A.name (e)}
    -
    +
    )), diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetTechniques.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetTechniques.tsx index 0f69401f..3d11001a 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetTechniques.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetTechniques.tsx @@ -13,7 +13,7 @@ import { translate } from "../../../Utilities/I18n"; import { pipe, pipe_ } from "../../../Utilities/pipe"; import { TextBox } from "../../Universal/TextBox"; -export interface CombatSheetTechniquesProps { +interface Props { attributes: List> combatTechniques: Maybe>> l10n: L10nRecord @@ -22,7 +22,7 @@ export interface CombatSheetTechniquesProps { const CTWAPBA = CombatTechniqueWithAttackParryBase.A const CTWAPBA_ = CombatTechniqueWithAttackParryBaseA_ -export function CombatSheetTechniques (props: CombatSheetTechniquesProps) { +export const CombatSheetTechniques: React.FC = props => { const { attributes, combatTechniques: mcombat_techniques, l10n } = props return ( diff --git a/src/App/Views/Sheets/CombatSheet/CombatSheetZones.tsx b/src/App/Views/Sheets/CombatSheet/CombatSheetZones.tsx index ea32923b..a87d69ac 100644 --- a/src/App/Views/Sheets/CombatSheet/CombatSheetZones.tsx +++ b/src/App/Views/Sheets/CombatSheet/CombatSheetZones.tsx @@ -27,7 +27,7 @@ import { CombatSheetSpecialAbilities } from "./CombatSheetSpecialAbilities"; import { CombatSheetStates } from "./CombatSheetStates"; import { CombatSheetTechniques } from "./CombatSheetTechniques"; -export interface CombatSheetZonesProps { +interface Props { armorZones: Maybe>> attributes: List> combatSpecialAbilities: Maybe>>> @@ -41,7 +41,7 @@ export interface CombatSheetZonesProps { states: List> } -export function CombatSheetZones (props: CombatSheetZonesProps) { +export const CombatSheetZones: React.FC = props => { const { armorZones, attributes, @@ -60,7 +60,7 @@ export function CombatSheetZones (props: CombatSheetZonesProps) { return ( - + attributes: List> blessedPrimary: Maybe @@ -38,10 +38,17 @@ export interface LiturgicalChantsSheetProps { switchAttributeValueVisibility (): void } -export function LiturgicalChantsSheet (props: LiturgicalChantsSheetProps) { +export const LiturgicalChantsSheet: React.FC = props => { const { + aspects, + attributes, + blessedPrimary, + blessedSpecialAbilities, + blessedTradition, + blessings, checkAttributeValueVisibility, derivedCharacteristics, + liturgicalChants, l10n, switchAttributeValueVisibility, } = props @@ -74,17 +81,37 @@ export function LiturgicalChantsSheet (props: LiturgicalChantsSheetProps) {
    - - - - - + + + + +
    diff --git a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetBlessings.tsx b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetBlessings.tsx index 419f8984..910b0e28 100644 --- a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetBlessings.tsx +++ b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetBlessings.tsx @@ -10,12 +10,12 @@ import { pipe, pipe_ } from "../../../Utilities/pipe"; import { sortStrings } from "../../../Utilities/sortBy"; import { TextBox } from "../../Universal/TextBox"; -export interface LiturgicalChantSheetBlessingsProps { - blessings: Maybe>> +interface Props { l10n: L10nRecord + blessings: Maybe>> } -export function LiturgicalChantsSheetBlessings (props: LiturgicalChantSheetBlessingsProps) { +export const LiturgicalChantsSheetBlessings: React.FC = props => { const { blessings, l10n } = props return ( diff --git a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetLiturgicalChants.tsx b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetLiturgicalChants.tsx index 97219080..8f88ed2a 100644 --- a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetLiturgicalChants.tsx +++ b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetLiturgicalChants.tsx @@ -21,7 +21,7 @@ import { sortStrings } from "../../../Utilities/sortBy"; import { getCheckModStr } from "../../InlineWiki/Elements/WikiSkillCheck"; import { TextBox } from "../../Universal/TextBox"; -export interface LiturgicalChantsSheetLiturgicalChantsProps { +interface Props { attributes: List> checkAttributeValueVisibility: boolean liturgicalChants: Maybe>> @@ -30,9 +30,7 @@ export interface LiturgicalChantsSheetLiturgicalChantsProps { const LCWRA_ = LiturgicalChantWithRequirementsA_ -export function LiturgicalChantsSheetLiturgicalChants ( - props: LiturgicalChantsSheetLiturgicalChantsProps -) { +export const LiturgicalChantsSheetLiturgicalChants: React.FC = props => { const { attributes, checkAttributeValueVisibility, diff --git a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetSpecialAbilities.tsx b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetSpecialAbilities.tsx index 7dfbcefc..a5268fd1 100644 --- a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetSpecialAbilities.tsx +++ b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetSpecialAbilities.tsx @@ -9,14 +9,12 @@ import { compressList } from "../../../Utilities/Activatable/activatableNameUtil import { translate } from "../../../Utilities/I18n"; import { TextBox } from "../../Universal/TextBox"; -export interface LiturgicalChantsSheetSpecialAbilitiesProps { - blessedSpecialAbilities: Maybe>>> +interface Props { l10n: L10nRecord + blessedSpecialAbilities: Maybe>>> } -export function LiturgicalChantsSheetSpecialAbilities ( - props: LiturgicalChantsSheetSpecialAbilitiesProps -) { +export const LiturgicalChantsSheetSpecialAbilities: React.FC = props => { const { l10n, blessedSpecialAbilities: maybeBlessedSpecialAbilities } = props return ( diff --git a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetTraditionsAspects.tsx b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetTraditionsAspects.tsx index 43252ed4..50992ed9 100644 --- a/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetTraditionsAspects.tsx +++ b/src/App/Views/Sheets/LiturgicalChantsSheet/LiturgicalChantsSheetTraditionsAspects.tsx @@ -4,16 +4,14 @@ import { L10nRecord } from "../../../Models/Wiki/L10n"; import { translate } from "../../../Utilities/I18n"; import { renderMaybe } from "../../../Utilities/ReactUtils"; -export interface LiturgicalChantsSheetTraditionsAspectsProps { +interface Props { + l10n: L10nRecord aspects: Maybe blessedPrimary: Maybe blessedTradition: Maybe - l10n: L10nRecord } -export function LiturgicalChantsSheetTraditionsAspects ( - props: LiturgicalChantsSheetTraditionsAspectsProps -) { +export const LiturgicalChantsSheetTraditionsAspects: React.FC = props => { const { aspects, blessedPrimary, blessedTradition, l10n } = props return ( diff --git a/src/App/Views/Sheets/MainSheet/MainSheet.tsx b/src/App/Views/Sheets/MainSheet/MainSheet.tsx index 8a465250..fba790c3 100644 --- a/src/App/Views/Sheets/MainSheet/MainSheet.tsx +++ b/src/App/Views/Sheets/MainSheet/MainSheet.tsx @@ -27,7 +27,7 @@ import { SheetWrapper } from "../SheetWrapper"; import { MainSheetAttributes } from "./MainSheetAttributes"; import { MainSheetPersonalData } from "./MainSheetPersonalData"; -export interface MainSheetProps { +interface Props { advantagesActive: Maybe>>> ap: Maybe> attributes: List> @@ -47,7 +47,7 @@ export interface MainSheetProps { printToPDF (): void } -export function MainSheet (props: MainSheetProps) { +export const MainSheet: React.FC = props => { const { advantagesActive: maybeAdvantagesActive, ap, diff --git a/src/App/Views/Sheets/MainSheet/MainSheetAttributes.tsx b/src/App/Views/Sheets/MainSheet/MainSheetAttributes.tsx index 9d668867..dfb6f39e 100644 --- a/src/App/Views/Sheets/MainSheet/MainSheetAttributes.tsx +++ b/src/App/Views/Sheets/MainSheet/MainSheetAttributes.tsx @@ -12,7 +12,7 @@ import { pipe_ } from "../../../Utilities/pipe"; import { MainSheetAttributesItem } from "./MainSheetAttributesItem"; import { MainSheetFatePoints } from "./MainSheetFatePoints"; -export interface MainSheetAttributesProps { +interface Props { attributes: List> fatePointsModifier: number l10n: L10nRecord @@ -21,7 +21,7 @@ export interface MainSheetAttributesProps { const DCA = DerivedCharacteristic.A -export function MainSheetAttributes (props: MainSheetAttributesProps) { +export const MainSheetAttributes: React.FC = props => { const { attributes, fatePointsModifier, race, l10n } = props return ( diff --git a/src/App/Views/Sheets/MainSheet/MainSheetAttributesItem.tsx b/src/App/Views/Sheets/MainSheet/MainSheetAttributesItem.tsx index 2677620a..690bfd03 100644 --- a/src/App/Views/Sheets/MainSheet/MainSheetAttributesItem.tsx +++ b/src/App/Views/Sheets/MainSheet/MainSheetAttributesItem.tsx @@ -7,7 +7,7 @@ import { classListMaybe } from "../../../Utilities/CSS"; import { pipe, pipe_ } from "../../../Utilities/pipe"; import { renderMaybeWith } from "../../../Utilities/ReactUtils"; -export interface MainSheetAttributesItemProps { +interface Props { add: Maybe calc: string empty: Maybe @@ -19,7 +19,7 @@ export interface MainSheetAttributesItemProps { subLabel: Maybe } -export function MainSheetAttributesItem (props: MainSheetAttributesItemProps) { +export const MainSheetAttributesItem: React.FC = props => { const { add, base, @@ -37,7 +37,13 @@ export function MainSheetAttributesItem (props: MainSheetAttributesItemProps) {

    {label}

    {calc} - {maybeRNull ((str: string) => {str}:) (subLabel)} + {maybeRNull ((str: string) => ( + + {str} + {":"} + + )) + (subLabel)}
    diff --git a/src/App/Views/Sheets/MainSheet/MainSheetFatePoints.tsx b/src/App/Views/Sheets/MainSheet/MainSheetFatePoints.tsx index 4947af1f..cf45afd3 100644 --- a/src/App/Views/Sheets/MainSheet/MainSheetFatePoints.tsx +++ b/src/App/Views/Sheets/MainSheet/MainSheetFatePoints.tsx @@ -5,12 +5,12 @@ import { translate } from "../../../Utilities/I18n"; import { LabelBox } from "../../Universal/LabelBox"; import { TextBox } from "../../Universal/TextBox"; -export interface SkillsSheetLanguagesProps { +interface Props { fatePointsModifier: number l10n: L10nRecord } -export function MainSheetFatePoints (props: SkillsSheetLanguagesProps) { +export const MainSheetFatePoints: React.FC = props => { const { fatePointsModifier, l10n } = props return ( diff --git a/src/App/Views/Sheets/MainSheet/MainSheetPersonalData.tsx b/src/App/Views/Sheets/MainSheet/MainSheetPersonalData.tsx index 99f67616..a41c3dfe 100644 --- a/src/App/Views/Sheets/MainSheet/MainSheetPersonalData.tsx +++ b/src/App/Views/Sheets/MainSheet/MainSheetPersonalData.tsx @@ -20,7 +20,7 @@ import { Plain } from "../../Universal/Plain"; const PDA = PersonalData.A -export interface MainSheetPersonalDataProps { +interface Props { ap: Maybe> avatar: Maybe culture: Maybe> @@ -36,7 +36,7 @@ export interface MainSheetPersonalDataProps { socialstatusTags: List } -export function MainSheetPersonalData (props: MainSheetPersonalDataProps) { +export const MainSheetPersonalData: React.FC = props => { const { ap, avatar, diff --git a/src/App/Views/Sheets/SheetHeader.tsx b/src/App/Views/Sheets/SheetHeader.tsx index 8e4fb0f8..4ad95a55 100644 --- a/src/App/Views/Sheets/SheetHeader.tsx +++ b/src/App/Views/Sheets/SheetHeader.tsx @@ -22,14 +22,14 @@ export const HeaderValue = value: Nothing, }) -export interface SheetHeaderProps { +interface Props { add?: List> attributes: List> l10n: L10nRecord title: string } -export function SheetHeader (props: SheetHeaderProps) { +export const SheetHeader: React.FC = props => { const { add = List> (), attributes, l10n, title } = props const list: List> = diff --git a/src/App/Views/Sheets/SheetHeaderAttribute.tsx b/src/App/Views/Sheets/SheetHeaderAttribute.tsx index 9c2bcf4c..e653f239 100644 --- a/src/App/Views/Sheets/SheetHeaderAttribute.tsx +++ b/src/App/Views/Sheets/SheetHeaderAttribute.tsx @@ -4,17 +4,15 @@ import { Just, Maybe } from "../../../Data/Maybe"; import { classListMaybe } from "../../Utilities/CSS"; import { renderMaybe } from "../../Utilities/ReactUtils"; -export interface SheetHeaderAttributeProps { +interface Props { id: string label: string value: Maybe } -export function SheetHeaderAttribute (props: SheetHeaderAttributeProps) { - return ( -
    - {props.label} - {renderMaybe (props.value)} -
    - ) -} +export const SheetHeaderAttribute: React.FC = ({ id, label, value }) => ( +
    + {label} + {renderMaybe (value)} +
    +) diff --git a/src/App/Views/Sheets/SheetOptions.tsx b/src/App/Views/Sheets/SheetOptions.tsx index 37fbc435..98511912 100644 --- a/src/App/Views/Sheets/SheetOptions.tsx +++ b/src/App/Views/Sheets/SheetOptions.tsx @@ -1,10 +1,10 @@ import * as React from "react"; -export interface SheetOptionsProps { +interface Props { children?: React.ReactNode } -export function SheetOptions (props: SheetOptionsProps) { +export const SheetOptions: React.FC = props => { const { children } = props return ( diff --git a/src/App/Views/Sheets/SheetWrapper.tsx b/src/App/Views/Sheets/SheetWrapper.tsx index 1a053ea6..f02e60e1 100644 --- a/src/App/Views/Sheets/SheetWrapper.tsx +++ b/src/App/Views/Sheets/SheetWrapper.tsx @@ -1,10 +1,10 @@ import * as React from "react"; -export interface SheetWrapperProps { +interface Props { children?: React.ReactNode } -export function SheetWrapper (props: SheetWrapperProps) { +export const SheetWrapper: React.FC = props => { const { children } = props return ( diff --git a/src/App/Views/Sheets/Sheets.tsx b/src/App/Views/Sheets/Sheets.tsx index 571f01d4..604d3a09 100644 --- a/src/App/Views/Sheets/Sheets.tsx +++ b/src/App/Views/Sheets/Sheets.tsx @@ -115,12 +115,12 @@ export interface SheetsDispatchProps { switchAttributeValueVisibility (): void } -export type SheetsProps = SheetsStateProps & SheetsDispatchProps & SheetsOwnProps +type Props = SheetsStateProps & SheetsDispatchProps & SheetsOwnProps const HA = HeroModel.A const RA = Rules.A -export function Sheets (props: SheetsProps) { +export const Sheets: React.FC = props => { const { derivedCharacteristics, books, diff --git a/src/App/Views/Sheets/SkillsSheet/SkillsSheet.tsx b/src/App/Views/Sheets/SkillsSheet/SkillsSheet.tsx index a39c5b5d..4f52ffef 100644 --- a/src/App/Views/Sheets/SkillsSheet/SkillsSheet.tsx +++ b/src/App/Views/Sheets/SkillsSheet/SkillsSheet.tsx @@ -21,7 +21,7 @@ import { SkillsSheetRoutineChecks } from "./SkillsSheetRoutineChecks"; import { SkillsSheetScripts } from "./SkillsSheetScripts"; import { SkillsSheetSkills } from "./SkillsSheetSkills"; -export interface SkillsSheetProps { +interface Props { attributes: List> checkAttributeValueVisibility: boolean languagesStateEntry: Maybe> @@ -34,7 +34,7 @@ export interface SkillsSheetProps { switchAttributeValueVisibility (): void } -export function SkillsSheet (props: SkillsSheetProps) { +export const SkillsSheet: React.FC = props => { const { attributes, checkAttributeValueVisibility, diff --git a/src/App/Views/Sheets/SkillsSheet/SkillsSheetLanguages.tsx b/src/App/Views/Sheets/SkillsSheet/SkillsSheetLanguages.tsx index 5717d4dc..7ced2507 100644 --- a/src/App/Views/Sheets/SkillsSheet/SkillsSheetLanguages.tsx +++ b/src/App/Views/Sheets/SkillsSheet/SkillsSheetLanguages.tsx @@ -17,7 +17,7 @@ import { pipe_ } from "../../../Utilities/pipe"; import { comparingR, sortByMulti } from "../../../Utilities/sortBy"; import { TextBox } from "../../Universal/TextBox"; -export interface SkillsSheetLanguagesProps { +interface Props { languagesStateEntry: Maybe> languagesWikiEntry: Maybe> l10n: L10nRecord @@ -37,7 +37,7 @@ const IdNameLevel = level: 0, }) -export function SkillsSheetLanguages (props: SkillsSheetLanguagesProps) { +export const SkillsSheetLanguages: React.FC = props => { const { languagesStateEntry: maybeLanguagesStateEntry, languagesWikiEntry: maybeLanguagesWikiEntry, diff --git a/src/App/Views/Sheets/SkillsSheet/SkillsSheetQualityLevels.tsx b/src/App/Views/Sheets/SkillsSheet/SkillsSheetQualityLevels.tsx index 8d0dd848..c4ffa144 100644 --- a/src/App/Views/Sheets/SkillsSheet/SkillsSheetQualityLevels.tsx +++ b/src/App/Views/Sheets/SkillsSheet/SkillsSheetQualityLevels.tsx @@ -4,11 +4,11 @@ import { ndash } from "../../../Utilities/Chars"; import { translate } from "../../../Utilities/I18n"; import { TextBox } from "../../Universal/TextBox"; -export interface SkillsSheetQualityLevelsProps { +interface Props { l10n: L10nRecord } -export const SkillsSheetQualityLevels = ({ l10n }: SkillsSheetQualityLevelsProps) => ( +export const SkillsSheetQualityLevels: React.FC = ({ l10n }) => ( ( +export const SkillsSheetRoutineChecks: React.FC = ({ l10n }) => ( - {translate (l10n) ("from")} +3 - 1 - {minus}1 - 13 + {translate (l10n) ("from")} + {1} + {signNeg (-1)} + {13} - +2 - 4 - {minus}2 - 16 + {sign (2)} + {4} + {sign (-2)} + {16} - +1 - 7 - {minus}3 - 19 + {sign (1)} + {7} + {sign (-3)} + {19} - +/{minus}0 - 10 - - + {`+/${minus}0`} + {10} + + diff --git a/src/App/Views/Sheets/SkillsSheet/SkillsSheetScripts.tsx b/src/App/Views/Sheets/SkillsSheet/SkillsSheetScripts.tsx index 3cd55132..355ee913 100644 --- a/src/App/Views/Sheets/SkillsSheet/SkillsSheetScripts.tsx +++ b/src/App/Views/Sheets/SkillsSheet/SkillsSheetScripts.tsx @@ -14,13 +14,13 @@ import { pipe_ } from "../../../Utilities/pipe"; import { sortStrings } from "../../../Utilities/sortBy"; import { TextBox } from "../../Universal/TextBox"; -export interface SkillsSheetScriptsProps { +interface Props { l10n: L10nRecord scriptsStateEntry: Maybe> scriptsWikiEntry: Maybe> } -export function SkillsSheetScripts (props: SkillsSheetScriptsProps) { +export const SkillsSheetScripts: React.FC = props => { const { l10n, scriptsStateEntry: maybeScriptsStateEntry, diff --git a/src/App/Views/Sheets/SkillsSheet/SkillsSheetSkills.tsx b/src/App/Views/Sheets/SkillsSheet/SkillsSheetSkills.tsx index 52f9de00..ea0824c5 100644 --- a/src/App/Views/Sheets/SkillsSheet/SkillsSheetSkills.tsx +++ b/src/App/Views/Sheets/SkillsSheet/SkillsSheetSkills.tsx @@ -13,7 +13,7 @@ import { TextBox } from "../../Universal/TextBox"; import { iterateGroupHeaders } from "./SkillsSheetSkillsGroups"; import { iterateList } from "./SkillsSheetSkillsIterate"; -export interface SkillsSheetSkillsProps { +interface Props { attributes: List> checkAttributeValueVisibility: boolean l10n: L10nRecord @@ -23,17 +23,17 @@ export interface SkillsSheetSkillsProps { const EmptyRow = () => ( - - - - - - - + + + + + + + ) -export function SkillsSheetSkills (props: SkillsSheetSkillsProps) { +export const SkillsSheetSkills: React.FC = props => { const { attributes, checkAttributeValueVisibility, l10n, skillsByGroup, skillGroupPages } = props const groupHeaders = iterateGroupHeaders (l10n) diff --git a/src/App/Views/Sheets/SpellsSheet/SpellsSheet.tsx b/src/App/Views/Sheets/SpellsSheet/SpellsSheet.tsx index fb7047ef..aad3311d 100644 --- a/src/App/Views/Sheets/SpellsSheet/SpellsSheet.tsx +++ b/src/App/Views/Sheets/SpellsSheet/SpellsSheet.tsx @@ -40,9 +40,16 @@ export interface SpellsSheetProps { export function SpellsSheet (props: SpellsSheetProps) { const { + attributes, + cantrips, checkAttributeValueVisibility, derivedCharacteristics, l10n, + magicalPrimary, + magicalSpecialAbilities, + magicalTradition, + properties, + spells, switchAttributeValueVisibility, } = props @@ -74,17 +81,37 @@ export function SpellsSheet (props: SpellsSheetProps) {
    - - - - - + + + + +
    diff --git a/src/App/Views/Sheets/SpellsSheet/SpellsSheetCantrips.tsx b/src/App/Views/Sheets/SpellsSheet/SpellsSheetCantrips.tsx index ce7b47af..a83628ef 100644 --- a/src/App/Views/Sheets/SpellsSheet/SpellsSheetCantrips.tsx +++ b/src/App/Views/Sheets/SpellsSheet/SpellsSheetCantrips.tsx @@ -10,12 +10,12 @@ import { pipe, pipe_ } from "../../../Utilities/pipe"; import { sortStrings } from "../../../Utilities/sortBy"; import { TextBox } from "../../Universal/TextBox"; -export interface SpellsSheetCantripsProps { +interface Props { cantrips: Maybe>> l10n: L10nRecord } -export function SpellsSheetCantrips (props: SpellsSheetCantripsProps) { +export const SpellsSheetCantrips: React.FC = props => { const { cantrips, l10n } = props return ( diff --git a/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpecialAbilities.tsx b/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpecialAbilities.tsx index 0fee7c83..259662e9 100644 --- a/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpecialAbilities.tsx +++ b/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpecialAbilities.tsx @@ -9,12 +9,12 @@ import { compressList } from "../../../Utilities/Activatable/activatableNameUtil import { translate } from "../../../Utilities/I18n"; import { TextBox } from "../../Universal/TextBox"; -export interface SpellsSheetSpecialAbilitiesProps { +interface Props { l10n: L10nRecord magicalSpecialAbilities: Maybe>>> } -export function SpellsSheetSpecialAbilities (props: SpellsSheetSpecialAbilitiesProps) { +export const SpellsSheetSpecialAbilities: React.FC = props => { const { l10n, magicalSpecialAbilities: maybeMagicalSpecialAbilities } = props return ( diff --git a/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpells.tsx b/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpells.tsx index cc0e4d55..1872c2e1 100644 --- a/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpells.tsx +++ b/src/App/Views/Sheets/SpellsSheet/SpellsSheetSpells.tsx @@ -18,7 +18,7 @@ import { getAttributeStringByIdList } from "../../../Utilities/sheetUtils"; import { getCheckModStr } from "../../InlineWiki/Elements/WikiSkillCheck"; import { TextBox } from "../../Universal/TextBox"; -export interface SpellsSheetSpellsProps { +interface Props { attributes: List> checkAttributeValueVisibility: boolean l10n: L10nRecord @@ -27,7 +27,7 @@ export interface SpellsSheetSpellsProps { const SWRA_ = SpellWithRequirementsA_ -export function SpellsSheetSpells (props: SpellsSheetSpellsProps) { +export const SpellsSheetSpells: React.FC = props => { const { attributes, checkAttributeValueVisibility, @@ -145,8 +145,8 @@ export function SpellsSheetSpells (props: SpellsSheetSpellsProps) { {getICName (SWRA_.ic (e))} - - + + ) }), @@ -157,17 +157,17 @@ export function SpellsSheetSpells (props: SpellsSheetSpellsProps) { {replicateR (21 - Maybe.sum (fmapF (maybeSpells) (flength))) (i => ( - - - - - - - - - - - + + + + + + + + + + + ))} diff --git a/src/App/Views/Sheets/SpellsSheet/SpellsSheetTraditionsProperties.tsx b/src/App/Views/Sheets/SpellsSheet/SpellsSheetTraditionsProperties.tsx index aa0c359a..e52ad16f 100644 --- a/src/App/Views/Sheets/SpellsSheet/SpellsSheetTraditionsProperties.tsx +++ b/src/App/Views/Sheets/SpellsSheet/SpellsSheetTraditionsProperties.tsx @@ -5,14 +5,14 @@ import { L10nRecord } from "../../../Models/Wiki/L10n"; import { translate } from "../../../Utilities/I18n"; import { renderMaybe } from "../../../Utilities/ReactUtils"; -export interface SpellsSheetTraditionsPropertiesProps { +interface Props { l10n: L10nRecord magicalPrimary: List magicalTradition: string properties: Maybe } -export function SpellsSheetTraditionsProperties (props: SpellsSheetTraditionsPropertiesProps) { +export const SpellsSheetTraditionsProperties: React.FC = props => { const { magicalPrimary, magicalTradition, properties, l10n } = props return ( diff --git a/src/App/Views/Skills/CombatTechniquesListItem.tsx b/src/App/Views/Skills/CombatTechniquesListItem.tsx deleted file mode 100644 index e251e26e..00000000 --- a/src/App/Views/Skills/CombatTechniquesListItem.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import * as React from "react"; -import { equals } from "../../../Data/Eq"; -import { fmapF } from "../../../Data/Functor"; -import { find, flength, intercalate, List } from "../../../Data/List"; -import { fromMaybe, listToMaybe, mapMaybe, Maybe } from "../../../Data/Maybe"; -import { Record } from "../../../Data/Record"; -import { AttributeCombined, AttributeCombinedA_ } from "../../Models/View/AttributeCombined"; -import { CombatTechniqueWithRequirements, CombatTechniqueWithRequirementsA_ } from "../../Models/View/CombatTechniqueWithRequirements"; -import { L10nRecord } from "../../Models/Wiki/L10n"; -import { ndash } from "../../Utilities/Chars"; -import { translate } from "../../Utilities/I18n"; -import { pipe, pipe_ } from "../../Utilities/pipe"; -import { SkillListItem } from "../Skills/SkillListItem"; - -const ACA_ = AttributeCombinedA_ -const CTWRA = CombatTechniqueWithRequirements.A -const CTWRA_ = CombatTechniqueWithRequirementsA_ - -export interface CombatTechniqueListItemProps { - l10n: L10nRecord - attributes: List> - combatTechnique: Record - currentInfoId: Maybe - isRemovingEnabled: boolean - addPoint: (id: string) => void - removePoint: (id: string) => void - selectForInfo: (id: string) => void -} - -export const CombatTechniqueListItem: React.FC = props => { - const { - attributes, - currentInfoId, - isRemovingEnabled, - l10n, - combatTechnique: ct, - selectForInfo, - addPoint, - removePoint, - } = props - - const primary = - pipe_ ( - CTWRA_.primary (ct), - mapMaybe ((id: string) => fmapF (find (pipe (ACA_.id, equals (id))) - (attributes)) - (ACA_.short)), - intercalate ("/") - ) - - const customClassName = - flength (CTWRA_.primary (ct)) > 1 - ? "ATTR_6_8" - : fromMaybe ("") (listToMaybe (CTWRA_.primary (ct))) - - const primaryClassName = `primary ${customClassName}` - - return ( - = CTWRA.max (ct)} - removePoint={removePoint} - removeDisabled={!isRemovingEnabled || CTWRA_.value (ct) <= CTWRA.min (ct)} - addValues={List ( - { className: primaryClassName, value: primary }, - { className: "at", value: CTWRA.at (ct) }, - { className: "atpa" }, - { - className: "pa", - value: fromMaybe (ndash) (CTWRA.pa (ct)), - } - )} - attributes={attributes} - l10n={l10n} - selectForInfo={selectForInfo} - groupIndex={CTWRA_.gr (ct)} - groupList={translate (l10n) ("combattechniquegroups")} - selectedForInfo={currentInfoId} - /> - ) -} diff --git a/src/App/Views/Skills/SkillAdditionalValues.tsx b/src/App/Views/Skills/SkillAdditionalValues.tsx index 6a592b79..7a11365d 100644 --- a/src/App/Views/Skills/SkillAdditionalValues.tsx +++ b/src/App/Views/Skills/SkillAdditionalValues.tsx @@ -7,11 +7,11 @@ export interface AdditionalValue { value?: string | number } -export interface SkillAdditionalValuesProps { +interface Props { addValues?: List } -export function SkillAdditionalValues (props: SkillAdditionalValuesProps) { +export const SkillAdditionalValues: React.FC = props => { const { addValues } = props if (typeof addValues === "object") { diff --git a/src/App/Views/Skills/SkillButtons.tsx b/src/App/Views/Skills/SkillButtons.tsx index 1c7cf5a1..a4f04381 100644 --- a/src/App/Views/Skills/SkillButtons.tsx +++ b/src/App/Views/Skills/SkillButtons.tsx @@ -4,7 +4,7 @@ import { isNumber } from "../../Utilities/typeCheckUtils"; import { IconButton } from "../Universal/IconButton"; import { ListItemButtons } from "../Universal/ListItemButtons"; -export interface SkillButtonsProps { +interface Props { activateDisabled?: boolean addDisabled?: boolean ic?: number @@ -18,7 +18,7 @@ export interface SkillButtonsProps { selectForInfo (id: string): void } -export const SkillButtons: React.FC = props => { +export const SkillButtons: React.FC = props => { const { activateDisabled, addDisabled, @@ -36,7 +36,7 @@ export const SkillButtons: React.FC = props => { const boundSelectForInfo = React.useCallback ( () => selectForInfo (id), - [selectForInfo, id] + [ selectForInfo, id ] ) const getRemoveIcon = @@ -49,7 +49,7 @@ export const SkillButtons: React.FC = props => { () => typeof activate === "function" ? activate (id) : undefined, - [activate, id] + [ activate, id ] ) const handleAddPoint = @@ -57,7 +57,7 @@ export const SkillButtons: React.FC = props => { () => addDisabled !== true && typeof addPoint === "function" ? addPoint (id) : undefined, - [addPoint, id, addDisabled] + [ addPoint, id, addDisabled ] ) const handleRemovePoint = @@ -65,7 +65,7 @@ export const SkillButtons: React.FC = props => { () => removeDisabled !== true && typeof removePoint === "function" ? removePoint (id) : undefined, - [removePoint, id, removeDisabled] + [ removePoint, id, removeDisabled ] ) return ( diff --git a/src/App/Views/Skills/SkillCheck.tsx b/src/App/Views/Skills/SkillCheck.tsx index 11a984e0..aafad724 100644 --- a/src/App/Views/Skills/SkillCheck.tsx +++ b/src/App/Views/Skills/SkillCheck.tsx @@ -13,7 +13,7 @@ import { minus } from "../../Utilities/Chars"; import { pipe, pipe_ } from "../../Utilities/pipe"; import { getCheckModStr } from "../InlineWiki/Elements/WikiSkillCheck"; -export interface SkillCheckProps { +interface Props { attributes: List> check?: List checkDisabled?: boolean @@ -21,7 +21,7 @@ export interface SkillCheckProps { l10n: L10nRecord } -export function SkillCheck (props: SkillCheckProps) { +export const SkillCheck: React.FC = props => { const { attributes, check, diff --git a/src/App/Views/Skills/SkillFill.tsx b/src/App/Views/Skills/SkillFill.tsx index e0d02cb5..58605dfa 100644 --- a/src/App/Views/Skills/SkillFill.tsx +++ b/src/App/Views/Skills/SkillFill.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { orN } from "../../../Data/Maybe"; -export interface SkillFillProps { +interface Props { addFillElement?: boolean } -export function SkillFill (props: SkillFillProps) { +export const SkillFill: React.FC = props => { const { addFillElement } = props return orN (addFillElement) ?
    : null diff --git a/src/App/Views/Skills/SkillGroup.tsx b/src/App/Views/Skills/SkillGroup.tsx index a5688e74..237a18f2 100644 --- a/src/App/Views/Skills/SkillGroup.tsx +++ b/src/App/Views/Skills/SkillGroup.tsx @@ -2,13 +2,13 @@ import * as React from "react"; import { List } from "../../../Data/List"; import { ListItemGroup } from "../Universal/ListItemGroup"; -export interface SkillListItemProps { +interface Props { addText?: string groupList?: List groupIndex?: number } -export const SkillGroup: React.FC = props => { +export const SkillGroup: React.FC = props => { const { addText, groupIndex, diff --git a/src/App/Views/Skills/SkillImprovementCost.tsx b/src/App/Views/Skills/SkillImprovementCost.tsx index 5bc34422..d90927ea 100644 --- a/src/App/Views/Skills/SkillImprovementCost.tsx +++ b/src/App/Views/Skills/SkillImprovementCost.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { getICName } from "../../Utilities/AdventurePoints/improvementCostUtils"; -export interface SkillImprovementCostProps { +interface Props { ic?: number } -export function SkillImprovementCost (props: SkillImprovementCostProps) { +export const SkillImprovementCost: React.FC = props => { const { ic } = props if (typeof ic === "number") { diff --git a/src/App/Views/Skills/SkillListItem.tsx b/src/App/Views/Skills/SkillListItem.tsx index a66c9f29..a0651262 100644 --- a/src/App/Views/Skills/SkillListItem.tsx +++ b/src/App/Views/Skills/SkillListItem.tsx @@ -18,7 +18,7 @@ import { SkillGroup } from "./SkillGroup"; import { SkillImprovementCost } from "./SkillImprovementCost"; import { SkillRating } from "./SkillRating"; -export interface SkillListItemProps { +interface Props { attributes: List> activateDisabled?: boolean addDisabled?: boolean @@ -48,119 +48,107 @@ export interface SkillListItemProps { selectForInfo (id: string): void } -export class SkillListItem extends React.Component { - shouldComponentUpdate (nextProps: SkillListItemProps) { - const { - sr, - addText, - activateDisabled, - addDisabled, - removeDisabled, - attributes, - l10n, - insertTopMargin, - typ, - untyp, - selectedForInfo, - } = this.props +const SkillListItem: React.FC = props => { + const { + attributes, + activateDisabled, + addDisabled, + addFillElement, + addValues, + addText, + check, + checkDisabled, + checkmod, + groupList, + groupIndex, + ic, + id, + insertTopMargin, + isNotActive, + name, + noIncrease, + removeDisabled, + sr, + typ, + untyp, + selectedForInfo, + l10n, + activate, + addPoint, + removePoint, + selectForInfo, + } = props - return sr !== nextProps.sr - || addText !== nextProps.addText - || activateDisabled !== nextProps.activateDisabled - || addDisabled !== nextProps.addDisabled - || removeDisabled !== nextProps.removeDisabled - || attributes !== nextProps.attributes - || l10n !== nextProps.l10n - || insertTopMargin !== nextProps.insertTopMargin - || typ !== nextProps.typ - || untyp !== nextProps.untyp - || !INTERNAL_shallowEquals (selectedForInfo) (nextProps.selectedForInfo) - } - - render () { - const { - attributes, - activateDisabled, - addDisabled, - addFillElement, - addValues, - addText, - check, - checkDisabled, - checkmod, - groupList, - groupIndex, - ic, - id, - insertTopMargin, - isNotActive, - name, - noIncrease, - removeDisabled, - sr, - typ, - untyp, - selectedForInfo, - l10n, - activate, - addPoint, - removePoint, - selectForInfo, - } = this.props - - return ( - - - - - - - - - - - - + + + + + - - ) - } + + + + + + + + ) } + +const MemoSkillListItem = React.memo ( + SkillListItem, + (prevProps, nextProps) => + prevProps.sr !== nextProps.sr + || prevProps.addText !== nextProps.addText + || prevProps.activateDisabled !== nextProps.activateDisabled + || prevProps.addDisabled !== nextProps.addDisabled + || prevProps.removeDisabled !== nextProps.removeDisabled + || prevProps.attributes !== nextProps.attributes + || prevProps.l10n !== nextProps.l10n + || prevProps.insertTopMargin !== nextProps.insertTopMargin + || prevProps.typ !== nextProps.typ + || prevProps.untyp !== nextProps.untyp + || !INTERNAL_shallowEquals (prevProps.selectedForInfo) (nextProps.selectedForInfo) +) + +export { MemoSkillListItem as SkillListItem }; diff --git a/src/App/Views/Skills/SkillRating.tsx b/src/App/Views/Skills/SkillRating.tsx index 22730e48..7c4a04f4 100644 --- a/src/App/Views/Skills/SkillRating.tsx +++ b/src/App/Views/Skills/SkillRating.tsx @@ -1,13 +1,13 @@ import * as React from "react"; -export interface SkillRatingProps { +interface Props { isNotActive?: boolean noIncrease?: boolean sr?: number addPoint? (id: string): void } -export function SkillRating (props: SkillRatingProps) { +export const SkillRating: React.FC = props => { const { isNotActive, noIncrease, diff --git a/src/App/Views/Skills/Skills.tsx b/src/App/Views/Skills/Skills.tsx index 86d537e5..a4aa7be9 100644 --- a/src/App/Views/Skills/Skills.tsx +++ b/src/App/Views/Skills/Skills.tsx @@ -52,7 +52,7 @@ export interface SkillsDispatchProps { removePoint (id: string): void } -export type SkillsProps = SkillsStateProps & SkillsDispatchProps & SkillsOwnProps +type Props = SkillsStateProps & SkillsDispatchProps & SkillsOwnProps export interface SkillsState { infoId: Maybe @@ -62,7 +62,7 @@ type Element = Record const SWRA = SkillWithRequirements.A const SWRA_ = SkillWithRequirementsA_ -export const Skills: React.FC = props => { +export const Skills: React.FC = props => { const [ infoId, setInfoId ] = React.useState> (Nothing) const showInfo = React.useCallback ( diff --git a/src/App/Views/SpecialAbilities/SpecialAbilities.tsx b/src/App/Views/SpecialAbilities/SpecialAbilities.tsx index 04fb02b4..b044ab42 100644 --- a/src/App/Views/SpecialAbilities/SpecialAbilities.tsx +++ b/src/App/Views/SpecialAbilities/SpecialAbilities.tsx @@ -54,18 +54,9 @@ export interface SpecialAbilitiesDispatchProps { setInactiveFilterText (filterText: string): void } -export type SpecialAbilitiesProps = - SpecialAbilitiesStateProps - & SpecialAbilitiesDispatchProps - & SpecialAbilitiesOwnProps +type Props = SpecialAbilitiesStateProps & SpecialAbilitiesDispatchProps & SpecialAbilitiesOwnProps -export interface SpecialAbilitiesState { - showAddSlidein: boolean - currentId: Maybe - currentSlideinId: Maybe -} - -export const SpecialAbilities: React.FC = props => { +export const SpecialAbilities: React.FC = props => { const { activeList, addToList, diff --git a/src/App/Views/Spells/Spells.tsx b/src/App/Views/Spells/Spells.tsx index 4f67c8ef..4c241533 100644 --- a/src/App/Views/Spells/Spells.tsx +++ b/src/App/Views/Spells/Spells.tsx @@ -68,13 +68,7 @@ export interface SpellsDispatchProps { setInactiveFilterText (filterText: string): void } -export type SpellsProps = SpellsStateProps & SpellsDispatchProps & SpellsOwnProps - -export interface SpellsState { - showAddSlidein: boolean - currentId: Maybe - currentSlideinId: Maybe -} +type Props = SpellsStateProps & SpellsDispatchProps & SpellsOwnProps const SWRA = SpellWithRequirements.A const SWRAL = SpellWithRequirements.AL @@ -120,7 +114,7 @@ const SCCA = { const isCantrip = CantripCombined.is -export const Spells: React.FC = props => { +export const Spells: React.FC = props => { const { addSpellsDisabled, addPoint, diff --git a/src/App/Views/Universal/Activate.tsx b/src/App/Views/Universal/Activate.tsx index d9903c3e..549d6f70 100644 --- a/src/App/Views/Universal/Activate.tsx +++ b/src/App/Views/Universal/Activate.tsx @@ -3,31 +3,33 @@ import { List } from "../../../Data/List"; import { guardReplace, Maybe, normalize, orN } from "../../../Data/Maybe"; import { classListMaybe } from "../../Utilities/CSS"; -export interface ActivateProps { - active: boolean; - children?: React.ReactNode; - className?: string; - disabled?: boolean; - value?: Maybe | string | number; - onClick (value: Maybe): void; +interface Props { + active: boolean + children?: React.ReactNode + className?: string + disabled?: boolean + value?: Maybe | string | number + onClick (value: Maybe): void } -export function Activate (props: ActivateProps) { - const { active, className, disabled, onClick, value, ...other } = props; +export const Activate: React.FC = props => { + const { active, className, disabled, onClick, value, children } = props - const normalizedValue = normalize (value); - - const onClickEval = orN (disabled) ? undefined : () => onClick (normalizedValue); + const onClickEval = React.useCallback ( + () => orN (disabled) ? undefined : onClick (normalize (value)), + [ disabled, onClick, value ] + ) return (
    - ); + > + {children} +
    + ) } diff --git a/src/App/Views/Universal/Alert.tsx b/src/App/Views/Universal/Alert.tsx index 5ff341f2..ff0dfe0d 100644 --- a/src/App/Views/Universal/Alert.tsx +++ b/src/App/Views/Universal/Alert.tsx @@ -4,18 +4,17 @@ import { fromJust, isJust, Just, listToMaybe, Maybe, maybeToUndefined, Nothing } import { Record } from "../../../Data/Record"; import { PromptButton, PromptOptions } from "../../Actions/AlertActions"; import { addKeybinding, removeKeybinding } from "../../Utilities/Keybindings"; -import { BorderButtonProps } from "./BorderButton"; import { Dialog } from "./Dialog"; const POA = PromptOptions.A const PBA = PromptButton.A -export interface AlertProps { +interface Props { options: Maybe>> close (): void } -export const Alert: React.FC = props => { +export const Alert: React.FC = props => { const { close, options: moptions } = props if (!Maybe.isJust (moptions)) { @@ -29,17 +28,8 @@ export const Alert: React.FC = props => { const buttons = POA.buttons (options) const resolve = POA.resolve (options) - // const { - // buttons: buttonsOption = [{ label: "OK", autoWidth: true }], - // message, - // title, - // confirm, - // confirmYesNo, - // onClose, - // } = options - const buttonOptions = - map ((x: Record>): BorderButtonProps => ({ + map ((x: Record>) => ({ autoWidth: flength (buttons) === 1, label: PBA.label (x), onClick: () => resolve (Just (PBA.response (x))), diff --git a/src/App/Views/Universal/Aside.tsx b/src/App/Views/Universal/Aside.tsx index 515bb24b..d7658e64 100644 --- a/src/App/Views/Universal/Aside.tsx +++ b/src/App/Views/Universal/Aside.tsx @@ -1,7 +1,7 @@ -import * as React from "react"; +import * as React from "react" -export function Aside (props?: object) { - return ( -