@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
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import {
|
|
3
|
+
Controls,
|
|
4
|
+
Heading as DocHeading,
|
|
5
|
+
Markdown,
|
|
6
|
+
Primary as DocPrimary,
|
|
7
|
+
Stories,
|
|
8
|
+
Subtitle,
|
|
9
|
+
Title,
|
|
10
|
+
} from '@storybook/addon-docs/blocks';
|
|
11
|
+
import type { CustomCellRendererProps } from 'ag-grid-react';
|
|
12
|
+
import { BooleanCellRenderer } from './BooleanCellRenderer';
|
|
13
|
+
import { Table } from 'Components/table/Table';
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Docs page content
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const DESCRIPTION_INTRO = [
|
|
20
|
+
'`BooleanCellRenderer` is an AG Grid cell renderer that displays boolean values as icons.',
|
|
21
|
+
'A `true` value renders a green check icon; a `false` value renders a red ✕ icon;',
|
|
22
|
+
'any other value (including `null` and `undefined`) renders nothing.',
|
|
23
|
+
'',
|
|
24
|
+
'Register it via the string key `dsBooleanCellRenderer` (pre-registered by Arbor\'s `Table`) or by importing the component directly.',
|
|
25
|
+
].join('\n');
|
|
26
|
+
|
|
27
|
+
const USAGE_GUIDANCE = [
|
|
28
|
+
'### When to use',
|
|
29
|
+
'',
|
|
30
|
+
'- On boolean columns where a visual icon is clearer than plain `true`/`false` text',
|
|
31
|
+
'- Active/inactive flags, yes/no columns, on/off states that are read-only',
|
|
32
|
+
'',
|
|
33
|
+
'---',
|
|
34
|
+
'',
|
|
35
|
+
'### When NOT to use',
|
|
36
|
+
'',
|
|
37
|
+
'| Situation | Use instead |',
|
|
38
|
+
'|---|---|',
|
|
39
|
+
'| User needs to toggle the value in the cell | `CheckboxCellRenderer` (`dsCheckboxCellRenderer`) |',
|
|
40
|
+
'| You want text labels like "Yes" / "No" | A `valueFormatter` returning strings, with the default renderer |',
|
|
41
|
+
'| The value is truthy/falsy but not strictly boolean | Coerce to `true`/`false` first — see Developer notes |',
|
|
42
|
+
].join('\n');
|
|
43
|
+
|
|
44
|
+
const DEVELOPER_NOTES = [
|
|
45
|
+
'### Critical usage patterns',
|
|
46
|
+
'',
|
|
47
|
+
'**Value comparison is strict — only `true` and `false` produce icons.**',
|
|
48
|
+
'The renderer checks `value === true` and `value === false`. Truthy values like `1`, `"yes"`, or objects render nothing.',
|
|
49
|
+
'Coerce your data to a strict boolean before passing to this column.',
|
|
50
|
+
'',
|
|
51
|
+
'```tsx',
|
|
52
|
+
"import { Table } from '@arbor-education/design-system.components';",
|
|
53
|
+
'',
|
|
54
|
+
'const colDefs = [',
|
|
55
|
+
' {',
|
|
56
|
+
" field: 'isActive',",
|
|
57
|
+
" headerName: 'Active',",
|
|
58
|
+
" cellRenderer: 'dsBooleanCellRenderer', // string key — no import needed",
|
|
59
|
+
' },',
|
|
60
|
+
'];',
|
|
61
|
+
'```',
|
|
62
|
+
'',
|
|
63
|
+
'---',
|
|
64
|
+
'',
|
|
65
|
+
'### Accessibility',
|
|
66
|
+
'',
|
|
67
|
+
'Icons include `screenReaderText` props (`"true"` and `"false"`) so screen readers announce',
|
|
68
|
+
"the cell's boolean meaning rather than describing the icon shape.",
|
|
69
|
+
'',
|
|
70
|
+
'---',
|
|
71
|
+
'',
|
|
72
|
+
'### TypeScript types',
|
|
73
|
+
'',
|
|
74
|
+
'```ts',
|
|
75
|
+
"import { BooleanCellRenderer } from '@arbor-education/design-system.components';",
|
|
76
|
+
'```',
|
|
77
|
+
'',
|
|
78
|
+
'`BooleanCellRenderer` accepts `CustomCellRendererProps` from AG Grid — only `value` is used by this renderer.',
|
|
79
|
+
].join('\n');
|
|
80
|
+
|
|
81
|
+
const RELATED_COMPONENTS = [
|
|
82
|
+
'## Related components',
|
|
83
|
+
'',
|
|
84
|
+
'[Table](?path=/docs/components-table--docs) · [CheckboxCellRenderer](?path=/docs/components-table-cellrenderers-checkboxcellrenderer--docs) · [Icon](?path=/docs/components-icon--docs)',
|
|
85
|
+
].join('\n');
|
|
86
|
+
|
|
87
|
+
const PROPS_INTRO = 'The preview below is wired to the **Controls** panel — use the `value` selector to see how `true`, `false`, and `null` each render.';
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Custom DocsPage
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
function BooleanCellRendererDocsPage() {
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<Title />
|
|
97
|
+
<Subtitle />
|
|
98
|
+
<Markdown>{DESCRIPTION_INTRO}</Markdown>
|
|
99
|
+
<DocHeading>Interactive example</DocHeading>
|
|
100
|
+
<Markdown>{PROPS_INTRO}</Markdown>
|
|
101
|
+
<DocPrimary />
|
|
102
|
+
<Controls />
|
|
103
|
+
<DocHeading>Usage guidance</DocHeading>
|
|
104
|
+
<Markdown>{USAGE_GUIDANCE}</Markdown>
|
|
105
|
+
<DocHeading>Developer notes</DocHeading>
|
|
106
|
+
<Markdown>{DEVELOPER_NOTES}</Markdown>
|
|
107
|
+
<DocHeading>Examples</DocHeading>
|
|
108
|
+
<Stories title="" />
|
|
109
|
+
<Markdown>{RELATED_COMPONENTS}</Markdown>
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Meta
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
const MOCK_CELL_PROPS = {} as unknown as CustomCellRendererProps;
|
|
119
|
+
|
|
120
|
+
const meta = {
|
|
121
|
+
title: 'Components/Table/CellRenderers/BooleanCellRenderer',
|
|
122
|
+
component: BooleanCellRenderer,
|
|
123
|
+
tags: ['autodocs'],
|
|
124
|
+
parameters: {
|
|
125
|
+
layout: 'padded',
|
|
126
|
+
docs: { page: BooleanCellRendererDocsPage },
|
|
127
|
+
},
|
|
128
|
+
argTypes: {
|
|
129
|
+
value: {
|
|
130
|
+
control: { type: 'select' },
|
|
131
|
+
options: [true, false, null],
|
|
132
|
+
description: 'The cell value. `true` renders a green check icon; `false` renders a red ✕ icon; any other value renders nothing.',
|
|
133
|
+
table: {
|
|
134
|
+
type: { summary: 'true | false | null | undefined' },
|
|
135
|
+
defaultValue: { summary: 'undefined' },
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
} satisfies Meta<typeof BooleanCellRenderer>;
|
|
140
|
+
|
|
141
|
+
export default meta;
|
|
142
|
+
type Story = StoryObj<typeof BooleanCellRenderer>;
|
|
143
|
+
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Helper: attach a per-story description to docs
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
const withDescription = (story: Story, description: string): Story => ({
|
|
149
|
+
...story,
|
|
150
|
+
parameters: {
|
|
151
|
+
...story.parameters,
|
|
152
|
+
docs: { ...story.parameters?.docs, description: { story: description } },
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Stories
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
export const Default: Story = withDescription(
|
|
161
|
+
{
|
|
162
|
+
args: { value: true },
|
|
163
|
+
render: args => <BooleanCellRenderer {...MOCK_CELL_PROPS} value={args.value} />,
|
|
164
|
+
},
|
|
165
|
+
'Interactive example — select `true`, `false`, or `null` from the **Controls** panel to see how each value renders.',
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
export const True: Story = withDescription(
|
|
169
|
+
{
|
|
170
|
+
parameters: {
|
|
171
|
+
controls: { disable: true },
|
|
172
|
+
docs: {
|
|
173
|
+
source: {
|
|
174
|
+
language: 'tsx',
|
|
175
|
+
code: `
|
|
176
|
+
import { Table } from '@arbor-education/design-system.components';
|
|
177
|
+
|
|
178
|
+
const colDefs = [
|
|
179
|
+
{
|
|
180
|
+
field: 'isActive',
|
|
181
|
+
headerName: 'Active',
|
|
182
|
+
cellRenderer: 'dsBooleanCellRenderer',
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
`.trim(),
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
render: () => <BooleanCellRenderer {...MOCK_CELL_PROPS} value={true} />,
|
|
190
|
+
},
|
|
191
|
+
'A `true` value renders a green check icon. The icon carries `screenReaderText="true"` for assistive technology.',
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
export const False: Story = withDescription(
|
|
195
|
+
{
|
|
196
|
+
parameters: { controls: { disable: true } },
|
|
197
|
+
render: () => <BooleanCellRenderer {...MOCK_CELL_PROPS} value={false} />,
|
|
198
|
+
},
|
|
199
|
+
'A `false` value renders a red ✕ icon. The icon carries `screenReaderText="false"` for assistive technology.',
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
export const Empty: Story = withDescription(
|
|
203
|
+
{
|
|
204
|
+
parameters: { controls: { disable: true } },
|
|
205
|
+
render: () => <BooleanCellRenderer {...MOCK_CELL_PROPS} value={null} />,
|
|
206
|
+
},
|
|
207
|
+
'`null`, `undefined`, or any non-boolean value renders nothing — the cell is intentionally left empty. This is by design: the renderer uses strict `=== true` / `=== false` comparisons, not truthiness.',
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const BOOLEAN_IN_TABLE_DATA = [
|
|
211
|
+
{ name: 'Alice Johnson', active: true },
|
|
212
|
+
{ name: 'Bob Smith', active: false },
|
|
213
|
+
{ name: 'Charlie Brown', active: true },
|
|
214
|
+
{ name: 'Diana Prince', active: null },
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
export const InATable: Story = withDescription(
|
|
218
|
+
{
|
|
219
|
+
parameters: {
|
|
220
|
+
controls: { disable: true },
|
|
221
|
+
docs: {
|
|
222
|
+
source: {
|
|
223
|
+
language: 'tsx',
|
|
224
|
+
code: `
|
|
225
|
+
import { Table } from '@arbor-education/design-system.components';
|
|
226
|
+
|
|
227
|
+
const rowData = [
|
|
228
|
+
{ name: 'Alice Johnson', active: true },
|
|
229
|
+
{ name: 'Bob Smith', active: false },
|
|
230
|
+
{ name: 'Charlie Brown', active: true },
|
|
231
|
+
{ name: 'Diana Prince', active: null },
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
function BooleanCellRendererExample() {
|
|
235
|
+
return (
|
|
236
|
+
<Table
|
|
237
|
+
rowData={rowData}
|
|
238
|
+
columnDefs={[
|
|
239
|
+
{ field: 'name', headerName: 'Name', flex: 2 },
|
|
240
|
+
{
|
|
241
|
+
field: 'active',
|
|
242
|
+
headerName: 'Active',
|
|
243
|
+
flex: 1,
|
|
244
|
+
editable: false,
|
|
245
|
+
cellRenderer: 'dsBooleanCellRenderer',
|
|
246
|
+
},
|
|
247
|
+
]}
|
|
248
|
+
defaultColDef={{ flex: 1, minWidth: 120 }}
|
|
249
|
+
domLayout="autoHeight"
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export default BooleanCellRendererExample;
|
|
255
|
+
`.trim(),
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
render: () => (
|
|
260
|
+
<Table
|
|
261
|
+
rowData={BOOLEAN_IN_TABLE_DATA}
|
|
262
|
+
columnDefs={[
|
|
263
|
+
{ field: 'name', headerName: 'Name', flex: 2 },
|
|
264
|
+
{
|
|
265
|
+
field: 'active',
|
|
266
|
+
headerName: 'Active',
|
|
267
|
+
flex: 1,
|
|
268
|
+
editable: false,
|
|
269
|
+
cellRenderer: 'dsBooleanCellRenderer',
|
|
270
|
+
},
|
|
271
|
+
]}
|
|
272
|
+
defaultColDef={{ flex: 1, minWidth: 120 }}
|
|
273
|
+
domLayout="autoHeight"
|
|
274
|
+
/>
|
|
275
|
+
),
|
|
276
|
+
},
|
|
277
|
+
'`dsBooleanCellRenderer` wired up inside a full `Table`. `true` renders a check, `false` renders a ✕, and `null` leaves the cell empty. The Active column is set to `editable: false` — this renderer is display-only.',
|
|
278
|
+
);
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import {
|
|
3
|
+
Controls,
|
|
4
|
+
Heading as DocHeading,
|
|
5
|
+
Markdown,
|
|
6
|
+
Primary as DocPrimary,
|
|
7
|
+
Stories,
|
|
8
|
+
Subtitle,
|
|
9
|
+
Title,
|
|
10
|
+
} from '@storybook/addon-docs/blocks';
|
|
11
|
+
import type { CustomCellRendererProps } from 'ag-grid-react';
|
|
12
|
+
import { ButtonCellRenderer } from './ButtonCellRenderer';
|
|
13
|
+
import { Table } from 'Components/table/Table';
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Docs page content
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const DESCRIPTION_INTRO = [
|
|
20
|
+
'`ButtonCellRenderer` is an AG Grid cell renderer that renders an Arbor `Button` inside a table cell.',
|
|
21
|
+
'The cell `value` (or `valueFormatted`) must be a `ButtonProps` object — the renderer spreads it',
|
|
22
|
+
'directly onto `Button`, so all button variants, sizes, and handlers are supported.',
|
|
23
|
+
'',
|
|
24
|
+
'Register it via the string key `dsButtonCellRenderer` (pre-registered by Arbor\'s `Table`) or by importing the component directly.',
|
|
25
|
+
].join('\n');
|
|
26
|
+
|
|
27
|
+
const USAGE_GUIDANCE = [
|
|
28
|
+
'### When to use',
|
|
29
|
+
'',
|
|
30
|
+
'- On action columns where each row needs a button (e.g. "View", "Edit", "Delete")',
|
|
31
|
+
'- When the action is contextual to the row — the `onClick` handler receives the event and can close over row data',
|
|
32
|
+
'',
|
|
33
|
+
'---',
|
|
34
|
+
'',
|
|
35
|
+
'### When NOT to use',
|
|
36
|
+
'',
|
|
37
|
+
'| Situation | Use instead |',
|
|
38
|
+
'|---|---|',
|
|
39
|
+
'| The action navigates to another page | A link (`<a>`) cell renderer or AG Grid\'s built-in link support |',
|
|
40
|
+
'| Every row shares the exact same static label with no per-row variation | A column header action button outside the grid |',
|
|
41
|
+
].join('\n');
|
|
42
|
+
|
|
43
|
+
const DEVELOPER_NOTES = [
|
|
44
|
+
'### Critical usage patterns',
|
|
45
|
+
'',
|
|
46
|
+
'**`value` must be a `ButtonProps` object with a `children` key.**',
|
|
47
|
+
'The renderer reads `value.children` as the button label. If `children` is absent it falls back to `value.value`.',
|
|
48
|
+
'All other `ButtonProps` (`variant`, `size`, `onClick`, `disabled`) are spread onto `Button`.',
|
|
49
|
+
'',
|
|
50
|
+
'**Provide the ButtonProps via `valueGetter` — the cell field value must BE the ButtonProps object.**',
|
|
51
|
+
'',
|
|
52
|
+
'```tsx',
|
|
53
|
+
"import { Table } from '@arbor-education/design-system.components';",
|
|
54
|
+
'',
|
|
55
|
+
'const colDefs = [',
|
|
56
|
+
' {',
|
|
57
|
+
" colId: 'viewAction',",
|
|
58
|
+
" headerName: '',",
|
|
59
|
+
" cellRenderer: 'dsButtonCellRenderer',",
|
|
60
|
+
' valueGetter: (params) => ({',
|
|
61
|
+
" children: 'View',",
|
|
62
|
+
" variant: 'secondary',",
|
|
63
|
+
" size: 'S',",
|
|
64
|
+
' onClick: () => handleView(params.data),',
|
|
65
|
+
' }),',
|
|
66
|
+
' },',
|
|
67
|
+
'];',
|
|
68
|
+
'```',
|
|
69
|
+
'',
|
|
70
|
+
'---',
|
|
71
|
+
'',
|
|
72
|
+
'### Accessibility',
|
|
73
|
+
'',
|
|
74
|
+
'Each cell\'s button inherits its accessible name from `children`. If `children` is an icon with no',
|
|
75
|
+
'visible text, add `aria-label` to the ButtonProps object.',
|
|
76
|
+
'',
|
|
77
|
+
'---',
|
|
78
|
+
'',
|
|
79
|
+
'### TypeScript types',
|
|
80
|
+
'',
|
|
81
|
+
'```ts',
|
|
82
|
+
"import { ButtonCellRenderer } from '@arbor-education/design-system.components';",
|
|
83
|
+
"import type { ButtonProps } from '@arbor-education/design-system.components';",
|
|
84
|
+
'',
|
|
85
|
+
'// In your valueGetter:',
|
|
86
|
+
'// (params): ButtonProps => ({ children: "View", variant: "secondary", onClick: ... })',
|
|
87
|
+
'```',
|
|
88
|
+
].join('\n');
|
|
89
|
+
|
|
90
|
+
const RELATED_COMPONENTS = [
|
|
91
|
+
'## Related components',
|
|
92
|
+
'',
|
|
93
|
+
'[Table](?path=/docs/components-table--docs) · [Button](?path=/docs/components-button--docs)',
|
|
94
|
+
].join('\n');
|
|
95
|
+
|
|
96
|
+
const PROPS_INTRO = 'The preview below shows `ButtonCellRenderer` with representative button configurations. The `value` prop is a `ButtonProps` object — most individual props are not separately controllable via the Controls panel.';
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Custom DocsPage
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
function ButtonCellRendererDocsPage() {
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
<Title />
|
|
106
|
+
<Subtitle />
|
|
107
|
+
<Markdown>{DESCRIPTION_INTRO}</Markdown>
|
|
108
|
+
<DocHeading>Interactive example</DocHeading>
|
|
109
|
+
<Markdown>{PROPS_INTRO}</Markdown>
|
|
110
|
+
<DocPrimary />
|
|
111
|
+
<Controls />
|
|
112
|
+
<DocHeading>Usage guidance</DocHeading>
|
|
113
|
+
<Markdown>{USAGE_GUIDANCE}</Markdown>
|
|
114
|
+
<DocHeading>Developer notes</DocHeading>
|
|
115
|
+
<Markdown>{DEVELOPER_NOTES}</Markdown>
|
|
116
|
+
<DocHeading>Examples</DocHeading>
|
|
117
|
+
<Stories title="" />
|
|
118
|
+
<Markdown>{RELATED_COMPONENTS}</Markdown>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Meta
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
const MOCK_CELL_PROPS = {} as unknown as CustomCellRendererProps;
|
|
128
|
+
|
|
129
|
+
const meta = {
|
|
130
|
+
title: 'Components/Table/CellRenderers/ButtonCellRenderer',
|
|
131
|
+
component: ButtonCellRenderer,
|
|
132
|
+
tags: ['autodocs'],
|
|
133
|
+
parameters: {
|
|
134
|
+
layout: 'padded',
|
|
135
|
+
docs: { page: ButtonCellRendererDocsPage },
|
|
136
|
+
},
|
|
137
|
+
argTypes: {
|
|
138
|
+
value: {
|
|
139
|
+
control: false,
|
|
140
|
+
description: 'A `ButtonProps` object. The `children` key becomes the button label; all other `ButtonProps` (`variant`, `size`, `onClick`, `disabled`) are spread onto the `Button` component.',
|
|
141
|
+
table: {
|
|
142
|
+
type: { summary: 'ButtonProps' },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
valueFormatted: {
|
|
146
|
+
control: false,
|
|
147
|
+
description: 'If provided, overrides `value` as the source for button props. Set by AG Grid\'s `valueFormatter`.',
|
|
148
|
+
table: {
|
|
149
|
+
type: { summary: 'ButtonProps | undefined' },
|
|
150
|
+
defaultValue: { summary: 'undefined' },
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
} satisfies Meta<typeof ButtonCellRenderer>;
|
|
155
|
+
|
|
156
|
+
export default meta;
|
|
157
|
+
type Story = StoryObj<typeof ButtonCellRenderer>;
|
|
158
|
+
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
// Helper: attach a per-story description to docs
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
|
|
163
|
+
const withDescription = (story: Story, description: string): Story => ({
|
|
164
|
+
...story,
|
|
165
|
+
parameters: {
|
|
166
|
+
...story.parameters,
|
|
167
|
+
docs: { ...story.parameters?.docs, description: { story: description } },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Stories
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
export const Default: Story = withDescription(
|
|
176
|
+
{
|
|
177
|
+
parameters: { controls: { disable: true } },
|
|
178
|
+
render: () => (
|
|
179
|
+
<ButtonCellRenderer
|
|
180
|
+
{...MOCK_CELL_PROPS}
|
|
181
|
+
value={{ children: 'View details', variant: 'secondary', size: 'S' }}
|
|
182
|
+
/>
|
|
183
|
+
),
|
|
184
|
+
},
|
|
185
|
+
'A secondary `Button` rendered inside a cell. `variant: "secondary"` and `size: "S"` are typical for action columns.',
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
export const PrimaryVariant: Story = withDescription(
|
|
189
|
+
{
|
|
190
|
+
parameters: {
|
|
191
|
+
controls: { disable: true },
|
|
192
|
+
docs: {
|
|
193
|
+
source: {
|
|
194
|
+
language: 'tsx',
|
|
195
|
+
code: `
|
|
196
|
+
import { Table } from '@arbor-education/design-system.components';
|
|
197
|
+
|
|
198
|
+
const colDefs = [
|
|
199
|
+
{
|
|
200
|
+
colId: 'action',
|
|
201
|
+
headerName: '',
|
|
202
|
+
cellRenderer: 'dsButtonCellRenderer',
|
|
203
|
+
valueGetter: (params) => ({
|
|
204
|
+
children: 'Enrol',
|
|
205
|
+
variant: 'primary',
|
|
206
|
+
size: 'S',
|
|
207
|
+
onClick: () => handleEnrol(params.data),
|
|
208
|
+
}),
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
`.trim(),
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
render: () => (
|
|
216
|
+
<ButtonCellRenderer
|
|
217
|
+
{...MOCK_CELL_PROPS}
|
|
218
|
+
value={{ children: 'Enrol', variant: 'primary', size: 'S' }}
|
|
219
|
+
/>
|
|
220
|
+
),
|
|
221
|
+
},
|
|
222
|
+
'`variant: "primary"` — use sparingly and only when the action is the primary call-to-action for the row.',
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
export const DestructiveVariant: Story = withDescription(
|
|
226
|
+
{
|
|
227
|
+
parameters: { controls: { disable: true } },
|
|
228
|
+
render: () => (
|
|
229
|
+
<ButtonCellRenderer
|
|
230
|
+
{...MOCK_CELL_PROPS}
|
|
231
|
+
value={{ children: 'Remove', variant: 'primary-destructive', size: 'S' }}
|
|
232
|
+
/>
|
|
233
|
+
),
|
|
234
|
+
},
|
|
235
|
+
'`variant: "primary-destructive"` — for destructive actions like delete or remove.',
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
export const Disabled: Story = withDescription(
|
|
239
|
+
{
|
|
240
|
+
parameters: { controls: { disable: true } },
|
|
241
|
+
render: () => (
|
|
242
|
+
<ButtonCellRenderer
|
|
243
|
+
{...MOCK_CELL_PROPS}
|
|
244
|
+
value={{ children: 'View details', variant: 'secondary', size: 'S', disabled: true }}
|
|
245
|
+
/>
|
|
246
|
+
),
|
|
247
|
+
},
|
|
248
|
+
'Pass `disabled: true` in the `ButtonProps` value to conditionally disable the button for specific rows.',
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const BUTTON_IN_TABLE_DATA = [
|
|
252
|
+
{ id: 1, name: 'Alice Johnson', role: 'Developer' },
|
|
253
|
+
{ id: 2, name: 'Bob Smith', role: 'Designer' },
|
|
254
|
+
{ id: 3, name: 'Charlie Brown', role: 'Manager' },
|
|
255
|
+
];
|
|
256
|
+
|
|
257
|
+
export const InATable: Story = withDescription(
|
|
258
|
+
{
|
|
259
|
+
parameters: {
|
|
260
|
+
controls: { disable: true },
|
|
261
|
+
docs: {
|
|
262
|
+
source: {
|
|
263
|
+
language: 'tsx',
|
|
264
|
+
code: `
|
|
265
|
+
import { Table } from '@arbor-education/design-system.components';
|
|
266
|
+
|
|
267
|
+
const rowData = [
|
|
268
|
+
{ id: 1, name: 'Alice Johnson', role: 'Developer' },
|
|
269
|
+
{ id: 2, name: 'Bob Smith', role: 'Designer' },
|
|
270
|
+
{ id: 3, name: 'Charlie Brown', role: 'Manager' },
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
function ButtonCellRendererExample() {
|
|
274
|
+
return (
|
|
275
|
+
<Table
|
|
276
|
+
rowData={rowData}
|
|
277
|
+
columnDefs={[
|
|
278
|
+
{ field: 'name', headerName: 'Name', flex: 2 },
|
|
279
|
+
{ field: 'role', headerName: 'Role', flex: 1 },
|
|
280
|
+
{
|
|
281
|
+
colId: 'viewAction',
|
|
282
|
+
headerName: '',
|
|
283
|
+
flex: 1,
|
|
284
|
+
maxWidth: 180,
|
|
285
|
+
editable: false,
|
|
286
|
+
cellRenderer: 'dsButtonCellRenderer',
|
|
287
|
+
valueGetter: (params) => ({
|
|
288
|
+
children: 'View details',
|
|
289
|
+
variant: 'secondary',
|
|
290
|
+
size: 'S',
|
|
291
|
+
onClick: () => console.log('View', params.data.name),
|
|
292
|
+
}),
|
|
293
|
+
},
|
|
294
|
+
]}
|
|
295
|
+
defaultColDef={{ flex: 1, minWidth: 120 }}
|
|
296
|
+
domLayout="autoHeight"
|
|
297
|
+
/>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export default ButtonCellRendererExample;
|
|
302
|
+
`.trim(),
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
render: () => (
|
|
307
|
+
<Table
|
|
308
|
+
rowData={BUTTON_IN_TABLE_DATA}
|
|
309
|
+
columnDefs={[
|
|
310
|
+
{ field: 'name', headerName: 'Name', flex: 2 },
|
|
311
|
+
{ field: 'role', headerName: 'Role', flex: 1 },
|
|
312
|
+
{
|
|
313
|
+
colId: 'viewAction',
|
|
314
|
+
headerName: '',
|
|
315
|
+
flex: 1,
|
|
316
|
+
maxWidth: 180,
|
|
317
|
+
editable: false,
|
|
318
|
+
cellRenderer: 'dsButtonCellRenderer',
|
|
319
|
+
valueGetter: params => ({
|
|
320
|
+
children: 'View details',
|
|
321
|
+
variant: 'secondary',
|
|
322
|
+
size: 'S',
|
|
323
|
+
onClick: () => console.log('View', params.data.name),
|
|
324
|
+
}),
|
|
325
|
+
},
|
|
326
|
+
]}
|
|
327
|
+
defaultColDef={{ flex: 1, minWidth: 120 }}
|
|
328
|
+
domLayout="autoHeight"
|
|
329
|
+
/>
|
|
330
|
+
),
|
|
331
|
+
},
|
|
332
|
+
'`dsButtonCellRenderer` wired up inside a full `Table`. The action column uses `valueGetter` to return a `ButtonProps` object per row — `onClick` closes over `params.data` so each button knows its row. Click a button and check the browser console.',
|
|
333
|
+
);
|