@arbor-education/design-system.components 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gather/skills/write-stories/SKILL.md +207 -271
- package/.storybook/preview.ts +5 -0
- package/CHANGELOG.md +27 -0
- package/README.md +8 -0
- package/component-library.md +144 -13
- package/dist/components/articleCard/ArticleCard.stories.d.ts +137 -11
- package/dist/components/articleCard/ArticleCard.stories.d.ts.map +1 -1
- package/dist/components/articleCard/ArticleCard.stories.js +358 -91
- package/dist/components/articleCard/ArticleCard.stories.js.map +1 -1
- package/dist/components/avatar/Avatar.stories.d.ts +6 -6
- package/dist/components/avatar/Avatar.stories.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.stories.js +393 -49
- package/dist/components/avatar/Avatar.stories.js.map +1 -1
- package/dist/components/avatarGroup/AvatarGroup.stories.d.ts +9 -7
- package/dist/components/avatarGroup/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/components/avatarGroup/AvatarGroup.stories.js +688 -65
- package/dist/components/avatarGroup/AvatarGroup.stories.js.map +1 -1
- package/dist/components/banner/Banner.stories.d.ts.map +1 -1
- package/dist/components/banner/Banner.stories.js +7 -3
- package/dist/components/banner/Banner.stories.js.map +1 -1
- package/dist/components/card/Card.stories.d.ts +105 -4
- package/dist/components/card/Card.stories.d.ts.map +1 -1
- package/dist/components/card/Card.stories.js +336 -18
- package/dist/components/card/Card.stories.js.map +1 -1
- package/dist/components/combobox/Combobox.stories.d.ts +134 -21
- package/dist/components/combobox/Combobox.stories.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.stories.js +676 -175
- package/dist/components/combobox/Combobox.stories.js.map +1 -1
- package/dist/components/datePicker/DatePicker.stories.d.ts +119 -27
- package/dist/components/datePicker/DatePicker.stories.d.ts.map +1 -1
- package/dist/components/datePicker/DatePicker.stories.js +575 -47
- package/dist/components/datePicker/DatePicker.stories.js.map +1 -1
- package/dist/components/dateTimePicker/DateTimePicker.stories.d.ts +155 -39
- package/dist/components/dateTimePicker/DateTimePicker.stories.d.ts.map +1 -1
- package/dist/components/dateTimePicker/DateTimePicker.stories.js +674 -103
- package/dist/components/dateTimePicker/DateTimePicker.stories.js.map +1 -1
- package/dist/components/editableText/EditableText.stories.d.ts +53 -12
- package/dist/components/editableText/EditableText.stories.d.ts.map +1 -1
- package/dist/components/editableText/EditableText.stories.js +401 -64
- package/dist/components/editableText/EditableText.stories.js.map +1 -1
- package/dist/components/formField/FormField.d.ts +4 -0
- package/dist/components/formField/FormField.d.ts.map +1 -1
- package/dist/components/formField/FormField.js +2 -1
- package/dist/components/formField/FormField.js.map +1 -1
- package/dist/components/formField/FormField.test.js +5 -0
- package/dist/components/formField/FormField.test.js.map +1 -1
- package/dist/components/formField/fieldset/Fieldset.stories.d.ts +56 -4
- package/dist/components/formField/fieldset/Fieldset.stories.d.ts.map +1 -1
- package/dist/components/formField/fieldset/Fieldset.stories.js +534 -28
- package/dist/components/formField/fieldset/Fieldset.stories.js.map +1 -1
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.d.ts +3 -1
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/formField/inputs/checkbox/CheckboxInput.js +1 -1
- package/dist/components/formField/inputs/checkbox/CheckboxInput.js.map +1 -1
- package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.d.ts +95 -1
- package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.js +386 -9
- package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.js.map +1 -1
- package/dist/components/formField/inputs/number/NumberInput.d.ts.map +1 -1
- package/dist/components/formField/inputs/number/NumberInput.js +14 -2
- package/dist/components/formField/inputs/number/NumberInput.js.map +1 -1
- package/dist/components/formField/inputs/number/NumberInput.test.js +21 -0
- package/dist/components/formField/inputs/number/NumberInput.test.js.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonGroup.d.ts +6 -2
- package/dist/components/formField/inputs/radio/RadioButtonGroup.d.ts.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonGroup.js.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.js +61 -49
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.js.map +1 -1
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.stories.d.ts +188 -166
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.stories.js +821 -160
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.stories.js.map +1 -1
- package/dist/components/formField/inputs/time/TimeInput.stories.d.ts +176 -22
- package/dist/components/formField/inputs/time/TimeInput.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/time/TimeInput.stories.js +851 -92
- package/dist/components/formField/inputs/time/TimeInput.stories.js.map +1 -1
- package/dist/components/formField/label/Label.stories.d.ts +54 -5
- package/dist/components/formField/label/Label.stories.d.ts.map +1 -1
- package/dist/components/formField/label/Label.stories.js +238 -4
- package/dist/components/formField/label/Label.stories.js.map +1 -1
- package/dist/components/icoText/IcoText.stories.d.ts +32 -6
- package/dist/components/icoText/IcoText.stories.d.ts.map +1 -1
- package/dist/components/icoText/IcoText.stories.js +309 -14
- package/dist/components/icoText/IcoText.stories.js.map +1 -1
- package/dist/components/kpiCard/KPICard.stories.d.ts +100 -2
- package/dist/components/kpiCard/KPICard.stories.d.ts.map +1 -1
- package/dist/components/kpiCard/KPICard.stories.js +354 -10
- package/dist/components/kpiCard/KPICard.stories.js.map +1 -1
- package/dist/components/kvpList/KVPList.stories.d.ts +57 -4
- package/dist/components/kvpList/KVPList.stories.d.ts.map +1 -1
- package/dist/components/kvpList/KVPList.stories.js +403 -10
- package/dist/components/kvpList/KVPList.stories.js.map +1 -1
- package/dist/components/modal/Modal.stories.d.ts +113 -9
- package/dist/components/modal/Modal.stories.d.ts.map +1 -1
- package/dist/components/modal/Modal.stories.js +633 -13
- package/dist/components/modal/Modal.stories.js.map +1 -1
- package/dist/components/modal/modalManager/ModalManager.stories.d.ts +34 -10
- package/dist/components/modal/modalManager/ModalManager.stories.d.ts.map +1 -1
- package/dist/components/modal/modalManager/ModalManager.stories.js +463 -85
- package/dist/components/modal/modalManager/ModalManager.stories.js.map +1 -1
- package/dist/components/pill/Pill.d.ts.map +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/pill/Pill.js.map +1 -1
- package/dist/components/pill/Pill.stories.d.ts.map +1 -1
- package/dist/components/pill/Pill.stories.js +11 -13
- package/dist/components/pill/Pill.stories.js.map +1 -1
- package/dist/components/row/Row.stories.d.ts +1 -2
- package/dist/components/row/Row.stories.d.ts.map +1 -1
- package/dist/components/row/Row.stories.js +360 -50
- package/dist/components/row/Row.stories.js.map +1 -1
- package/dist/components/searchBar/SearchBar.stories.d.ts +52 -4
- package/dist/components/searchBar/SearchBar.stories.d.ts.map +1 -1
- package/dist/components/searchBar/SearchBar.stories.js +428 -36
- package/dist/components/searchBar/SearchBar.stories.js.map +1 -1
- package/dist/components/section/Section.stories.d.ts +11 -41
- package/dist/components/section/Section.stories.d.ts.map +1 -1
- package/dist/components/section/Section.stories.js +494 -56
- package/dist/components/section/Section.stories.js.map +1 -1
- package/dist/components/singleUser/SingleUser.stories.d.ts +5 -4
- package/dist/components/singleUser/SingleUser.stories.d.ts.map +1 -1
- package/dist/components/singleUser/SingleUser.stories.js +303 -31
- package/dist/components/singleUser/SingleUser.stories.js.map +1 -1
- package/dist/components/slideoverManager/SlideoverManager.stories.d.ts +32 -11
- package/dist/components/slideoverManager/SlideoverManager.stories.d.ts.map +1 -1
- package/dist/components/slideoverManager/SlideoverManager.stories.js +380 -84
- package/dist/components/slideoverManager/SlideoverManager.stories.js.map +1 -1
- package/dist/components/table/DSDefaultColDef.d.ts.map +1 -1
- package/dist/components/table/DSDefaultColDef.js +4 -3
- package/dist/components/table/DSDefaultColDef.js.map +1 -1
- package/dist/components/table/Table.d.ts +7 -1
- package/dist/components/table/Table.d.ts.map +1 -1
- package/dist/components/table/Table.js +12 -5
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/table/Table.stories.d.ts +3 -0
- package/dist/components/table/Table.stories.d.ts.map +1 -1
- package/dist/components/table/Table.stories.js +445 -3
- package/dist/components/table/Table.stories.js.map +1 -1
- package/dist/components/table/Table.test.js +184 -0
- package/dist/components/table/Table.test.js.map +1 -1
- package/dist/components/table/TableFooter.stories.d.ts +49 -0
- package/dist/components/table/TableFooter.stories.d.ts.map +1 -0
- package/dist/components/table/TableFooter.stories.js +137 -0
- package/dist/components/table/TableFooter.stories.js.map +1 -0
- package/dist/components/table/TableHeader.stories.d.ts +93 -0
- package/dist/components/table/TableHeader.stories.d.ts.map +1 -0
- package/dist/components/table/TableHeader.stories.js +176 -0
- package/dist/components/table/TableHeader.stories.js.map +1 -0
- package/dist/components/table/cellEditors/DateCellEditor.stories.d.ts +44 -0
- package/dist/components/table/cellEditors/DateCellEditor.stories.d.ts.map +1 -0
- package/dist/components/table/cellEditors/DateCellEditor.stories.js +186 -0
- package/dist/components/table/cellEditors/DateCellEditor.stories.js.map +1 -0
- package/dist/components/table/cellEditors/NumberCellEditor.d.ts +13 -0
- package/dist/components/table/cellEditors/NumberCellEditor.d.ts.map +1 -0
- package/dist/components/table/cellEditors/NumberCellEditor.js +35 -0
- package/dist/components/table/cellEditors/NumberCellEditor.js.map +1 -0
- package/dist/components/table/cellRenderers/BooleanCellRenderer.stories.d.ts +40 -0
- package/dist/components/table/cellRenderers/BooleanCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/BooleanCellRenderer.stories.js +209 -0
- package/dist/components/table/cellRenderers/BooleanCellRenderer.stories.js.map +1 -0
- package/dist/components/table/cellRenderers/ButtonCellRenderer.stories.d.ts +48 -0
- package/dist/components/table/cellRenderers/ButtonCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/ButtonCellRenderer.stories.js +244 -0
- package/dist/components/table/cellRenderers/ButtonCellRenderer.stories.js.map +1 -0
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.d.ts.map +1 -1
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.js +3 -1
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.js.map +1 -1
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.stories.d.ts +64 -0
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.stories.js +241 -0
- package/dist/components/table/cellRenderers/CheckboxCellRenderer.stories.js.map +1 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.stories.d.ts +55 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.stories.js +245 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.stories.js.map +1 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.stories.d.ts +67 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.stories.js +221 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.stories.js.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.d.ts +75 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.js +270 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.js.map +1 -0
- package/dist/components/table/columnFilters/BooleanFilter.stories.d.ts +57 -0
- package/dist/components/table/columnFilters/BooleanFilter.stories.d.ts.map +1 -0
- package/dist/components/table/columnFilters/BooleanFilter.stories.js +198 -0
- package/dist/components/table/columnFilters/BooleanFilter.stories.js.map +1 -0
- package/dist/components/table/columnFilters/TimeFilter.stories.d.ts +58 -0
- package/dist/components/table/columnFilters/TimeFilter.stories.d.ts.map +1 -0
- package/dist/components/table/columnFilters/TimeFilter.stories.js +207 -0
- package/dist/components/table/columnFilters/TimeFilter.stories.js.map +1 -0
- package/dist/components/table/pagination/PaginationPanel.stories.d.ts +113 -0
- package/dist/components/table/pagination/PaginationPanel.stories.d.ts.map +1 -0
- package/dist/components/table/pagination/PaginationPanel.stories.js +272 -0
- package/dist/components/table/pagination/PaginationPanel.stories.js.map +1 -0
- package/dist/components/table/tableControls/TableControls.stories.d.ts +151 -0
- package/dist/components/table/tableControls/TableControls.stories.d.ts.map +1 -0
- package/dist/components/table/tableControls/TableControls.stories.js +356 -0
- package/dist/components/table/tableControls/TableControls.stories.js.map +1 -0
- package/dist/components/table/tableControls/TableSettingsDropdown.d.ts +27 -1
- package/dist/components/table/tableControls/TableSettingsDropdown.d.ts.map +1 -1
- package/dist/components/table/tableControls/TableSettingsDropdown.js +53 -26
- package/dist/components/table/tableControls/TableSettingsDropdown.js.map +1 -1
- package/dist/components/table/tableControls/TableSettingsDropdown.test.d.ts +2 -0
- package/dist/components/table/tableControls/TableSettingsDropdown.test.d.ts.map +1 -0
- package/dist/components/table/tableControls/TableSettingsDropdown.test.js +178 -0
- package/dist/components/table/tableControls/TableSettingsDropdown.test.js.map +1 -0
- package/dist/components/tabs/Tabs.stories.d.ts +22 -4
- package/dist/components/tabs/Tabs.stories.d.ts.map +1 -1
- package/dist/components/tabs/Tabs.stories.js +398 -22
- package/dist/components/tabs/Tabs.stories.js.map +1 -1
- package/dist/components/tabs/TabsItem.stories.d.ts +54 -1
- package/dist/components/tabs/TabsItem.stories.d.ts.map +1 -1
- package/dist/components/tabs/TabsItem.stories.js +61 -9
- package/dist/components/tabs/TabsItem.stories.js.map +1 -1
- package/dist/components/toast/Toast.stories.d.ts +103 -10
- package/dist/components/toast/Toast.stories.d.ts.map +1 -1
- package/dist/components/toast/Toast.stories.js +409 -47
- package/dist/components/toast/Toast.stories.js.map +1 -1
- package/dist/components/toggle/Toggle.stories.d.ts +61 -46
- package/dist/components/toggle/Toggle.stories.d.ts.map +1 -1
- package/dist/components/toggle/Toggle.stories.js +311 -122
- package/dist/components/toggle/Toggle.stories.js.map +1 -1
- package/dist/components/tooltip/Tooltip.stories.d.ts +78 -6
- package/dist/components/tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.stories.js +413 -7
- package/dist/components/tooltip/Tooltip.stories.js.map +1 -1
- package/dist/components/tooltip/TooltipWrapper.stories.d.ts +71 -7
- package/dist/components/tooltip/TooltipWrapper.stories.d.ts.map +1 -1
- package/dist/components/tooltip/TooltipWrapper.stories.js +238 -10
- package/dist/components/tooltip/TooltipWrapper.stories.js.map +1 -1
- package/dist/index.css +27 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/PopupParentContext.stories.d.ts +17 -0
- package/dist/utils/PopupParentContext.stories.d.ts.map +1 -0
- package/dist/utils/PopupParentContext.stories.js +266 -0
- package/dist/utils/PopupParentContext.stories.js.map +1 -0
- package/dist/utils/getDefaultPopupParent.d.ts.map +1 -1
- package/dist/utils/getDefaultPopupParent.js +6 -0
- package/dist/utils/getDefaultPopupParent.js.map +1 -1
- package/package.json +1 -1
- package/src/components/articleCard/ArticleCard.stories.tsx +524 -111
- package/src/components/avatar/Avatar.stories.tsx +504 -59
- package/src/components/avatarGroup/AvatarGroup.stories.tsx +977 -175
- package/src/components/banner/Banner.stories.tsx +7 -3
- package/src/components/card/Card.stories.tsx +466 -36
- package/src/components/combobox/Combobox.stories.tsx +867 -260
- package/src/components/datePicker/DatePicker.stories.tsx +777 -60
- package/src/components/dateTimePicker/DateTimePicker.stories.tsx +910 -132
- package/src/components/editableText/EditableText.stories.tsx +567 -91
- package/src/components/formField/FormField.test.tsx +6 -0
- package/src/components/formField/FormField.tsx +5 -0
- package/src/components/formField/fieldset/Fieldset.stories.tsx +761 -51
- package/src/components/formField/inputs/checkbox/CheckboxGroup.tsx +1 -1
- package/src/components/formField/inputs/checkbox/CheckboxInput.tsx +1 -1
- package/src/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.tsx +504 -11
- package/src/components/formField/inputs/number/NumberInput.test.tsx +28 -0
- package/src/components/formField/inputs/number/NumberInput.tsx +15 -0
- package/src/components/formField/inputs/radio/RadioButtonGroup.tsx +17 -4
- package/src/components/formField/inputs/radio/RadioButtonInput.stories.tsx +71 -59
- package/src/components/formField/inputs/selectDropdown/SelectDropdown.stories.tsx +1079 -168
- package/src/components/formField/inputs/time/TimeInput.stories.tsx +1140 -104
- package/src/components/formField/label/Label.stories.tsx +317 -8
- package/src/components/icoText/IcoText.stories.tsx +442 -31
- package/src/components/kpiCard/KPICard.stories.tsx +475 -30
- package/src/components/kvpList/KVPList.stories.tsx +593 -26
- package/src/components/modal/Modal.stories.tsx +963 -26
- package/src/components/modal/modalManager/ModalManager.stories.tsx +612 -454
- package/src/components/pill/Pill.stories.tsx +11 -13
- package/src/components/pill/Pill.tsx +1 -0
- package/src/components/row/Row.stories.tsx +474 -58
- package/src/components/searchBar/SearchBar.stories.tsx +570 -38
- package/src/components/section/Section.stories.tsx +723 -70
- package/src/components/singleUser/SingleUser.stories.tsx +393 -34
- package/src/components/slideoverManager/SlideoverManager.stories.tsx +572 -342
- package/src/components/table/DSDefaultColDef.ts +25 -5
- package/src/components/table/Table.stories.tsx +504 -3
- package/src/components/table/Table.test.tsx +255 -0
- package/src/components/table/Table.tsx +15 -2
- package/src/components/table/TableFooter.stories.tsx +196 -0
- package/src/components/table/TableHeader.stories.tsx +251 -0
- package/src/components/table/cellEditors/DateCellEditor.stories.tsx +245 -0
- package/src/components/table/cellEditors/NumberCellEditor.tsx +83 -0
- package/src/components/table/cellEditors/numberCellEditor.scss +11 -0
- package/src/components/table/cellRenderers/BooleanCellRenderer.stories.tsx +278 -0
- package/src/components/table/cellRenderers/ButtonCellRenderer.stories.tsx +333 -0
- package/src/components/table/cellRenderers/CheckboxCellRenderer.stories.tsx +337 -0
- package/src/components/table/cellRenderers/CheckboxCellRenderer.tsx +5 -1
- package/src/components/table/cellRenderers/DefaultCellRenderer.stories.tsx +342 -0
- package/src/components/table/cellRenderers/InlineTextCellRenderer.stories.tsx +292 -0
- package/src/components/table/cellRenderers/SelectDropdownCellRenderer.stories.tsx +369 -0
- package/src/components/table/columnFilters/BooleanFilter.stories.tsx +268 -0
- package/src/components/table/columnFilters/TimeFilter.stories.tsx +281 -0
- package/src/components/table/pagination/PaginationPanel.stories.tsx +327 -0
- package/src/components/table/table.scss +11 -0
- package/src/components/table/tableControls/TableControls.stories.tsx +415 -0
- package/src/components/table/tableControls/TableSettingsDropdown.test.tsx +207 -0
- package/src/components/table/tableControls/TableSettingsDropdown.tsx +103 -39
- package/src/components/tabs/Tabs.stories.tsx +540 -60
- package/src/components/tabs/TabsItem.stories.tsx +82 -8
- package/src/components/toast/Toast.stories.tsx +539 -77
- package/src/components/toggle/Toggle.stories.tsx +371 -135
- package/src/components/tooltip/Tooltip.stories.tsx +606 -15
- package/src/components/tooltip/TooltipWrapper.stories.tsx +348 -12
- package/src/docs/Contributing.mdx +241 -0
- package/src/docs/UsingComponents.mdx +93 -0
- package/src/docs/Welcome.mdx +68 -0
- package/src/global.scss +7 -0
- package/src/index.scss +1 -0
- package/src/index.ts +3 -2
- package/src/utils/PopupParentContext.stories.tsx +367 -0
- package/src/utils/getDefaultPopupParent.ts +6 -0
- package/.ralph/storybook-upgrade/knowledge.md +0 -308
- package/.ralph/storybook-upgrade/prd.json +0 -777
- package/.ralph/storybook-upgrade/progress.md +0 -342
- package/src/components/table/TableWIP.mdx +0 -3
package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.d.ts
CHANGED
|
@@ -1,10 +1,104 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { ColourPickerDropdown } from './ColourPickerDropdown';
|
|
3
|
+
declare function ColourPickerDropdownDocsPage(): import("react/jsx-runtime").JSX.Element;
|
|
2
4
|
declare const meta: {
|
|
3
5
|
title: string;
|
|
4
6
|
component: ({ value, onChange, hasError, disabled, id, "aria-describedBy": ariaDescribedBy, "aria-invalid": ariaInvalid }: import("./ColourPickerDropdown").ColourPickerDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
tags: string[];
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: string;
|
|
10
|
+
docs: {
|
|
11
|
+
page: typeof ColourPickerDropdownDocsPage;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
argTypes: {
|
|
15
|
+
value: {
|
|
16
|
+
description: string;
|
|
17
|
+
control: {
|
|
18
|
+
type: "color";
|
|
19
|
+
};
|
|
20
|
+
table: {
|
|
21
|
+
type: {
|
|
22
|
+
summary: string;
|
|
23
|
+
};
|
|
24
|
+
defaultValue: {
|
|
25
|
+
summary: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
onChange: {
|
|
30
|
+
description: string;
|
|
31
|
+
action: string;
|
|
32
|
+
control: false;
|
|
33
|
+
table: {
|
|
34
|
+
type: {
|
|
35
|
+
summary: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
hasError: {
|
|
40
|
+
description: string;
|
|
41
|
+
control: "boolean";
|
|
42
|
+
table: {
|
|
43
|
+
type: {
|
|
44
|
+
summary: string;
|
|
45
|
+
};
|
|
46
|
+
defaultValue: {
|
|
47
|
+
summary: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
disabled: {
|
|
52
|
+
description: string;
|
|
53
|
+
control: "boolean";
|
|
54
|
+
table: {
|
|
55
|
+
type: {
|
|
56
|
+
summary: string;
|
|
57
|
+
};
|
|
58
|
+
defaultValue: {
|
|
59
|
+
summary: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
id: {
|
|
64
|
+
description: string;
|
|
65
|
+
control: "text";
|
|
66
|
+
table: {
|
|
67
|
+
type: {
|
|
68
|
+
summary: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
'aria-describedBy': {
|
|
73
|
+
description: string;
|
|
74
|
+
control: "text";
|
|
75
|
+
table: {
|
|
76
|
+
type: {
|
|
77
|
+
summary: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
'aria-invalid': {
|
|
82
|
+
description: string;
|
|
83
|
+
control: "boolean";
|
|
84
|
+
table: {
|
|
85
|
+
type: {
|
|
86
|
+
summary: string;
|
|
87
|
+
};
|
|
88
|
+
defaultValue: {
|
|
89
|
+
summary: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
6
94
|
};
|
|
7
95
|
export default meta;
|
|
8
|
-
type Story = StoryObj<typeof
|
|
96
|
+
type Story = StoryObj<typeof ColourPickerDropdown>;
|
|
9
97
|
export declare const Default: Story;
|
|
98
|
+
export declare const WithCustomValue: Story;
|
|
99
|
+
export declare const Disabled: Story;
|
|
100
|
+
export declare const WithError: Story;
|
|
101
|
+
export declare const Controlled: Story;
|
|
102
|
+
export declare const InFormField: Story;
|
|
103
|
+
export declare const WithFormFieldAndError: Story;
|
|
10
104
|
//# sourceMappingURL=ColourPickerDropdown.stories.d.ts.map
|
package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColourPickerDropdown.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColourPickerDropdown.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAY5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA6G9D,iBAAS,4BAA4B,4CAmBpC;AAMD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFmC,CAAC;AAE9C,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAoEnD,eAAO,MAAM,OAAO,EAAE,KASrB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KA8B7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KA8BtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAwCvB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAqCxB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KA+BzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAgCnC,CAAC"}
|
package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.js
CHANGED
|
@@ -1,24 +1,401 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Controls, Heading as DocHeading, Markdown, Primary as DocPrimary, Stories, Subtitle, Title, } from '@storybook/addon-docs/blocks';
|
|
4
|
+
import { FormField } from '../../../formField/FormField';
|
|
1
5
|
import { ColourPickerDropdown } from './ColourPickerDropdown';
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Docs page content
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
const DESCRIPTION_INTRO = [
|
|
10
|
+
'ColourPickerDropdown is a dropdown-triggered colour picker that lets users select any colour from a',
|
|
11
|
+
'full-spectrum palette, with Hex and RGB input fields for precise entry.',
|
|
12
|
+
'Built on the [`@uiw/react-color` Sketch picker](https://uiwjs.github.io/react-color/), which provides',
|
|
13
|
+
'the colour plane, hue slider, Hex/RGB inputs, and preset swatches.',
|
|
14
|
+
'The dropdown panel renders via a Radix UI portal —',
|
|
15
|
+
'**do not place inside a container with `overflow: hidden`**.',
|
|
16
|
+
'',
|
|
17
|
+
'The trigger renders as a small circular colour swatch inside a dropdown-variant button.',
|
|
18
|
+
'Selection applies immediately — the swatch updates live as the user picks.',
|
|
19
|
+
'The panel closes on click outside or `Escape`.',
|
|
20
|
+
].join('\n');
|
|
21
|
+
const USAGE_GUIDANCE = [
|
|
22
|
+
'### When to use',
|
|
23
|
+
'',
|
|
24
|
+
'- Data-driven formatting where users assign a colour to a record — for example, background colours for conditional formatting bands in a marksheet.',
|
|
25
|
+
'- When users need to match a specific colour exactly by Hex or RGB value.',
|
|
26
|
+
'- When freedom of colour choice is appropriate and available colours are not predefined.',
|
|
27
|
+
'',
|
|
28
|
+
'---',
|
|
29
|
+
'',
|
|
30
|
+
'### When NOT to use',
|
|
31
|
+
'',
|
|
32
|
+
'| Situation | Use instead |',
|
|
33
|
+
'|---|---|',
|
|
34
|
+
'| Status choices ("On track / At risk / Off track") | `SelectDropdown` with named labels — colour alone is not sufficient to communicate status |',
|
|
35
|
+
'| Small fixed set of meaningful colours | `SelectDropdown` with colour swatches as option labels |',
|
|
36
|
+
'| Colour could reduce readability (e.g. text colour without contrast checks) | Constrain choices via `SelectDropdown` with an approved palette |',
|
|
37
|
+
].join('\n');
|
|
38
|
+
const DEVELOPER_NOTES = [
|
|
39
|
+
'### Critical usage patterns',
|
|
40
|
+
'',
|
|
41
|
+
'**`onChange` receives a `ColorResult` object, not a plain hex string.** Read the format you need:',
|
|
42
|
+
'',
|
|
43
|
+
'```tsx',
|
|
44
|
+
"import type { ColorResult } from '@uiw/color-convert';",
|
|
45
|
+
'',
|
|
46
|
+
'<ColourPickerDropdown',
|
|
47
|
+
' value={colour}',
|
|
48
|
+
' onChange={(result: ColorResult) => {',
|
|
49
|
+
" const hex = result.hex; // '#3cad51'",
|
|
50
|
+
' const { r, g, b } = result.rgb; // { r: 60, g: 173, b: 81 }',
|
|
51
|
+
' setColour(hex);',
|
|
52
|
+
' }}',
|
|
53
|
+
'/>',
|
|
54
|
+
'```',
|
|
55
|
+
'',
|
|
56
|
+
'**`id` is dual-purpose** — it sets the `name` on the hidden `<input>` (for native form submission) AND',
|
|
57
|
+
'the `id` on the trigger button (for label association via `htmlFor`).',
|
|
58
|
+
'',
|
|
59
|
+
'**`hasError` is visual-only.** It changes the trigger button\'s border colour but tells screen readers',
|
|
60
|
+
'nothing. Always pair it with `aria-invalid={true}`.',
|
|
61
|
+
'',
|
|
62
|
+
'**No alpha / transparency support** — `disableAlpha` is hardcoded. The picker never shows an opacity slider.',
|
|
63
|
+
'',
|
|
64
|
+
'**Semi-controlled pattern** — the component holds internal state via `useState`, but syncs from the',
|
|
65
|
+
'`value` prop via `useEffect`. Changing `value` externally (e.g. a form reset) will update the picker.',
|
|
66
|
+
'',
|
|
67
|
+
'**`onChange` fires on every picker interaction**, including while sliders are dragged.',
|
|
68
|
+
'If you update server state in `onChange`, consider debouncing.',
|
|
69
|
+
'',
|
|
70
|
+
'**Portal rendering** — the dropdown panel renders via a Radix UI portal outside the trigger\'s DOM subtree.',
|
|
71
|
+
'Do not place inside `overflow: hidden` or `position: relative` containers.',
|
|
72
|
+
'',
|
|
73
|
+
'---',
|
|
74
|
+
'',
|
|
75
|
+
'### Accessibility',
|
|
76
|
+
'',
|
|
77
|
+
'- The trigger button includes a visually-hidden "Toggle colour picker." label for screen readers.',
|
|
78
|
+
'- The swatch inside the trigger includes a visually-hidden "current colour: #hex" label that updates live.',
|
|
79
|
+
'- Always pair `hasError` with `aria-invalid={true}` — one is visual, one is for assistive technology.',
|
|
80
|
+
'- Use `aria-describedBy` pointing to the `id` of a `FormField.Error` element to provide the error message.',
|
|
81
|
+
'- The recommended pattern is `<FormField inputType="colourPicker" inputProps={{...}} />` — this wires `hasError`, `aria-invalid`, and `aria-describedby` automatically.',
|
|
82
|
+
'',
|
|
83
|
+
'---',
|
|
84
|
+
'',
|
|
85
|
+
'### TypeScript types',
|
|
86
|
+
'',
|
|
87
|
+
'```tsx',
|
|
88
|
+
"import type { ColorResult } from '@uiw/color-convert';",
|
|
89
|
+
"import { ColourPickerDropdown } from '@arbor-education/design-system.components';",
|
|
90
|
+
'',
|
|
91
|
+
'// Access colour values in onChange:',
|
|
92
|
+
'onChange={(result: ColorResult) => {',
|
|
93
|
+
" const hex = result.hex; // '#3cad51'",
|
|
94
|
+
' const { r, g, b } = result.rgb; // { r: 60, g: 173, b: 81 }',
|
|
95
|
+
'}}',
|
|
96
|
+
'',
|
|
97
|
+
'// Type your own props using the exported namespace:',
|
|
98
|
+
'function MyField(props: ColourPickerDropdown.Props) { ... }',
|
|
99
|
+
'```',
|
|
100
|
+
].join('\n');
|
|
101
|
+
const RELATED_COMPONENTS = [
|
|
102
|
+
'## Related components',
|
|
103
|
+
'',
|
|
104
|
+
'[FormField](?path=/docs/components-formfield--docs) · [SelectDropdown](?path=/docs/components-formfield-inputs-selectdropdown--docs) · [Combobox](?path=/docs/components-combobox--docs)',
|
|
105
|
+
].join('\n');
|
|
106
|
+
const PROPS_INTRO = 'The preview below is wired to the **Controls** panel — tweak any prop to see the story update in real time.';
|
|
107
|
+
function ColourPickerDropdownDocsPage() {
|
|
108
|
+
return (_jsxs(_Fragment, { children: [_jsx(Title, {}), _jsx(Subtitle, {}), _jsx(Markdown, { children: DESCRIPTION_INTRO }), _jsx(DocHeading, { children: "Interactive example" }), _jsx(Markdown, { children: PROPS_INTRO }), _jsx(DocPrimary, {}), _jsx(Controls, {}), _jsx(DocHeading, { children: "Usage guidance" }), _jsx(Markdown, { children: USAGE_GUIDANCE }), _jsx(DocHeading, { children: "Developer notes" }), _jsx(Markdown, { children: DEVELOPER_NOTES }), _jsx(DocHeading, { children: "Examples" }), _jsx(Stories, { title: "" }), _jsx(Markdown, { children: RELATED_COMPONENTS })] }));
|
|
109
|
+
}
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// Meta
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
2
113
|
const meta = {
|
|
3
114
|
title: 'Components/FormField/Inputs/ColourPickerDropdown',
|
|
4
115
|
component: ColourPickerDropdown,
|
|
5
116
|
tags: ['autodocs'],
|
|
117
|
+
parameters: {
|
|
118
|
+
layout: 'padded',
|
|
119
|
+
docs: {
|
|
120
|
+
page: ColourPickerDropdownDocsPage,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
argTypes: {
|
|
124
|
+
'value': {
|
|
125
|
+
description: [
|
|
126
|
+
'The current colour value as a hex string (e.g. `\'#3cad51\'`).',
|
|
127
|
+
'The component holds internal state but syncs from this prop via `useEffect` —',
|
|
128
|
+
'changing it externally (e.g. a form reset) will update the picker.',
|
|
129
|
+
].join(' '),
|
|
130
|
+
control: { type: 'color' },
|
|
131
|
+
table: {
|
|
132
|
+
type: { summary: 'string' },
|
|
133
|
+
defaultValue: { summary: "'#3cad51'" },
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
'onChange': {
|
|
137
|
+
description: [
|
|
138
|
+
'Callback fired on every colour change (including while sliders are dragged).',
|
|
139
|
+
'Receives a `ColorResult` object — read `.hex`, `.rgb`, or `.hsl` off it.',
|
|
140
|
+
].join(' '),
|
|
141
|
+
action: 'onChange',
|
|
142
|
+
control: false,
|
|
143
|
+
table: {
|
|
144
|
+
type: { summary: '(value: ColorResult) => void' },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
'hasError': {
|
|
148
|
+
description: [
|
|
149
|
+
'Applies error styling (red border) to the trigger button.',
|
|
150
|
+
'Visual only — always pair with `aria-invalid` for screen-reader coverage.',
|
|
151
|
+
].join(' '),
|
|
152
|
+
control: 'boolean',
|
|
153
|
+
table: {
|
|
154
|
+
type: { summary: 'boolean' },
|
|
155
|
+
defaultValue: { summary: 'false' },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
'disabled': {
|
|
159
|
+
description: 'When true, the trigger is non-interactive and visually muted.',
|
|
160
|
+
control: 'boolean',
|
|
161
|
+
table: {
|
|
162
|
+
type: { summary: 'boolean' },
|
|
163
|
+
defaultValue: { summary: 'false' },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
'id': {
|
|
167
|
+
description: [
|
|
168
|
+
'Dual-purpose: sets the `name` on the hidden `<input>` for native form submission AND',
|
|
169
|
+
'the `id` on the trigger button for label association via `htmlFor`.',
|
|
170
|
+
].join(' '),
|
|
171
|
+
control: 'text',
|
|
172
|
+
table: {
|
|
173
|
+
type: { summary: 'string' },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
'aria-describedBy': {
|
|
177
|
+
description: [
|
|
178
|
+
'ID of the element describing this field (e.g. a `FormField.Error`).',
|
|
179
|
+
'Note the capital B — the component maps this to the lowercase `aria-describedby` DOM attribute.',
|
|
180
|
+
].join(' '),
|
|
181
|
+
control: 'text',
|
|
182
|
+
table: {
|
|
183
|
+
type: { summary: 'string' },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
'aria-invalid': {
|
|
187
|
+
description: 'Marks the trigger as invalid for screen readers. Use alongside `hasError` and `aria-describedBy`.',
|
|
188
|
+
control: 'boolean',
|
|
189
|
+
table: {
|
|
190
|
+
type: { summary: 'boolean' },
|
|
191
|
+
defaultValue: { summary: 'false' },
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
6
195
|
};
|
|
7
196
|
export default meta;
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Helper: attach a per-story description to docs
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
const withDescription = (story, description) => ({
|
|
201
|
+
...story,
|
|
202
|
+
parameters: {
|
|
203
|
+
...story.parameters,
|
|
204
|
+
docs: {
|
|
205
|
+
...story.parameters?.docs,
|
|
206
|
+
description: {
|
|
207
|
+
story: description,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
// Template components for stateful and composite stories
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
const ControlledTemplate = () => {
|
|
216
|
+
const [colour, setColour] = useState('#3cad51');
|
|
217
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem', maxWidth: '20rem' }, children: [_jsx(ColourPickerDropdown, { value: colour, onChange: (result) => setColour(result.hex), id: "controlled-colour" }), _jsxs("p", { style: { margin: 0, fontSize: '0.875rem', color: 'var(--color-grey-600)' }, children: ["Selected colour:", ' ', _jsx("code", { children: colour })] })] }));
|
|
218
|
+
};
|
|
219
|
+
const InFormFieldTemplate = () => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(FormField, { label: "Category colour", id: "category-colour", inputType: "colourPicker", inputProps: { value: '#3cad51' } }) }));
|
|
220
|
+
const WithFormFieldAndErrorTemplate = () => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(FormField, { label: "Background colour", id: "background-colour", inputType: "colourPicker", errorText: "Please choose a background colour.", inputProps: { value: '#3cad51' } }) }));
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// Stories
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
8
224
|
export const Default = {
|
|
9
225
|
args: {
|
|
10
226
|
value: '#3cad51',
|
|
11
|
-
onChange: (value) => { console.log(value); },
|
|
12
227
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
228
|
+
render: args => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(ColourPickerDropdown, { ...args }) })),
|
|
229
|
+
};
|
|
230
|
+
export const WithCustomValue = withDescription({
|
|
231
|
+
parameters: {
|
|
232
|
+
controls: { disable: true },
|
|
233
|
+
docs: {
|
|
234
|
+
source: {
|
|
235
|
+
language: 'tsx',
|
|
236
|
+
code: `
|
|
237
|
+
import { ColourPickerDropdown } from '@arbor-education/design-system.components';
|
|
238
|
+
|
|
239
|
+
function WithCustomValueExample() {
|
|
240
|
+
return (
|
|
241
|
+
<div style={{ maxWidth: '20rem' }}>
|
|
242
|
+
<ColourPickerDropdown value="#e84393" id="highlight-colour" />
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default WithCustomValueExample;
|
|
248
|
+
`.trim(),
|
|
249
|
+
},
|
|
17
250
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
251
|
+
},
|
|
252
|
+
render: () => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(ColourPickerDropdown, { value: "#e84393", id: "highlight-colour" }) })),
|
|
253
|
+
}, 'Pass any valid hex string to `value` to pre-seed the picker with a specific colour. The swatch in the trigger updates immediately.');
|
|
254
|
+
export const Disabled = withDescription({
|
|
255
|
+
parameters: {
|
|
256
|
+
controls: { disable: true },
|
|
257
|
+
docs: {
|
|
258
|
+
source: {
|
|
259
|
+
language: 'tsx',
|
|
260
|
+
code: `
|
|
261
|
+
import { ColourPickerDropdown } from '@arbor-education/design-system.components';
|
|
262
|
+
|
|
263
|
+
function DisabledExample() {
|
|
264
|
+
return (
|
|
265
|
+
<div style={{ maxWidth: '20rem' }}>
|
|
266
|
+
<ColourPickerDropdown value="#3cad51" disabled id="disabled-colour" />
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export default DisabledExample;
|
|
272
|
+
`.trim(),
|
|
273
|
+
},
|
|
21
274
|
},
|
|
22
275
|
},
|
|
23
|
-
}
|
|
276
|
+
render: () => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(ColourPickerDropdown, { value: "#3cad51", disabled: true, id: "disabled-colour" }) })),
|
|
277
|
+
}, 'When `disabled` is true the trigger is non-interactive and visually muted. The colour swatch is still visible so the current value remains clear.');
|
|
278
|
+
export const WithError = withDescription({
|
|
279
|
+
parameters: {
|
|
280
|
+
controls: { disable: true },
|
|
281
|
+
docs: {
|
|
282
|
+
source: {
|
|
283
|
+
language: 'tsx',
|
|
284
|
+
code: `
|
|
285
|
+
import { ColourPickerDropdown } from '@arbor-education/design-system.components';
|
|
286
|
+
|
|
287
|
+
function WithErrorExample() {
|
|
288
|
+
return (
|
|
289
|
+
<div style={{ maxWidth: '20rem' }}>
|
|
290
|
+
<ColourPickerDropdown
|
|
291
|
+
value="#3cad51"
|
|
292
|
+
hasError
|
|
293
|
+
aria-invalid
|
|
294
|
+
id="colour-with-error"
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export default WithErrorExample;
|
|
301
|
+
`.trim(),
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
render: () => (_jsx("div", { style: { maxWidth: '20rem' }, children: _jsx(ColourPickerDropdown, { value: "#3cad51", hasError: true, "aria-invalid": true, id: "colour-with-error" }) })),
|
|
306
|
+
}, 'Both `hasError` (red border on the trigger) and `aria-invalid` (screen-reader announcement) must be set together for a complete error treatment. Neither alone is sufficient.');
|
|
307
|
+
export const Controlled = withDescription({
|
|
308
|
+
parameters: {
|
|
309
|
+
controls: { disable: true },
|
|
310
|
+
docs: {
|
|
311
|
+
source: {
|
|
312
|
+
language: 'tsx',
|
|
313
|
+
code: `
|
|
314
|
+
import { useState } from 'react';
|
|
315
|
+
import type { ColorResult } from '@uiw/color-convert';
|
|
316
|
+
import { ColourPickerDropdown } from '@arbor-education/design-system.components';
|
|
317
|
+
|
|
318
|
+
function ControlledExample() {
|
|
319
|
+
const [colour, setColour] = useState('#3cad51');
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem', maxWidth: '20rem' }}>
|
|
323
|
+
<ColourPickerDropdown
|
|
324
|
+
value={colour}
|
|
325
|
+
onChange={(result: ColorResult) => setColour(result.hex)}
|
|
326
|
+
id="controlled-colour"
|
|
327
|
+
/>
|
|
328
|
+
<p style={{ margin: 0, fontSize: '0.875rem' }}>
|
|
329
|
+
Selected colour: <code>{colour}</code>
|
|
330
|
+
</p>
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export default ControlledExample;
|
|
336
|
+
`.trim(),
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
render: () => _jsx(ControlledTemplate, {}),
|
|
341
|
+
}, '`onChange` receives a `ColorResult` object — read `.hex` off it to keep your own state in sync. The selected hex value is reflected live beneath the picker.');
|
|
342
|
+
export const InFormField = withDescription({
|
|
343
|
+
parameters: {
|
|
344
|
+
controls: { disable: true },
|
|
345
|
+
docs: {
|
|
346
|
+
source: {
|
|
347
|
+
language: 'tsx',
|
|
348
|
+
code: `
|
|
349
|
+
import { FormField } from '@arbor-education/design-system.components';
|
|
350
|
+
|
|
351
|
+
function InFormFieldExample() {
|
|
352
|
+
return (
|
|
353
|
+
<div style={{ maxWidth: '20rem' }}>
|
|
354
|
+
<FormField
|
|
355
|
+
label="Category colour"
|
|
356
|
+
id="category-colour"
|
|
357
|
+
inputType="colourPicker"
|
|
358
|
+
inputProps={{ value: '#3cad51' }}
|
|
359
|
+
/>
|
|
360
|
+
</div>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export default InFormFieldExample;
|
|
365
|
+
`.trim(),
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
render: () => _jsx(InFormFieldTemplate, {}),
|
|
370
|
+
}, 'The recommended usage pattern — `FormField` with `inputType="colourPicker"` auto-wires the label, `hasError`, `aria-invalid`, and `aria-describedby`. No manual prop threading required.');
|
|
371
|
+
export const WithFormFieldAndError = withDescription({
|
|
372
|
+
parameters: {
|
|
373
|
+
controls: { disable: true },
|
|
374
|
+
docs: {
|
|
375
|
+
source: {
|
|
376
|
+
language: 'tsx',
|
|
377
|
+
code: `
|
|
378
|
+
import { FormField } from '@arbor-education/design-system.components';
|
|
379
|
+
|
|
380
|
+
function WithFormFieldAndErrorExample() {
|
|
381
|
+
return (
|
|
382
|
+
<div style={{ maxWidth: '20rem' }}>
|
|
383
|
+
<FormField
|
|
384
|
+
label="Background colour"
|
|
385
|
+
id="background-colour"
|
|
386
|
+
inputType="colourPicker"
|
|
387
|
+
errorText="Please choose a background colour."
|
|
388
|
+
inputProps={{ value: '#3cad51' }}
|
|
389
|
+
/>
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export default WithFormFieldAndErrorExample;
|
|
395
|
+
`.trim(),
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
render: () => _jsx(WithFormFieldAndErrorTemplate, {}),
|
|
400
|
+
}, 'The full error treatment via `FormField` — setting `errorText` automatically passes `hasError`, `aria-invalid`, and `aria-describedby` to the picker. No manual prop threading required.');
|
|
24
401
|
//# sourceMappingURL=ColourPickerDropdown.stories.js.map
|
package/dist/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColourPickerDropdown.stories.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColourPickerDropdown.stories.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/colourPickerDropdown/ColourPickerDropdown.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAC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EF,MAAM,CAAC,MAAM,UAAU,GAAU,eAAe,CAC9C;IACE,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC3B,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;WAuBL,CAAC,IAAI,EAAE;aACT;SACF;KACF;IACD,MAAM,EAAE,GAAG,EAAE,CAAC,KAAC,kBAAkB,KAAG;CACrC,EACD,8JAA8J,CAC/J,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAU,eAAe,CAC/C;IACE,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC3B,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE;;;;;;;;;;;;;;;;;WAiBL,CAAC,IAAI,EAAE;aACT;SACF;KACF;IACD,MAAM,EAAE,GAAG,EAAE,CAAC,KAAC,mBAAmB,KAAG;CACtC,EACD,0LAA0L,CAC3L,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAU,eAAe,CACzD;IACE,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC3B,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE;;;;;;;;;;;;;;;;;;WAkBL,CAAC,IAAI,EAAE;aACT;SACF;KACF;IACD,MAAM,EAAE,GAAG,EAAE,CAAC,KAAC,6BAA6B,KAAG;CAChD,EACD,0LAA0L,CAC3L,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/number/NumberInput.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiD,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAE1C,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/number/NumberInput.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiD,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAE1C,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CAwIlD,CAAC;AAEF,yBAAiB,WAAW,CAAC;IAC3B,KAAY,KAAK,GAAG,gBAAgB,CAAC;CACtC"}
|
|
@@ -4,7 +4,7 @@ import { Icon } from '../../../icon/Icon';
|
|
|
4
4
|
import Decimal from 'decimal.js';
|
|
5
5
|
import { useEffect, useRef, useState } from 'react';
|
|
6
6
|
export const NumberInput = (props) => {
|
|
7
|
-
const { hasError, className = '', disabled, onChange, defaultValue = '', step = 1, min = -Infinity, max = Infinity, disableSpinners, containerClassName, value: passedValue = '', ...rest } = props;
|
|
7
|
+
const { hasError, className = '', disabled, onChange, defaultValue = '', step = 1, min = -Infinity, max = Infinity, disableSpinners, containerClassName, value: passedValue = '', onKeyDown, ...rest } = props;
|
|
8
8
|
const [value, setValue] = useState(defaultValue.toString() || passedValue.toString());
|
|
9
9
|
const inputRef = useRef(null);
|
|
10
10
|
useEffect(() => {
|
|
@@ -45,9 +45,21 @@ export const NumberInput = (props) => {
|
|
|
45
45
|
const handleOnBlur = () => {
|
|
46
46
|
checkOverOrUnderMaxOrMin(value);
|
|
47
47
|
};
|
|
48
|
+
const handleOnKeyDown = (e) => {
|
|
49
|
+
if (e.key === 'Enter') {
|
|
50
|
+
handleOnBlur();
|
|
51
|
+
}
|
|
52
|
+
if (e.key === 'ArrowUp') {
|
|
53
|
+
handleSpinner(step);
|
|
54
|
+
}
|
|
55
|
+
if (e.key === 'ArrowDown') {
|
|
56
|
+
handleSpinner(-step);
|
|
57
|
+
}
|
|
58
|
+
onKeyDown?.(e);
|
|
59
|
+
};
|
|
48
60
|
return (_jsxs("div", { className: classNames('ds-number-input__container', {
|
|
49
61
|
'ds-number-input__container--error': hasError,
|
|
50
62
|
'ds-number-input__container--disabled': disabled,
|
|
51
|
-
}, containerClassName), children: [!disableSpinners && (_jsx("button", { className: "ds-number-input__spinner-button", type: "button", disabled: disabled || (Number(value) <= Number(min)), onClick: () => handleSpinner(-step), "aria-label": "Minus button", "data-testid": "minus-button", children: _jsx(Icon, { name: "minus", size: 12 }) })), _jsx("input", { ref: inputRef, type: "text", inputMode: "numeric", autoComplete: "off", pattern: "^[+\\-]?\\d+(,\\d{2})?", className: inputClasses, disabled: disabled, defaultValue: defaultValue, onChange: (e) => handleOnChange(e.currentTarget.value), onBlur: handleOnBlur, step: step, min: min, max: max, ...rest }), !disableSpinners && (_jsx("button", { className: "ds-number-input__spinner-button", type: "button", disabled: disabled || (Number(value) >= Number(max)), onClick: () => handleSpinner(step), "aria-label": "Plus button", "data-testid": "plus-button", children: _jsx(Icon, { name: "plus", size: 12 }) }))] }));
|
|
63
|
+
}, containerClassName), children: [!disableSpinners && (_jsx("button", { className: "ds-number-input__spinner-button", type: "button", disabled: disabled || (Number(value) <= Number(min)), onClick: () => handleSpinner(-step), "aria-label": "Minus button", "data-testid": "minus-button", children: _jsx(Icon, { name: "minus", size: 12 }) })), _jsx("input", { ref: inputRef, type: "text", inputMode: "numeric", autoComplete: "off", pattern: "^[+\\-]?\\d+(,\\d{2})?", className: inputClasses, disabled: disabled, defaultValue: defaultValue, onChange: (e) => handleOnChange(e.currentTarget.value), onBlur: handleOnBlur, onKeyDown: handleOnKeyDown, step: step, min: min, max: max, ...rest }), !disableSpinners && (_jsx("button", { className: "ds-number-input__spinner-button", type: "button", disabled: disabled || (Number(value) >= Number(max)), onClick: () => handleSpinner(step), "aria-label": "Plus button", "data-testid": "plus-button", children: _jsx(Icon, { name: "plus", size: 12 }) }))] }));
|
|
52
64
|
};
|
|
53
65
|
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/number/NumberInput.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA8C,MAAM,OAAO,CAAC;AAQhG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EACJ,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,EAAE,EACjB,IAAI,GAAG,CAAC,EACR,GAAG,GAAG,CAAC,QAAQ,EACf,GAAG,GAAG,QAAQ,EACd,eAAe,EACf,kBAAkB,EAClB,KAAK,EAAE,WAAW,GAAG,EAAE,EACvB,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,YAAY,CAAC,QAAQ,EAAE,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9F,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAA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EACrF,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,KACJ,IAAI,GACR,EAED,CAAC,eAAe,IAAI,CACnB,iBACE,SAAS,EAAC,iCAAiC,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,gBACvB,aAAa,iBACZ,aAAa,YAEzB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAE,EAAE,GAAI,GACvB,CACV,IACG,CAEP,CAAC;AACJ,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/number/NumberInput.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA8C,MAAM,OAAO,CAAC;AAQhG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EACJ,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,EAAE,EACjB,IAAI,GAAG,CAAC,EACR,GAAG,GAAG,CAAC,QAAQ,EACf,GAAG,GAAG,QAAQ,EACd,eAAe,EACf,kBAAkB,EAClB,KAAK,EAAE,WAAW,GAAG,EAAE,EACvB,SAAS,EACT,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,YAAY,CAAC,QAAQ,EAAE,IA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,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,gBACxB,cAAc,iBACb,cAAc,YAE1B,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,GAAI,GACxB,CACV,EAED,gBACE,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,SAAS,EACnB,YAAY,EAAC,KAAK,EAClB,OAAO,EAAC,wBAAqB,EAC7B,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EACrF,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,KACJ,IAAI,GACR,EAED,CAAC,eAAe,IAAI,CACnB,iBACE,SAAS,EAAC,iCAAiC,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,gBACvB,aAAa,iBACZ,aAAa,YAEzB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAE,EAAE,GAAI,GACvB,CACV,IACG,CAEP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -26,6 +26,27 @@ describe('NumberInput component', () => {
|
|
|
26
26
|
fireEvent.click(screen.getByLabelText('Plus button'));
|
|
27
27
|
expect(inputElement.value).toBe('12');
|
|
28
28
|
});
|
|
29
|
+
describe('Keyboard controls', () => {
|
|
30
|
+
test('pressing Enter validates and clamps value to max', () => {
|
|
31
|
+
render(_jsx(NumberInput, { placeholder: "Enter a number", defaultValue: "5", min: 0, max: 10 }));
|
|
32
|
+
const inputElement = screen.getByPlaceholderText('Enter a number');
|
|
33
|
+
fireEvent.change(inputElement, { target: { value: '12' } });
|
|
34
|
+
fireEvent.keyDown(inputElement, { key: 'Enter' });
|
|
35
|
+
expect(inputElement.value).toBe('10');
|
|
36
|
+
});
|
|
37
|
+
test('ArrowUp increments by step', () => {
|
|
38
|
+
render(_jsx(NumberInput, { placeholder: "Enter a number", defaultValue: "10", step: 2 }));
|
|
39
|
+
const inputElement = screen.getByPlaceholderText('Enter a number');
|
|
40
|
+
fireEvent.keyDown(inputElement, { key: 'ArrowUp' });
|
|
41
|
+
expect(inputElement.value).toBe('12');
|
|
42
|
+
});
|
|
43
|
+
test('ArrowDown decrements by step', () => {
|
|
44
|
+
render(_jsx(NumberInput, { placeholder: "Enter a number", defaultValue: "10", step: 2 }));
|
|
45
|
+
const inputElement = screen.getByPlaceholderText('Enter a number');
|
|
46
|
+
fireEvent.keyDown(inputElement, { key: 'ArrowDown' });
|
|
47
|
+
expect(inputElement.value).toBe('8');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
29
50
|
describe('Decimal value handling', () => {
|
|
30
51
|
test('handles decimal step values correctly', () => {
|
|
31
52
|
render(_jsx(NumberInput, { placeholder: "Enter a number", defaultValue: "0.5", step: 0.1 }));
|