@webiny/admin-ui 6.5.2-beta.1 → 6.5.2-beta.3
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/Accordion/Accordion.stories.js.map +1 -1
- package/Accordion/components/AccordionBackgroundProvider.js.map +1 -1
- package/Accordion/components/AccordionTrigger.js.map +1 -1
- package/AdminUiProvider/AdminUiProvider.js.map +1 -1
- package/Checkbox/primitives/CheckboxPrimitive.js.map +1 -1
- package/CheckboxGroup/primitives/CheckboxGroupPrimitive.js.map +1 -1
- package/DataTable/DataTable.js +1 -1
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/DataTable.stories.js +1 -1
- package/DataTable/DataTable.stories.js.map +1 -1
- package/DatePicker/DatePicker.js.map +1 -1
- package/DatePicker/DatePicker.stories.js.map +1 -1
- package/DatePicker/primitives/WeekPicker.js +1 -1
- package/DatePicker/primitives/WeekPicker.js.map +1 -1
- package/DatePicker/primitives/components/DatePickerTrigger.js.map +1 -1
- package/DatePicker/utils/timezoneHelpers.js +1 -1
- package/DatePicker/utils/timezoneHelpers.js.map +1 -1
- package/Dialog/components/DialogContent.js.map +1 -1
- package/Dialog/components/DialogOverlay.js.map +1 -1
- package/Drawer/components/DrawerContent.js.map +1 -1
- package/Drawer/components/DrawerOverlay.js.map +1 -1
- package/DropdownMenu/DropdownMenu.js.map +1 -1
- package/DropdownMenu/DropdownMenu.stories.js +1 -1
- package/DropdownMenu/DropdownMenu.stories.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuCheckboxItem.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuContent.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuItem.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuLabel.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuSubContent.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuSubTrigger.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js.map +1 -1
- package/Grid/Grid.js +1 -1
- package/Grid/Grid.js.map +1 -1
- package/HeaderBar/HeaderBar.stories.js.map +1 -1
- package/ImageEditor/ImageEditor.stories.js.map +1 -1
- package/Input/InputPrimitive.js.map +1 -1
- package/List/List.stories.js.map +1 -1
- package/MultiSelect/primitives/MultiSelectPrimitive.js.map +1 -1
- package/RadioGroup/primitives/RadioGroupPrimitive.js.map +1 -1
- package/RangeSlider/primitives/RangeSliderPrimitive.js.map +1 -1
- package/ScrollArea/ScrollArea.js.map +1 -1
- package/SegmentedControl/SegmentedControl.stories.js.map +1 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.js.map +1 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.stories.js +6 -6
- package/SegmentedControl/primitives/SegmentedControlPrimitive.stories.js.map +1 -1
- package/Select/primitives/SelectPrimitive.js.map +1 -1
- package/Sidebar/Sidebar.stories.js.map +1 -1
- package/Sidebar/components/SidebarProvider.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuProvider.js.map +1 -1
- package/Slider/Slider.js.map +1 -1
- package/Slider/primitives/SliderPrimitive.js.map +1 -1
- package/SteppedProgress/domains/ProgressItemState.js.map +1 -1
- package/Switch/primitives/SwitchPrimitive.js.map +1 -1
- package/Tabs/Tabs.js.map +1 -1
- package/Tabs/components/Context.js.map +1 -1
- package/Toast/components/ToastIcon.js.map +1 -1
- package/Toggle/primitives/TogglePrimitive.js.map +1 -1
- package/ToggleGroup/primitives/ToggleGroupPrimitive.js.map +1 -1
- package/Tooltip/Tooltip.js.map +1 -1
- package/Tree/Tree.js.map +1 -1
- package/Widget/components/WidgetActionsContext.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl/SegmentedControl.stories.js","sources":["../../src/SegmentedControl/SegmentedControl.stories.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { ReactComponent as LockIcon } from \"@webiny/icons/notifications.svg\";\nimport { ReactComponent as PersonIcon } from \"@webiny/icons/person.svg\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { SegmentedControl } from \"./SegmentedControl.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { Button } from \"~/Button/index.js\";\nimport { useSegmentedTabs } from \"./SegmentedControlTabsContext.js\";\n\nconst meta: Meta<typeof SegmentedControl> = {\n title: \"Components/Form/SegmentedControl\",\n component: SegmentedControl\n};\n\nexport default meta;\ntype Story = StoryObj<typeof SegmentedControl>;\n\nconst items = [\n { label: \"Item\", value: \"item1\" },\n { label: \"Item\", value: \"item2\" },\n { label: \"Item\", value: \"item3\" },\n { label: \"Item\", value: \"item4\" }\n];\n\nconst itemsWithIcons = [\n { label: \"Item 1\", value: \"item1\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item2\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item3\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item4\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> }\n];\n\nexport const Default: Story = {\n render: args => {\n const [value, setValue] = useState(args.value);\n return <SegmentedControl {...args} value={value} onChange={value => setValue(value)} />;\n },\n args: {\n items: itemsWithIcons\n }\n};\n\nexport const VariantLight: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return <SegmentedControl items={items} value={value} onChange={setValue} variant=\"light\" />;\n }\n};\n\nexport const VariantDimmed: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <SegmentedControl items={items} value={value} onChange={setValue} variant=\"dimmed\" />\n );\n }\n};\n\nexport const VariantGhost: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"p-md rounded-md\">\n <SegmentedControl items={items} value={value} onChange={setValue} variant=\"ghost\" />\n </div>\n );\n }\n};\n\nexport const WithFormComponent: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"space-y-lg\">\n <SegmentedControl\n label=\"Select an option\"\n description=\"Choose one of the available options\"\n items={items}\n value={value}\n onChange={setValue}\n />\n <SegmentedControl\n label=\"With error\"\n items={items}\n value={value}\n onChange={setValue}\n validation={{\n isValid: false,\n message: \"This field is required\"\n }}\n />\n <SegmentedControl\n label=\"Disabled\"\n items={items}\n value={value}\n onChange={setValue}\n disabled\n />\n </div>\n );\n }\n};\n\nexport const FullWidth: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"w-[500px]\">\n <SegmentedControl items={items} value={value} onChange={setValue} fullWidth />\n </div>\n );\n }\n};\n\nexport const Disabled: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"space-y-md\">\n <div>\n <h3 className=\"text-lg font-semibold mb-sm\">Fully Disabled</h3>\n <SegmentedControl items={items} value={value} onChange={setValue} disabled />\n </div>\n <div>\n <h3 className=\"text-lg font-semibold mb-sm\">Partially Disabled</h3>\n <SegmentedControl\n items={[\n { label: \"Item\", value: \"item1\" },\n { label: \"Item (disabled)\", value: \"item2\", disabled: true },\n { label: \"Item\", value: \"item3\" },\n { label: \"Item (disabled)\", value: \"item4\", disabled: true }\n ]}\n value={value}\n onChange={setValue}\n />\n </div>\n </div>\n );\n }\n};\n\n// SegmentedControl.Tabs stories\n\nexport const TabsDefault: Story = {\n render: () => (\n <SegmentedControl.Tabs>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n icon={<Icon icon={<PersonIcon />} label={\"Account\"} />}\n content={<div className={\"p-md\"}>{\"Account content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n icon={<Icon icon={<LockIcon />} label={\"Security\"} />}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"preferences\"}\n trigger={\"Preferences\"}\n icon={<Icon icon={<SettingsIcon />} label={\"Preferences\"} />}\n content={<div className={\"p-md\"}>{\"Preferences content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n\nexport const TabsDimmed: Story = {\n render: () => (\n <SegmentedControl.Tabs variant={\"dimmed\"}>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n content={<div className={\"p-md\"}>{\"Account content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"preferences\"}\n trigger={\"Preferences\"}\n content={<div className={\"p-md\"}>{\"Preferences content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n\nconst SwitchFromContent = () => {\n const { setActiveTab } = useSegmentedTabs();\n return (\n <div className={\"p-md flex flex-col gap-sm\"}>\n <p>{\"Account content\"}</p>\n <Button\n variant={\"secondary\"}\n text={\"Go to Security\"}\n onClick={() => setActiveTab(\"security\")}\n />\n </div>\n );\n};\n\nexport const TabsProgrammaticSwitch: Story = {\n render: () => (\n <SegmentedControl.Tabs variant={\"dimmed\"}>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n content={<SwitchFromContent />}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n"],"names":["meta","SegmentedControl","items","itemsWithIcons","Icon","LockIcon","Default","args","value","setValue","useState","VariantLight","VariantDimmed","VariantGhost","WithFormComponent","FullWidth","Disabled","TabsDefault","PersonIcon","SettingsIcon","TabsDimmed","SwitchFromContent","setActiveTab","useSegmentedTabs","Button","TabsProgrammaticSwitch"],"mappings":";;;;;;;;AAUA,MAAMA,OAAsC;IACxC,OAAO;IACP,WAAWC;AACf;AAEA,iCAAeD;AAGf,MAAME,QAAQ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,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC,WAAG,kCACJ,oBAACC,QAAMA;QACH,SAAS;QACT,MAAM;QACN,SAAS,IAAMF,aAAa;;AAI5C;AAEO,MAAMG,yBAAgC;IACzC,QAAQ,kBACJ,oBAACxB,iBAAiB,IAAI;YAAC,SAAS;yBAC5B,oBAACA,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAACoB,mBAAiBA;0BAE/B,oBAACpB,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAAC;gBAAI,WAAW;eAAS;;AAIlD"}
|
|
1
|
+
{"version":3,"file":"SegmentedControl/SegmentedControl.stories.js","sources":["../../src/SegmentedControl/SegmentedControl.stories.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { ReactComponent as LockIcon } from \"@webiny/icons/notifications.svg\";\nimport { ReactComponent as PersonIcon } from \"@webiny/icons/person.svg\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { SegmentedControl } from \"./SegmentedControl.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { Button } from \"~/Button/index.js\";\nimport { useSegmentedTabs } from \"./SegmentedControlTabsContext.js\";\n\nconst meta: Meta<typeof SegmentedControl> = {\n title: \"Components/Form/SegmentedControl\",\n component: SegmentedControl\n};\n\nexport default meta;\ntype Story = StoryObj<typeof SegmentedControl>;\n\nconst items = [\n { label: \"Item\", value: \"item1\" },\n { label: \"Item\", value: \"item2\" },\n { label: \"Item\", value: \"item3\" },\n { label: \"Item\", value: \"item4\" }\n];\n\nconst itemsWithIcons = [\n { label: \"Item 1\", value: \"item1\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item2\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item3\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 1\", value: \"item4\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> }\n];\n\nexport const Default: Story = {\n render: args => {\n const [value, setValue] = useState(args.value);\n return <SegmentedControl {...args} value={value} onChange={value => setValue(value)} />;\n },\n args: {\n items: itemsWithIcons\n }\n};\n\nexport const VariantLight: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return <SegmentedControl items={items} value={value} onChange={setValue} variant=\"light\" />;\n }\n};\n\nexport const VariantDimmed: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <SegmentedControl items={items} value={value} onChange={setValue} variant=\"dimmed\" />\n );\n }\n};\n\nexport const VariantGhost: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"p-md rounded-md\">\n <SegmentedControl items={items} value={value} onChange={setValue} variant=\"ghost\" />\n </div>\n );\n }\n};\n\nexport const WithFormComponent: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"space-y-lg\">\n <SegmentedControl\n label=\"Select an option\"\n description=\"Choose one of the available options\"\n items={items}\n value={value}\n onChange={setValue}\n />\n <SegmentedControl\n label=\"With error\"\n items={items}\n value={value}\n onChange={setValue}\n validation={{\n isValid: false,\n message: \"This field is required\"\n }}\n />\n <SegmentedControl\n label=\"Disabled\"\n items={items}\n value={value}\n onChange={setValue}\n disabled\n />\n </div>\n );\n }\n};\n\nexport const FullWidth: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"w-[500px]\">\n <SegmentedControl items={items} value={value} onChange={setValue} fullWidth />\n </div>\n );\n }\n};\n\nexport const Disabled: Story = {\n render: () => {\n const [value, setValue] = useState(\"item1\");\n\n return (\n <div className=\"space-y-md\">\n <div>\n <h3 className=\"text-lg font-semibold mb-sm\">Fully Disabled</h3>\n <SegmentedControl items={items} value={value} onChange={setValue} disabled />\n </div>\n <div>\n <h3 className=\"text-lg font-semibold mb-sm\">Partially Disabled</h3>\n <SegmentedControl\n items={[\n { label: \"Item\", value: \"item1\" },\n { label: \"Item (disabled)\", value: \"item2\", disabled: true },\n { label: \"Item\", value: \"item3\" },\n { label: \"Item (disabled)\", value: \"item4\", disabled: true }\n ]}\n value={value}\n onChange={setValue}\n />\n </div>\n </div>\n );\n }\n};\n\n// SegmentedControl.Tabs stories\n\nexport const TabsDefault: Story = {\n render: () => (\n <SegmentedControl.Tabs>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n icon={<Icon icon={<PersonIcon />} label={\"Account\"} />}\n content={<div className={\"p-md\"}>{\"Account content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n icon={<Icon icon={<LockIcon />} label={\"Security\"} />}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"preferences\"}\n trigger={\"Preferences\"}\n icon={<Icon icon={<SettingsIcon />} label={\"Preferences\"} />}\n content={<div className={\"p-md\"}>{\"Preferences content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n\nexport const TabsDimmed: Story = {\n render: () => (\n <SegmentedControl.Tabs variant={\"dimmed\"}>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n content={<div className={\"p-md\"}>{\"Account content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n <SegmentedControl.Tabs.Tab\n value={\"preferences\"}\n trigger={\"Preferences\"}\n content={<div className={\"p-md\"}>{\"Preferences content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n\nconst SwitchFromContent = () => {\n const { setActiveTab } = useSegmentedTabs();\n return (\n <div className={\"p-md flex flex-col gap-sm\"}>\n <p>{\"Account content\"}</p>\n <Button\n variant={\"secondary\"}\n text={\"Go to Security\"}\n onClick={() => setActiveTab(\"security\")}\n />\n </div>\n );\n};\n\nexport const TabsProgrammaticSwitch: Story = {\n render: () => (\n <SegmentedControl.Tabs variant={\"dimmed\"}>\n <SegmentedControl.Tabs.Tab\n value={\"account\"}\n trigger={\"Account\"}\n content={<SwitchFromContent />}\n />\n <SegmentedControl.Tabs.Tab\n value={\"security\"}\n trigger={\"Security\"}\n content={<div className={\"p-md\"}>{\"Security content\"}</div>}\n />\n </SegmentedControl.Tabs>\n )\n};\n"],"names":["meta","SegmentedControl","items","itemsWithIcons","Icon","LockIcon","Default","args","value","setValue","useState","VariantLight","VariantDimmed","VariantGhost","WithFormComponent","FullWidth","Disabled","TabsDefault","PersonIcon","SettingsIcon","TabsDimmed","SwitchFromContent","setActiveTab","useSegmentedTabs","Button","TabsProgrammaticSwitch"],"mappings":";;;;;;;;AAUA,MAAMA,OAAsC;IACxC,OAAO;IACP,WAAWC;AACf;AAEA,iCAAeD;AAGf,MAAME,QAAQ;IACV;QAAE,OAAO;QAAQ,OAAO;IAAQ;IAChC;QAAE,OAAO;QAAQ,OAAO;IAAQ;IAChC;QAAE,OAAO;QAAQ,OAAO;IAAQ;IAChC;QAAE,OAAO;QAAQ,OAAO;IAAQ;CACnC;AAED,MAAMC,iBAAiB;IACnB;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACC,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,M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S,oBAAC;gBAAI,WAAW;eAAS;0BAEtC,oBAACJ,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,oBAAM,oBAACG,MAAIA;gBAAC,oBAAM,oBAACe,6BAAYA;gBAAK,OAAO;;YAC3C,uBAAS,oBAAC;gBAAI,WAAW;eAAS;;AAIlD;AAEO,MAAMC,aAAoB;IAC7B,QAAQ,kBACJ,oBAACnB,iBAAiB,IAAI;YAAC,SAAS;yBAC5B,oBAACA,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAAC;gBAAI,WAAW;eAAS;0BAEtC,oBAACA,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAAC;gBAAI,WAAW;eAAS;0BAEtC,oBAACA,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAAC;gBAAI,WAAW;eAAS;;AAIlD;AAEA,MAAMoB,oBAAoB;IACtB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC,WAAG,kCACJ,oBAACC,QAAMA;QACH,SAAS;QACT,MAAM;QACN,SAAS,IAAMF,aAAa;;AAI5C;AAEO,MAAMG,yBAAgC;IACzC,QAAQ,kBACJ,oBAACxB,iBAAiB,IAAI;YAAC,SAAS;yBAC5B,oBAACA,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAACoB,mBAAAA;0BAEd,oBAACpB,iBAAiB,IAAI,CAAC,GAAG;YACtB,OAAO;YACP,SAAS;YACT,uBAAS,oBAAC;gBAAI,WAAW;eAAS;;AAIlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl/primitives/SegmentedControlPrimitive.js","sources":["../../../src/SegmentedControl/primitives/SegmentedControlPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, type VariantProps } from \"~/utils.js\";\nimport type {\n SegmentedControlItemParams,\n SegmentedControlItemFormatted\n} from \"../domains/index.js\";\nimport { useSegmentedControl } from \"./useSegmentedControl.js\";\nimport { Icon } from \"~/Icon/index.js\";\n\n/**\n * Segmented Control Item Button\n */\nconst segmentedControlItemVariants = cva(\n [\n \"inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer relative rounded-md\",\n \"text-md px-sm-extra py-xs [&>svg]:size-md gap-xs\",\n \"focus-visible:outline-none focus-visible:ring-md focus-visible:ring-primary-dimmed focus-visible:ring-offset-0\",\n \"disabled:opacity-50 disabled:pointer-events-none disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n variant: {\n light: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:text-neutral-primary data-[state=active]:fill-neutral-xstrong data-[state=active]:bg-neutral-base/80\",\n \"hover:data-[state=inactive]:text-neutral-primary\",\n \"hover:data-[state=inactive]:bg-neutral-base/80\",\n \"active:data-[state=inactive]:bg-neutral-base/80\"\n ],\n dimmed: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:text-neutral-primary data-[state=active]:fill-neutral-xstrong data-[state=active]:bg-neutral-base/80\",\n \"hover:data-[state=inactive]:text-neutral-primary\",\n \"hover:data-[state=inactive]:bg-neutral-base/80\",\n \"active:data-[state=inactive]:bg-neutral-base/80\"\n ],\n ghost: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:bg-neutral-dark/5\",\n \"hover:data-[state=inactive]:bg-neutral-dark/5\",\n \"active:data-[state=inactive]:bg-neutral-dark/5\"\n ]\n }\n },\n defaultVariants: {\n variant: \"light\"\n }\n }\n);\n\nconst segmentedControlRootVariants = cva(\"inline-flex rounded-md p-xxs gap-xs\", {\n variants: {\n variant: {\n light: \"bg-neutral-light\",\n dimmed: \"bg-neutral-dimmed\",\n ghost: \"\"\n }\n },\n defaultVariants: {\n variant: \"light\"\n }\n});\n\ninterface SegmentedControlItemProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"value\"\n> {\n item: SegmentedControlItemFormatted;\n isActive: boolean;\n onValueChange: (value: string) => void;\n variant?: VariantProps<typeof segmentedControlItemVariants>[\"variant\"];\n}\n\nconst SegmentedControlItemButton = ({\n item,\n isActive,\n onValueChange,\n variant,\n className,\n ...props\n}: SegmentedControlItemProps) => {\n return (\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked={isActive}\n data-state={isActive ? \"active\" : \"inactive\"}\n disabled={item.disabled}\n onClick={() => onValueChange(item.value)}\n className={cn(segmentedControlItemVariants({ variant }), className)}\n {...props}\n >\n {item.icon && (\n <Icon\n icon={item.icon}\n size={\"sm\"}\n label={String(item.label)}\n color={\"neutral-strong\"}\n />\n )}\n {item.label}\n </button>\n );\n};\n\n/**\n * Segmented Control Primitive\n */\ninterface SegmentedControlPrimitiveProps {\n items: SegmentedControlItemParams[];\n /**\n * Callback triggered when the selected value changes.\n */\n onChange?: (value: string) => void;\n /**\n * The selected value.\n */\n value?: string;\n /**\n * Visual style variant.\n */\n variant?: VariantProps<typeof segmentedControlItemVariants>[\"variant\"];\n /**\n * Additional class name.\n */\n className?: string;\n /**\n * Disabled state for all items.\n */\n disabled?: boolean;\n /**\n * Stretch the control to fill its container width, with buttons sharing space equally.\n */\n fullWidth?: boolean;\n}\n\ninterface SegmentedControlVm {\n items: SegmentedControlItemFormatted[];\n}\n\ninterface SegmentedControlRendererProps extends SegmentedControlPrimitiveProps {\n items: SegmentedControlItemFormatted[];\n changeValue: (value: string) => void;\n}\n\nconst SegmentedControlRenderer = ({\n items,\n changeValue,\n value,\n variant = \"light\",\n className,\n disabled,\n fullWidth\n}: SegmentedControlRendererProps) => {\n return (\n <div\n role=\"radiogroup\"\n className={cn(\n segmentedControlRootVariants({ variant }),\n fullWidth && \"flex w-full\",\n className\n )}\n >\n {items.map(item => (\n <SegmentedControlItemButton\n key={item.id}\n item={{ ...item, disabled: disabled || item.disabled }}\n isActive={value === item.value}\n onValueChange={changeValue}\n variant={variant}\n className={fullWidth ? \"flex-1\" : undefined}\n />\n ))}\n </div>\n );\n};\n\n/**\n * Segmented Control Primitive Component\n */\nconst SegmentedControlPrimitive = (props: SegmentedControlPrimitiveProps) => {\n const { vm, changeValue } = useSegmentedControl(props);\n return <SegmentedControlRenderer {...props} items={vm.items} changeValue={changeValue} />;\n};\n\nexport {\n SegmentedControlPrimitive,\n SegmentedControlRenderer,\n type SegmentedControlPrimitiveProps,\n type SegmentedControlVm\n};\n"],"names":["segmentedControlItemVariants","cva","segmentedControlRootVariants","SegmentedControlItemButton","item","isActive","onValueChange","variant","className","props","cn","Icon","String","SegmentedControlRenderer","items","changeValue","value","disabled","fullWidth","undefined","SegmentedControlPrimitive","vm","useSegmentedControl"],"mappings":";;;;AAYA,MAAMA,+BAA+BC,IACjC;IACI;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,SAAS;YACL,OAAO;gBACH;gBACA;gBACA;gBACA;gBACA;aACH;YACD,QAAQ;gBACJ;gBACA;gBACA;gBACA;gBACA;aACH;YACD,OAAO;gBACH;gBACA;gBACA;gBACA;aACH;QACL;IACJ;IACA,iBAAiB;QACb,SAAS;IACb;AACJ;AAGJ,MAAMC,+BAA+BD,IAAI,uCAAuC;IAC5E,UAAU;QACN,SAAS;YACL,OAAO;YACP,QAAQ;YACR,OAAO;QACX;IACJ;IACA,iBAAiB;QACb,SAAS;IACb;AACJ;AAYA,MAAME,6BAA6B,CAAC,EAChCC,IAAI,EACJC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACT,GAAGC,OACqB,GACjB,WAAP,GACI,sCAAC;QACG,MAAK;QACL,MAAK;QACL,gBAAcJ;QACd,cAAYA,WAAW,WAAW;QAClC,UAAUD,KAAK,QAAQ;QACvB,SAAS,IAAME,cAAcF,KAAK,KAAK;QACvC,WAAWM,GAAGV,6BAA6B;YAAEO;QAAQ,IAAIC;QACxD,GAAGC,KAAK;OAERL,KAAK,IAAI,IAAI,WAAJ,GACN,sCAACO,MAAIA;QACD,MAAMP,KAAK,IAAI;QACf,MAAM;QACN,OAAOQ,OAAOR,KAAK,KAAK;QACxB,OAAO;QAGdA,KAAK,KAAK;AA6CvB,MAAMS,2BAA2B,CAAC,EAC9BC,KAAK,EACLC,WAAW,EACXC,KAAK,EACLT,UAAU,OAAO,EACjBC,SAAS,EACTS,QAAQ,EACRC,SAAS,EACmB,GACrB,WAAP,GACI,sCAAC;QACG,MAAK;QACL,WAAWR,GACPR,6BAA6B;YAAEK;QAAQ,IACvCW,aAAa,eACbV;OAGHM,MAAM,GAAG,CAACV,CAAAA,OAAAA,WAAAA,GACP,sCAACD,
|
|
1
|
+
{"version":3,"file":"SegmentedControl/primitives/SegmentedControlPrimitive.js","sources":["../../../src/SegmentedControl/primitives/SegmentedControlPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, type VariantProps } from \"~/utils.js\";\nimport type {\n SegmentedControlItemParams,\n SegmentedControlItemFormatted\n} from \"../domains/index.js\";\nimport { useSegmentedControl } from \"./useSegmentedControl.js\";\nimport { Icon } from \"~/Icon/index.js\";\n\n/**\n * Segmented Control Item Button\n */\nconst segmentedControlItemVariants = cva(\n [\n \"inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer relative rounded-md\",\n \"text-md px-sm-extra py-xs [&>svg]:size-md gap-xs\",\n \"focus-visible:outline-none focus-visible:ring-md focus-visible:ring-primary-dimmed focus-visible:ring-offset-0\",\n \"disabled:opacity-50 disabled:pointer-events-none disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n variant: {\n light: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:text-neutral-primary data-[state=active]:fill-neutral-xstrong data-[state=active]:bg-neutral-base/80\",\n \"hover:data-[state=inactive]:text-neutral-primary\",\n \"hover:data-[state=inactive]:bg-neutral-base/80\",\n \"active:data-[state=inactive]:bg-neutral-base/80\"\n ],\n dimmed: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:text-neutral-primary data-[state=active]:fill-neutral-xstrong data-[state=active]:bg-neutral-base/80\",\n \"hover:data-[state=inactive]:text-neutral-primary\",\n \"hover:data-[state=inactive]:bg-neutral-base/80\",\n \"active:data-[state=inactive]:bg-neutral-base/80\"\n ],\n ghost: [\n \"text-neutral-strong fill-neutral-xstrong\",\n \"data-[state=active]:bg-neutral-dark/5\",\n \"hover:data-[state=inactive]:bg-neutral-dark/5\",\n \"active:data-[state=inactive]:bg-neutral-dark/5\"\n ]\n }\n },\n defaultVariants: {\n variant: \"light\"\n }\n }\n);\n\nconst segmentedControlRootVariants = cva(\"inline-flex rounded-md p-xxs gap-xs\", {\n variants: {\n variant: {\n light: \"bg-neutral-light\",\n dimmed: \"bg-neutral-dimmed\",\n ghost: \"\"\n }\n },\n defaultVariants: {\n variant: \"light\"\n }\n});\n\ninterface SegmentedControlItemProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"value\"\n> {\n item: SegmentedControlItemFormatted;\n isActive: boolean;\n onValueChange: (value: string) => void;\n variant?: VariantProps<typeof segmentedControlItemVariants>[\"variant\"];\n}\n\nconst SegmentedControlItemButton = ({\n item,\n isActive,\n onValueChange,\n variant,\n className,\n ...props\n}: SegmentedControlItemProps) => {\n return (\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked={isActive}\n data-state={isActive ? \"active\" : \"inactive\"}\n disabled={item.disabled}\n onClick={() => onValueChange(item.value)}\n className={cn(segmentedControlItemVariants({ variant }), className)}\n {...props}\n >\n {item.icon && (\n <Icon\n icon={item.icon}\n size={\"sm\"}\n label={String(item.label)}\n color={\"neutral-strong\"}\n />\n )}\n {item.label}\n </button>\n );\n};\n\n/**\n * Segmented Control Primitive\n */\ninterface SegmentedControlPrimitiveProps {\n items: SegmentedControlItemParams[];\n /**\n * Callback triggered when the selected value changes.\n */\n onChange?: (value: string) => void;\n /**\n * The selected value.\n */\n value?: string;\n /**\n * Visual style variant.\n */\n variant?: VariantProps<typeof segmentedControlItemVariants>[\"variant\"];\n /**\n * Additional class name.\n */\n className?: string;\n /**\n * Disabled state for all items.\n */\n disabled?: boolean;\n /**\n * Stretch the control to fill its container width, with buttons sharing space equally.\n */\n fullWidth?: boolean;\n}\n\ninterface SegmentedControlVm {\n items: SegmentedControlItemFormatted[];\n}\n\ninterface SegmentedControlRendererProps extends SegmentedControlPrimitiveProps {\n items: SegmentedControlItemFormatted[];\n changeValue: (value: string) => void;\n}\n\nconst SegmentedControlRenderer = ({\n items,\n changeValue,\n value,\n variant = \"light\",\n className,\n disabled,\n fullWidth\n}: SegmentedControlRendererProps) => {\n return (\n <div\n role=\"radiogroup\"\n className={cn(\n segmentedControlRootVariants({ variant }),\n fullWidth && \"flex w-full\",\n className\n )}\n >\n {items.map(item => (\n <SegmentedControlItemButton\n key={item.id}\n item={{ ...item, disabled: disabled || item.disabled }}\n isActive={value === item.value}\n onValueChange={changeValue}\n variant={variant}\n className={fullWidth ? \"flex-1\" : undefined}\n />\n ))}\n </div>\n );\n};\n\n/**\n * Segmented Control Primitive Component\n */\nconst SegmentedControlPrimitive = (props: SegmentedControlPrimitiveProps) => {\n const { vm, changeValue } = useSegmentedControl(props);\n return <SegmentedControlRenderer {...props} items={vm.items} changeValue={changeValue} />;\n};\n\nexport {\n SegmentedControlPrimitive,\n SegmentedControlRenderer,\n type SegmentedControlPrimitiveProps,\n type SegmentedControlVm\n};\n"],"names":["segmentedControlItemVariants","cva","segmentedControlRootVariants","SegmentedControlItemButton","item","isActive","onValueChange","variant","className","props","cn","Icon","String","SegmentedControlRenderer","items","changeValue","value","disabled","fullWidth","undefined","SegmentedControlPrimitive","vm","useSegmentedControl"],"mappings":";;;;AAYA,MAAMA,+BAA+BC,IACjC;IACI;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,SAAS;YACL,OAAO;gBACH;gBACA;gBACA;gBACA;gBACA;aACH;YACD,QAAQ;gBACJ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CAACX;IAC/B,MAAM,EAAEY,EAAE,EAAEN,WAAW,EAAE,GAAGO,oBAAoBb;IAChD,OAAO,WAAP,GAAO,sCAACI,0BAAAA;QAA0B,GAAGJ,KAAK;QAAE,OAAOY,GAAG,KAAK;QAAE,aAAaN;;AAC9E"}
|
|
@@ -76,12 +76,12 @@ const itemsWithIcons = [
|
|
|
76
76
|
];
|
|
77
77
|
const Default = {
|
|
78
78
|
args: {
|
|
79
|
-
items
|
|
79
|
+
items
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
const WithDefaultOption = {
|
|
83
83
|
args: {
|
|
84
|
-
items
|
|
84
|
+
items,
|
|
85
85
|
value: "item2"
|
|
86
86
|
}
|
|
87
87
|
};
|
|
@@ -93,14 +93,14 @@ const WithIcons = {
|
|
|
93
93
|
};
|
|
94
94
|
const VariantLight = {
|
|
95
95
|
args: {
|
|
96
|
-
items
|
|
96
|
+
items,
|
|
97
97
|
value: "item1",
|
|
98
98
|
variant: "light"
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
const VariantDimmed = {
|
|
102
102
|
args: {
|
|
103
|
-
items
|
|
103
|
+
items,
|
|
104
104
|
value: "item1",
|
|
105
105
|
variant: "dimmed"
|
|
106
106
|
}
|
|
@@ -121,7 +121,7 @@ const VariantGhost = {
|
|
|
121
121
|
};
|
|
122
122
|
const Disabled = {
|
|
123
123
|
args: {
|
|
124
|
-
items
|
|
124
|
+
items,
|
|
125
125
|
value: "item2",
|
|
126
126
|
disabled: true
|
|
127
127
|
}
|
|
@@ -153,7 +153,7 @@ const PartiallyDisabled = {
|
|
|
153
153
|
};
|
|
154
154
|
const FullWidth = {
|
|
155
155
|
args: {
|
|
156
|
-
items
|
|
156
|
+
items,
|
|
157
157
|
value: "item1",
|
|
158
158
|
fullWidth: true
|
|
159
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl/primitives/SegmentedControlPrimitive.stories.js","sources":["../../../src/SegmentedControl/primitives/SegmentedControlPrimitive.stories.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { SegmentedControlPrimitive } from \"./SegmentedControlPrimitive.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { ReactComponent as LockIcon } from \"@webiny/icons/notifications.svg\";\n\nconst meta: Meta<typeof SegmentedControlPrimitive> = {\n title: \"Components/Form Primitives/SegmentedControl\",\n component: SegmentedControlPrimitive,\n parameters: {\n layout: \"padded\"\n },\n render: args => {\n const [value, setValue] = useState(args.value);\n return (\n <div className={\"w-full\"}>\n <SegmentedControlPrimitive\n {...args}\n value={value}\n onChange={value => setValue(value)}\n />\n <div className={\"mt-4 text-center\"}>\n Current selected value: <pre>{value}</pre>\n </div>\n </div>\n );\n }\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof SegmentedControlPrimitive>;\n\nconst items = [\n { label: \"Item 1\", value: \"item1\" },\n { label: \"Item 2\", value: \"item2\" },\n { label: \"Item 3\", value: \"item3\" },\n { label: \"Item 4\", value: \"item4\" }\n];\n\nconst itemsWithIcons = [\n { label: \"Item 1\", value: \"item1\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 2\", value: \"item2\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 3\", value: \"item3\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 4\", value: \"item4\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> }\n];\n\nexport const Default: Story = {\n args: {\n items\n }\n};\n\nexport const WithDefaultOption: Story = {\n args: {\n items,\n value: \"item2\"\n }\n};\n\nexport const WithIcons: Story = {\n args: {\n items: itemsWithIcons,\n value: \"item1\"\n }\n};\n\nexport const VariantLight: Story = {\n args: {\n items,\n value: \"item1\",\n variant: \"light\"\n }\n};\n\nexport const VariantDimmed: Story = {\n args: {\n items,\n value: \"item1\",\n variant: \"dimmed\"\n }\n};\n\nexport const VariantGhost: Story = {\n render: args => {\n const [value, setValue] = useState(args.value || \"item1\");\n return (\n <div className=\"p-md rounded-md bg-neutral-light\">\n <SegmentedControlPrimitive\n {...args}\n items={items}\n value={value}\n onChange={value => setValue(value)}\n variant=\"ghost\"\n />\n </div>\n );\n }\n};\n\nexport const Disabled: Story = {\n args: {\n items,\n value: \"item2\",\n disabled: true\n }\n};\n\nexport const PartiallyDisabled: Story = {\n args: {\n items: [\n { label: \"Item 1\", value: \"item1\" },\n { label: \"Item 2 (disabled)\", value: \"item2\", disabled: true },\n { label: \"Item 3\", value: \"item3\" },\n { label: \"Item 4 (disabled)\", value: \"item4\", disabled: true }\n ],\n value: \"item1\"\n }\n};\n\nexport const FullWidth: Story = {\n args: {\n items,\n value: \"item1\",\n fullWidth: true\n }\n};\n"],"names":["meta","SegmentedControlPrimitive","args","value","setValue","useState","items","itemsWithIcons","Icon","LockIcon","Default","WithDefaultOption","WithIcons","VariantLight","VariantDimmed","VariantGhost","Disabled","PartiallyDisabled","FullWidth"],"mappings":";;;;AAMA,MAAMA,OAA+C;IACjD,OAAO;IACP,WAAWC;IACX,YAAY;QACR,QAAQ;IACZ;IACA,QAAQC,CAAAA;QACJ,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAASH,KAAK,KAAK;QAC7C,OAAO,WAAP,GACI,oBAAC;YAAI,WAAW;yBACZ,oBAACD,2BAAyBA;YACrB,GAAGC,IAAI;YACR,OAAOC;YACP,UAAUA,CAAAA,QAASC,SAASD;0BAEhC,oBAAC;YAAI,WAAW;WAAoB,0CACR,oBAAC,aAAKA;IAI9C;AACJ;AAEA,0CAAeH;AAIf,MAAMM,QAAQ;IACV;QAAE,OAAO;QAAU,OAAO;IAAQ;IAClC;QAAE,OAAO;QAAU,OAAO;IAAQ;IAClC;QAAE,OAAO;QAAU,OAAO;IAAQ;IAClC;QAAE,OAAO;QAAU,OAAO;IAAQ;CACrC;AAED,MAAMC,iBAAiB;IACnB;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACC,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;IACnF;QAAE,OAAO;QAAU,OAAO;QAAS,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACC,gBAAQA;YAAK,OAAM;;IAAU;CACtF;AAEM,MAAMC,UAAiB;IAC1B,MAAM;QACFJ
|
|
1
|
+
{"version":3,"file":"SegmentedControl/primitives/SegmentedControlPrimitive.stories.js","sources":["../../../src/SegmentedControl/primitives/SegmentedControlPrimitive.stories.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { SegmentedControlPrimitive } from \"./SegmentedControlPrimitive.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { ReactComponent as LockIcon } from \"@webiny/icons/notifications.svg\";\n\nconst meta: Meta<typeof SegmentedControlPrimitive> = {\n title: \"Components/Form Primitives/SegmentedControl\",\n component: SegmentedControlPrimitive,\n parameters: {\n layout: \"padded\"\n },\n render: args => {\n const [value, setValue] = useState(args.value);\n return (\n <div className={\"w-full\"}>\n <SegmentedControlPrimitive\n {...args}\n value={value}\n onChange={value => setValue(value)}\n />\n <div className={\"mt-4 text-center\"}>\n Current selected value: <pre>{value}</pre>\n </div>\n </div>\n );\n }\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof SegmentedControlPrimitive>;\n\nconst items = [\n { label: \"Item 1\", value: \"item1\" },\n { label: \"Item 2\", value: \"item2\" },\n { label: \"Item 3\", value: \"item3\" },\n { label: \"Item 4\", value: \"item4\" }\n];\n\nconst itemsWithIcons = [\n { label: \"Item 1\", value: \"item1\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 2\", value: \"item2\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 3\", value: \"item3\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> },\n { label: \"Item 4\", value: \"item4\", icon: <Icon icon={<LockIcon />} label=\"Lock\" /> }\n];\n\nexport const Default: Story = {\n args: {\n items\n }\n};\n\nexport const WithDefaultOption: Story = {\n args: {\n items,\n value: \"item2\"\n }\n};\n\nexport const WithIcons: Story = {\n args: {\n items: itemsWithIcons,\n value: \"item1\"\n }\n};\n\nexport const VariantLight: Story = {\n args: {\n items,\n value: \"item1\",\n variant: \"light\"\n }\n};\n\nexport const VariantDimmed: Story = {\n args: {\n items,\n value: \"item1\",\n variant: \"dimmed\"\n }\n};\n\nexport const VariantGhost: Story = {\n render: args => {\n const [value, setValue] = useState(args.value || \"item1\");\n return (\n <div className=\"p-md rounded-md bg-neutral-light\">\n <SegmentedControlPrimitive\n {...args}\n items={items}\n value={value}\n onChange={value => setValue(value)}\n variant=\"ghost\"\n />\n </div>\n );\n }\n};\n\nexport const Disabled: Story = {\n args: {\n items,\n value: \"item2\",\n disabled: true\n }\n};\n\nexport const PartiallyDisabled: Story = {\n args: {\n items: [\n { label: \"Item 1\", value: \"item1\" },\n { label: \"Item 2 (disabled)\", value: \"item2\", disabled: true },\n { label: \"Item 3\", value: \"item3\" },\n { label: \"Item 4 (disabled)\", value: \"item4\", disabled: true }\n ],\n value: \"item1\"\n }\n};\n\nexport const FullWidth: Story = {\n args: {\n items,\n value: \"item1\",\n fullWidth: true\n }\n};\n"],"names":["meta","SegmentedControlPrimitive","args","value","setValue","useState","items","itemsWithIcons","Icon","LockIcon","Default","WithDefaultOption","WithIcons","VariantLight","VariantDimmed","VariantGhost","Disabled","PartiallyDisabled","FullWidth"],"mappings":";;;;AAMA,MAAMA,OAA+C;IACjD,OAAO;IACP,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AS;IACb;AACJ;AAEO,MAAMQ,gBAAuB;IAChC,MAAM;QACFR;QACA,OAAO;QACP,SAAS;IACb;AACJ;AAEO,MAAMS,eAAsB;IAC/B,QAAQb,CAAAA;QACJ,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAASH,KAAK,KAAK,IAAI;QACjD,OAAO,WAAP,GACI,oBAAC;YAAI,WAAU;yBACX,oBAACD,2BAAyBA;YACrB,GAAGC,IAAI;YACR,OAAOI;YACP,OAAOH;YACP,UAAUA,CAAAA,QAASC,SAASD;YAC5B,SAAQ;;IAIxB;AACJ;AAEO,MAAMa,WAAkB;IAC3B,MAAM;QACFV;QACA,OAAO;QACP,UAAU;IACd;AACJ;AAEO,MAAMW,oBAA2B;IACpC,MAAM;QACF,OAAO;YACH;gBAAE,OAAO;gBAAU,OAAO;YAAQ;YAClC;gBAAE,OAAO;gBAAqB,OAAO;gBAAS,UAAU;YAAK;YAC7D;gBAAE,OAAO;gBAAU,OAAO;YAAQ;YAClC;gBAAE,OAAO;gBAAqB,OAAO;gBAAS,UAAU;YAAK;SAChE;QACD,OAAO;IACX;AACJ;AAEO,MAAMC,YAAmB;IAC5B,MAAM;QACFZ;QACA,OAAO;QACP,WAAW;IACf;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select/primitives/SelectPrimitive.js","sources":["../../../src/Select/primitives/SelectPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { ReactComponent as Close } from \"@webiny/icons/close.svg\";\nimport { Select as SelectPrimitives } from \"radix-ui\";\nimport { type VariantProps } from \"~/utils.js\";\nimport { useSelect } from \"./useSelect.js\";\nimport type { SelectOptionDto, SelectOptionFormatted } from \"../domains/index.js\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport type { selectTriggerVariants } from \"./components/index.js\";\nimport {\n SelectContent,\n SelectItem,\n SelectLabel,\n SelectSeparator,\n SelectTrigger\n} from \"./components/index.js\";\n\nconst SelectRoot = SelectPrimitives.Root;\n\nconst SelectGroup = SelectPrimitives.Group;\n\nconst SelectValue = SelectPrimitives.Value;\n\n/**\n * Trigger\n */\ntype SelectTriggerVm = {\n placeholder: string;\n hasValue: boolean;\n displayResetAction: boolean;\n};\n\ntype SelectTriggerProps = SelectPrimitives.SelectValueProps &\n SelectTriggerVm & {\n size: VariantProps<typeof selectTriggerVariants>[\"size\"];\n variant: VariantProps<typeof selectTriggerVariants>[\"variant\"];\n invalid: VariantProps<typeof selectTriggerVariants>[\"invalid\"];\n startIcon?: React.ReactElement;\n endIcon?: React.ReactElement;\n onValueReset: () => void;\n disabled?: boolean;\n };\n\nconst Trigger = ({\n hasValue,\n size,\n variant,\n startIcon,\n endIcon,\n invalid,\n onValueReset,\n disabled,\n displayResetAction,\n ...props\n}: SelectTriggerProps) => {\n const resetButton = React.useMemo(() => {\n if (!hasValue || !displayResetAction) {\n return undefined;\n }\n\n return (\n <IconButton\n onPointerDown={event => {\n event.stopPropagation();\n onValueReset();\n }}\n icon={\n <span>\n <Icon\n icon={<Close />}\n label={\"Reset\"}\n color={variant === \"ghost-negative\" ? \"neutral-negative\" : \"inherit\"}\n />\n </span>\n }\n size={\"xs\"}\n variant={variant === \"ghost-negative\" ? \"ghost-negative\" : \"secondary\"}\n disabled={disabled}\n asChild\n />\n );\n }, [hasValue, onValueReset, disabled, displayResetAction, variant]);\n\n return (\n <SelectTrigger\n size={size}\n variant={variant}\n invalid={invalid}\n startIcon={startIcon}\n endIcon={endIcon}\n resetButton={resetButton}\n >\n <div className={\"flex-1 text-left truncate\"}>\n <SelectValue {...props} />\n </div>\n </SelectTrigger>\n );\n};\n\n/**\n * SelectOptions\n */\ntype SelectOptionsVm = {\n options: SelectOptionFormatted[];\n};\n\ntype SelectOptionsProps = SelectOptionsVm;\n\nconst SelectOptions = (props: SelectOptionsProps) => {\n const renderOptions = React.useCallback((items: SelectOptionFormatted[]) => {\n return items.map((item, index) => {\n const elements = [];\n\n if (item.options.length > 0) {\n // Render as a group if there are nested options\n elements.push(\n <SelectGroup key={`group-${index}`}>\n <SelectLabel>{item.label}</SelectLabel>\n {renderOptions(item.options)}\n </SelectGroup>\n );\n }\n\n if (item.value) {\n // Render as a select item if there are no nested options\n elements.push(\n <SelectItem\n key={`item-${item.value}`}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </SelectItem>\n );\n }\n\n // Conditionally render the separator if hasSeparator is true\n if (item.separator) {\n elements.push(<SelectSeparator key={`separator-${item.value ?? index}`} />);\n }\n\n return elements;\n });\n }, []);\n\n return <SelectContent>{renderOptions(props.options)}</SelectContent>;\n};\n\n/**\n * SelectRenderer\n */\nexport type SelectRootVm = {\n value: string;\n};\n\ntype SelectRootProps = Omit<SelectPrimitives.SelectProps, \"onValueChange\">;\n\ntype SelectRendererProps = {\n selectRootProps: SelectRootProps;\n selectTriggerProps: Omit<SelectTriggerProps, \"onValueReset\">;\n selectOptionsProps: SelectOptionsProps;\n onValueChange: (value: string) => void;\n onValueReset: () => void;\n};\n\nconst SelectPrimitiveRenderer = ({\n selectRootProps,\n selectTriggerProps,\n selectOptionsProps,\n onValueChange,\n onValueReset\n}: SelectRendererProps) => {\n return (\n <SelectRoot {...selectRootProps} onValueChange={onValueChange}>\n <Trigger {...selectTriggerProps} onValueReset={onValueReset} />\n <SelectOptions {...selectOptionsProps} />\n </SelectRoot>\n );\n};\n\n/**\n * Select\n */\ntype SelectOption = SelectOptionDto | string;\n\ninterface SelectPrimitiveProps {\n /**\n * Whether to display the reset action button.\n */\n displayResetAction?: boolean;\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Icon to display at the end of the select trigger.\n */\n endIcon?: React.ReactElement;\n /**\n * Whether the select input is invalid.\n */\n invalid?: VariantProps<typeof selectTriggerVariants>[\"invalid\"];\n /**\n * Callback function called when the value changes.\n */\n onChange?: (value: string) => void;\n /**\n * Callback function called when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Callback function called when the value is reset.\n */\n onValueReset?: () => void;\n /**\n * Array of options to display in the select dropdown.\n */\n options?: SelectOption[];\n /**\n * Placeholder text to display when no value is selected.\n */\n placeholder?: string;\n /**\n * Size variant of the select trigger.\n */\n size?: VariantProps<typeof selectTriggerVariants>[\"size\"];\n /**\n * Icon to display at the start of the select trigger.\n */\n startIcon?: React.ReactElement;\n /**\n * The value of the select input.\n */\n value?: string;\n /**\n * Style variant of the select trigger.\n */\n variant?: VariantProps<typeof selectTriggerVariants>[\"variant\"];\n}\n\nconst SelectPrimitive = (props: SelectPrimitiveProps) => {\n const { vm, changeValue, resetValue } = useSelect(props);\n const { size, variant, startIcon, endIcon, invalid, disabled, ...selectRootProps } = props;\n\n return (\n <SelectPrimitiveRenderer\n selectRootProps={{ ...selectRootProps, ...vm.selectRoot, disabled }}\n selectTriggerProps={{\n ...vm.selectTrigger,\n size,\n variant,\n startIcon,\n endIcon,\n invalid,\n disabled\n }}\n selectOptionsProps={vm.selectOptions}\n onValueChange={changeValue}\n onValueReset={resetValue}\n />\n );\n};\n\nexport {\n SelectPrimitive,\n type SelectPrimitiveProps,\n type SelectOptionsVm,\n type SelectTriggerVm,\n type SelectOption\n};\n"],"names":["SelectRoot","SelectPrimitives","SelectGroup","SelectValue","Trigger","hasValue","size","variant","startIcon","endIcon","invalid","onValueReset","disabled","displayResetAction","props","resetButton","React","IconButton","event","Icon","Close","SelectTrigger","SelectOptions","renderOptions","items","item","index","elements","SelectLabel","SelectItem","SelectSeparator","SelectContent","SelectPrimitiveRenderer","selectRootProps","selectTriggerProps","selectOptionsProps","onValueChange","SelectPrimitive","vm","changeValue","resetValue","useSelect"],"mappings":";;;;;;;AAiBA,MAAMA,aAAaC,OAAAA,IAAqB;AAExC,MAAMC,cAAcD,OAAAA,KAAsB;AAE1C,MAAME,cAAcF,OAAAA,KAAsB;AAsB1C,MAAMG,UAAU,CAAC,EACbC,QAAQ,EACRC,IAAI,EACJC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,OA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,EACdE,SAAS,IAAI,CAAC,WAAD,GAAC,sCAACG,iBAAeA;gBAAC,KAAK,CAAC,UAAU,EAAEL,KAAK,KAAK,IAAIC,OAAO;;YAG1E,OAAOC;QACX,IACD,EAAE;IAEL,OAAO,WAAP,GAAO,sCAACI,eAAaA,MAAER,cAAcT,MAAM,OAAO;AACtD;AAmBA,MAAMkB,0BAA0B,CAAC,EAC7BC,eAAe,EACfC,kBAAkB,EAClBC,kBAAkB,EAClBC,aAAa,EACbzB,YAAY,EACM,GACX,WAAP,GACI,sCAACX,YAAUA;QAAE,GAAGiC,eAAe;QAAE,eAAeG;qBAC5C,sCAAChC,SAAOA;QAAE,GAAG8B,kBAAkB;QAAE,cAAcvB;sBAC/C,sCAACW,eAAkBa;AAiE/B,MAAME,kBAAkB,CAACvB;IACrB,MAAM,EAAEwB,EAAE,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAGC,UAAU3B;IAClD,MAAM,EAAER,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,OAAO,EAAEC,OAAO,EAAEE,QAAQ,EAAE,GAAGqB,iBAAiB,GAAGnB;IAErF,OAAO,WAAP,GACI,sCAACkB,yBAAuBA;QACpB,iBAAiB;YAAE,GAAGC,eAAe;YAAE,GAAGK,GAAG,UAAU;YAAE1B;QAAS;QAClE,oBAAoB;YAChB,GAAG0B,GAAG,aAAa;YACnBhC;YACAC;YACAC;YACAC;YACAC;YACAE;QACJ;QACA,oBAAoB0B,GAAG,aAAa;QACpC,eAAeC;QACf,cAAcC;;AAG1B"}
|
|
1
|
+
{"version":3,"file":"Select/primitives/SelectPrimitive.js","sources":["../../../src/Select/primitives/SelectPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { ReactComponent as Close } from \"@webiny/icons/close.svg\";\nimport { Select as SelectPrimitives } from \"radix-ui\";\nimport { type VariantProps } from \"~/utils.js\";\nimport { useSelect } from \"./useSelect.js\";\nimport type { SelectOptionDto, SelectOptionFormatted } from \"../domains/index.js\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport type { selectTriggerVariants } from \"./components/index.js\";\nimport {\n SelectContent,\n SelectItem,\n SelectLabel,\n SelectSeparator,\n SelectTrigger\n} from \"./components/index.js\";\n\nconst SelectRoot = SelectPrimitives.Root;\n\nconst SelectGroup = SelectPrimitives.Group;\n\nconst SelectValue = SelectPrimitives.Value;\n\n/**\n * Trigger\n */\ntype SelectTriggerVm = {\n placeholder: string;\n hasValue: boolean;\n displayResetAction: boolean;\n};\n\ntype SelectTriggerProps = SelectPrimitives.SelectValueProps &\n SelectTriggerVm & {\n size: VariantProps<typeof selectTriggerVariants>[\"size\"];\n variant: VariantProps<typeof selectTriggerVariants>[\"variant\"];\n invalid: VariantProps<typeof selectTriggerVariants>[\"invalid\"];\n startIcon?: React.ReactElement;\n endIcon?: React.ReactElement;\n onValueReset: () => void;\n disabled?: boolean;\n };\n\nconst Trigger = ({\n hasValue,\n size,\n variant,\n startIcon,\n endIcon,\n invalid,\n onValueReset,\n disabled,\n displayResetAction,\n ...props\n}: SelectTriggerProps) => {\n const resetButton = React.useMemo(() => {\n if (!hasValue || !displayResetAction) {\n return undefined;\n }\n\n return (\n <IconButton\n onPointerDown={event => {\n event.stopPropagation();\n onValueReset();\n }}\n icon={\n <span>\n <Icon\n icon={<Close />}\n label={\"Reset\"}\n color={variant === \"ghost-negative\" ? \"neutral-negative\" : \"inherit\"}\n />\n </span>\n }\n size={\"xs\"}\n variant={variant === \"ghost-negative\" ? \"ghost-negative\" : \"secondary\"}\n disabled={disabled}\n asChild\n />\n );\n }, [hasValue, onValueReset, disabled, displayResetAction, variant]);\n\n return (\n <SelectTrigger\n size={size}\n variant={variant}\n invalid={invalid}\n startIcon={startIcon}\n endIcon={endIcon}\n resetButton={resetButton}\n >\n <div className={\"flex-1 text-left truncate\"}>\n <SelectValue {...props} />\n </div>\n </SelectTrigger>\n );\n};\n\n/**\n * SelectOptions\n */\ntype SelectOptionsVm = {\n options: SelectOptionFormatted[];\n};\n\ntype SelectOptionsProps = SelectOptionsVm;\n\nconst SelectOptions = (props: SelectOptionsProps) => {\n const renderOptions = React.useCallback((items: SelectOptionFormatted[]) => {\n return items.map((item, index) => {\n const elements = [];\n\n if (item.options.length > 0) {\n // Render as a group if there are nested options\n elements.push(\n <SelectGroup key={`group-${index}`}>\n <SelectLabel>{item.label}</SelectLabel>\n {renderOptions(item.options)}\n </SelectGroup>\n );\n }\n\n if (item.value) {\n // Render as a select item if there are no nested options\n elements.push(\n <SelectItem\n key={`item-${item.value}`}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </SelectItem>\n );\n }\n\n // Conditionally render the separator if hasSeparator is true\n if (item.separator) {\n elements.push(<SelectSeparator key={`separator-${item.value ?? index}`} />);\n }\n\n return elements;\n });\n }, []);\n\n return <SelectContent>{renderOptions(props.options)}</SelectContent>;\n};\n\n/**\n * SelectRenderer\n */\nexport type SelectRootVm = {\n value: string;\n};\n\ntype SelectRootProps = Omit<SelectPrimitives.SelectProps, \"onValueChange\">;\n\ntype SelectRendererProps = {\n selectRootProps: SelectRootProps;\n selectTriggerProps: Omit<SelectTriggerProps, \"onValueReset\">;\n selectOptionsProps: SelectOptionsProps;\n onValueChange: (value: string) => void;\n onValueReset: () => void;\n};\n\nconst SelectPrimitiveRenderer = ({\n selectRootProps,\n selectTriggerProps,\n selectOptionsProps,\n onValueChange,\n onValueReset\n}: SelectRendererProps) => {\n return (\n <SelectRoot {...selectRootProps} onValueChange={onValueChange}>\n <Trigger {...selectTriggerProps} onValueReset={onValueReset} />\n <SelectOptions {...selectOptionsProps} />\n </SelectRoot>\n );\n};\n\n/**\n * Select\n */\ntype SelectOption = SelectOptionDto | string;\n\ninterface SelectPrimitiveProps {\n /**\n * Whether to display the reset action button.\n */\n displayResetAction?: boolean;\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Icon to display at the end of the select trigger.\n */\n endIcon?: React.ReactElement;\n /**\n * Whether the select input is invalid.\n */\n invalid?: VariantProps<typeof selectTriggerVariants>[\"invalid\"];\n /**\n * Callback function called when the value changes.\n */\n onChange?: (value: string) => void;\n /**\n * Callback function called when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Callback function called when the value is reset.\n */\n onValueReset?: () => void;\n /**\n * Array of options to display in the select dropdown.\n */\n options?: SelectOption[];\n /**\n * Placeholder text to display when no value is selected.\n */\n placeholder?: string;\n /**\n * Size variant of the select trigger.\n */\n size?: VariantProps<typeof selectTriggerVariants>[\"size\"];\n /**\n * Icon to display at the start of the select trigger.\n */\n startIcon?: React.ReactElement;\n /**\n * The value of the select input.\n */\n value?: string;\n /**\n * Style variant of the select trigger.\n */\n variant?: VariantProps<typeof selectTriggerVariants>[\"variant\"];\n}\n\nconst SelectPrimitive = (props: SelectPrimitiveProps) => {\n const { vm, changeValue, resetValue } = useSelect(props);\n const { size, variant, startIcon, endIcon, invalid, disabled, ...selectRootProps } = props;\n\n return (\n <SelectPrimitiveRenderer\n selectRootProps={{ ...selectRootProps, ...vm.selectRoot, disabled }}\n selectTriggerProps={{\n ...vm.selectTrigger,\n size,\n variant,\n startIcon,\n endIcon,\n invalid,\n disabled\n }}\n selectOptionsProps={vm.selectOptions}\n onValueChange={changeValue}\n onValueReset={resetValue}\n />\n );\n};\n\nexport {\n SelectPrimitive,\n type SelectPrimitiveProps,\n type SelectOptionsVm,\n type SelectTriggerVm,\n type SelectOption\n};\n"],"names":["SelectRoot","SelectPrimitives","SelectGroup","SelectValue","Trigger","hasValue","size","variant","startIcon","endIcon","invalid","onValueReset","disabled","displayResetAction","props","resetButton","React","IconButton","event","Icon","Close","SelectTrigger","SelectOptions","renderOptions","items","item","index","elements","SelectLabel","SelectItem","SelectSeparator","SelectContent","SelectPrimitiveRenderer","selectRootProps","selectTriggerProps","selectOptionsProps","onValueChange","SelectPrimitive","vm","changeValue","resetValue","useSelect"],"mappings":";;;;;;;AAiBA,MAAMA,aAAaC,OAAAA,IAAq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ent":["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { ReactComponent as AuditLogsIcon } from \"@webiny/icons/assignment.svg\";\nimport { ReactComponent as FormBuilderIcon } from \"@webiny/icons/check_box.svg\";\nimport { ReactComponent as CmsIcon } from \"@webiny/icons/web.svg\";\nimport { ReactComponent as PageBuilderIcon } from \"@webiny/icons/table_chart.svg\";\nimport { ReactComponent as InfoIcon } from \"@webiny/icons/info.svg\";\nimport { ReactComponent as ChatIcon } from \"@webiny/icons/chat.svg\";\nimport { ReactComponent as GithubIcon } from \"@webiny/icons/gite.svg\";\nimport { ReactComponent as DocsIcon } from \"@webiny/icons/summarize.svg\";\nimport { ReactComponent as ApiPlaygroundIcon } from \"@webiny/icons/swap_horiz.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as FileManagerIcon } from \"@webiny/icons/insert_drive_file.svg\";\nimport { ReactComponent as GridIcon } from \"@webiny/icons/grid_4x4.svg\";\nimport { ReactComponent as CarIcon } from \"@webiny/icons/car_rental.svg\";\nimport { ReactComponent as VehiclesIcon } from \"@webiny/icons/expand.svg\";\nimport { Sidebar } from \"./Sidebar.js\";\nimport { SidebarProvider } from \"~/Sidebar/components/SidebarProvider.js\";\nimport { DropdownMenu } from \"~/DropdownMenu/index.js\";\nimport { Tag } from \"~/Tag/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { AdminUiProvider } from \"~/AdminUiProvider/index.js\";\nimport { HashLink } from \"~/Sidebar/stories/HashLink.js\";\nimport { useHash } from \"~/Sidebar/stories/useHash.js\";\n\nconst meta: Meta<typeof Sidebar> = {\n title: \"Components/Sidebar\",\n component: Sidebar,\n\n parameters: {\n layout: \"fullscreen\"\n },\n\n // We removed this because in the \"all stories\" view, the menu gets visually\n // broken because of the fixed positioning of the sidebar. This is not a problem\n // when the story is viewed in isolation.\n // tags: [\"autodocs\"],\n\n argTypes: {},\n decorators: [\n Story => (\n <Tooltip.Provider>\n <Story />\n </Tooltip.Provider>\n )\n ]\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof Sidebar>;\n\nexport const MainMenu: Story = {\n render: () => (\n <AdminUiProvider linkComponent={HashLink}>\n <SidebarComponent />\n </AdminUiProvider>\n )\n};\n\nconst SidebarComponent = () => {\n const hash = useHash();\n\n const [sidebarState, setSidebarState] = React.useState<{\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n }>({\n pinned: false,\n expandedSections: [],\n pinnedItems: []\n });\n\n return (\n <SidebarProvider state={sidebarState} onChangeState={setSidebarState}>\n <Sidebar\n title={\"Webiny\"}\n icon={\n <Sidebar.Icon\n element={<img src=\"/images/wby-logo.png\" alt=\"Webiny\" />}\n label={\"Webiny\"}\n />\n }\n footer={\n <DropdownMenu\n trigger={\n <Sidebar.Item\n icon={<Sidebar.Item.Icon label=\"Settings\" element={<InfoIcon />} />}\n text={\"Support\"}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n />\n }\n className={\"w-[225px]\"}\n >\n <DropdownMenu.Item text={\"API Playground\"} icon={<ApiPlaygroundIcon />} />\n <DropdownMenu.Item text={\"Documentation\"} icon={<DocsIcon />} />\n <DropdownMenu.Item text={\"GitHub\"} icon={<GithubIcon />} />\n <DropdownMenu.Item text={\"Slack\"} icon={<ChatIcon />} />\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n text={\n <div className={\"flex items-center\"}>\n Webiny 6.0.0\n <Tag\n variant={\"accent\"}\n content={\"WCP \"}\n className={\"ml-sm-extra\"}\n />\n </div>\n }\n />\n </DropdownMenu>\n }\n >\n <Sidebar.Link\n pinnable\n text={\"Audit Logs\"}\n action={\n <Sidebar.Item.Action\n element={<MoreVertIcon />}\n onClick={() => console.log(\"More action clicked\")}\n />\n }\n to={\"#audit-logs\"}\n active={hash === \"#audit-logs\"}\n icon={<Sidebar.Item.Icon label=\"Audit Logs\" element={<AuditLogsIcon />} />}\n />\n <Sidebar.Link\n pinnable\n text={\"Form Builder\"}\n to={\"#form-builder\"}\n active={hash === \"#form-builder\"}\n icon={<Sidebar.Item.Icon label=\"Form Builder\" element={<FormBuilderIcon />} />}\n />\n <Sidebar.Item\n pinnable\n text={\"File Manager\"}\n onClick={() => {\n alert(\"File Manager clicked\");\n }}\n icon={<Sidebar.Item.Icon label=\"File Manager\" element={<FileManagerIcon />} />}\n />\n <Sidebar.Item\n text={\"Content\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<CmsIcon />} />}\n >\n <Sidebar.Item\n text={\"Vehicles\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<VehiclesIcon />} />}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n >\n <Sidebar.Link\n pinnable\n pinnedIcon={\n <Sidebar.Item.Icon label=\"File Manager\" element={<CarIcon />} />\n }\n text={\"Cars\"}\n to={\"#cms-cars\"}\n active={hash === \"#cms-cars\"}\n />\n <Sidebar.Link\n pinnable\n text={\"Planes\"}\n to={\"#cms-planes\"}\n active={hash === \"#cms-planes\"}\n />\n </Sidebar.Item>{\" \"}\n <Sidebar.Item\n text={\"Ungrouped\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<GridIcon />} />}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n >\n <Sidebar.Link\n text={\"Articles\"}\n to={\"#cms-articles\"}\n active={hash === \"#cms-articles\"}\n />\n <Sidebar.Link\n text={\"Settings\"}\n to={\"#cms-settings\"}\n active={hash === \"#cms-settings\"}\n />\n </Sidebar.Item>\n </Sidebar.Item>\n <Sidebar.Item\n text={\"Headless CMS\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<CmsIcon />} />}\n >\n <Sidebar.Group text={\"Content Models\"} />\n <Sidebar.Link\n pinnable\n text={\"Groups\"}\n to={\"#cms-groups\"}\n active={hash === \"#cms-groups\"}\n />\n <Sidebar.Link\n pinnable\n text={\"Models\"}\n to={\"#cms-models\"}\n active={hash === \"#cms-models\"}\n />\n </Sidebar.Item>\n <Sidebar.Item\n text={\"Page Builder\"}\n icon={<Sidebar.Item.Icon label=\"Page Builder\" element={<PageBuilderIcon />} />}\n >\n <Sidebar.Group text={\"Blocks\"} />\n <Sidebar.Link\n text={\"Blocks\"}\n to={\"#pb-blocks\"}\n active={hash === \"#pb-blocks\"}\n />\n <Sidebar.Link\n text={\"Categories\"}\n to={\"#pb-blocks-categories\"}\n active={hash === \"#pb-blocks-categories\"}\n />\n\n <Sidebar.Group text={\"Pages\"} active={hash === `#pb-pages`} />\n <Sidebar.Link\n to={\"#pb-pages-categories\"}\n text={\"Categories\"}\n active={hash === `#pb-pages-categories`}\n />\n <Sidebar.Link\n to={\"#pb-pages-menus\"}\n text={\"Menus\"}\n active={hash === `#pb-pages-menus`}\n />\n <Sidebar.Link\n to={\"#pb-pages-pages\"}\n text={\"Pages\"}\n active={hash === `#pb-pages-pages`}\n />\n <Sidebar.Link\n to={\"#pb-pages-templates\"}\n text={\"Templates\"}\n disabled={true}\n active={hash === `#pb-pages-templates`}\n />\n </Sidebar.Item>\n </Sidebar>\n </SidebarProvider>\n );\n};\n"],"names":["meta","Sidebar","Story","Tooltip","MainMenu","AdminUiProvider","HashLink","SidebarComponent","hash","useHash","sidebarState","setSidebarState","React","SidebarProvider","DropdownMenu","InfoIcon","MoreVertIcon","ApiPlaygroundIcon","DocsIcon","GithubIcon","ChatIcon","Tag","console","AuditLogsIcon","FormBuilderIcon","alert","FileManagerIcon","CmsIcon","VehiclesIcon","CarIcon","GridIcon","PageBuilderIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,OAA6B;IAC/B,OAAO;IACP,WAAWC;IAEX,YAAY;QACR,QAAQ;IACZ;IAOA,UAAU,CAAC;IACX,YAAY;QACRC,CAAAA,QAAAA,WAAAA,GACI,oBAACC,QAAQ,QAAQ,sBACb,oBAACD,OAAAA;KAGZ;AACL;AAEA,wBAAeF;AAIR,MAAMI,WAAkB;IAC3B,QAA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ACN,UAAU;QACV,QAAQO,AAAS,0BAATA;;AAMhC"}
|
|
1
|
+
{"version":3,"file":"Sidebar/Sidebar.stories.js","sources":["../../src/Sidebar/Sidebar.stories.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { ReactComponent as AuditLogsIcon } from \"@webiny/icons/assignment.svg\";\nimport { ReactComponent as FormBuilderIcon } from \"@webiny/icons/check_box.svg\";\nimport { ReactComponent as CmsIcon } from \"@webiny/icons/web.svg\";\nimport { ReactComponent as PageBuilderIcon } from \"@webiny/icons/table_chart.svg\";\nimport { ReactComponent as InfoIcon } from \"@webiny/icons/info.svg\";\nimport { ReactComponent as ChatIcon } from \"@webiny/icons/chat.svg\";\nimport { ReactComponent as GithubIcon } from \"@webiny/icons/gite.svg\";\nimport { ReactComponent as DocsIcon } from \"@webiny/icons/summarize.svg\";\nimport { ReactComponent as ApiPlaygroundIcon } from \"@webiny/icons/swap_horiz.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as FileManagerIcon } from \"@webiny/icons/insert_drive_file.svg\";\nimport { ReactComponent as GridIcon } from \"@webiny/icons/grid_4x4.svg\";\nimport { ReactComponent as CarIcon } from \"@webiny/icons/car_rental.svg\";\nimport { ReactComponent as VehiclesIcon } from \"@webiny/icons/expand.svg\";\nimport { Sidebar } from \"./Sidebar.js\";\nimport { SidebarProvider } from \"~/Sidebar/components/SidebarProvider.js\";\nimport { DropdownMenu } from \"~/DropdownMenu/index.js\";\nimport { Tag } from \"~/Tag/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { AdminUiProvider } from \"~/AdminUiProvider/index.js\";\nimport { HashLink } from \"~/Sidebar/stories/HashLink.js\";\nimport { useHash } from \"~/Sidebar/stories/useHash.js\";\n\nconst meta: Meta<typeof Sidebar> = {\n title: \"Components/Sidebar\",\n component: Sidebar,\n\n parameters: {\n layout: \"fullscreen\"\n },\n\n // We removed this because in the \"all stories\" view, the menu gets visually\n // broken because of the fixed positioning of the sidebar. This is not a problem\n // when the story is viewed in isolation.\n // tags: [\"autodocs\"],\n\n argTypes: {},\n decorators: [\n Story => (\n <Tooltip.Provider>\n <Story />\n </Tooltip.Provider>\n )\n ]\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof Sidebar>;\n\nexport const MainMenu: Story = {\n render: () => (\n <AdminUiProvider linkComponent={HashLink}>\n <SidebarComponent />\n </AdminUiProvider>\n )\n};\n\nconst SidebarComponent = () => {\n const hash = useHash();\n\n const [sidebarState, setSidebarState] = React.useState<{\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n }>({\n pinned: false,\n expandedSections: [],\n pinnedItems: []\n });\n\n return (\n <SidebarProvider state={sidebarState} onChangeState={setSidebarState}>\n <Sidebar\n title={\"Webiny\"}\n icon={\n <Sidebar.Icon\n element={<img src=\"/images/wby-logo.png\" alt=\"Webiny\" />}\n label={\"Webiny\"}\n />\n }\n footer={\n <DropdownMenu\n trigger={\n <Sidebar.Item\n icon={<Sidebar.Item.Icon label=\"Settings\" element={<InfoIcon />} />}\n text={\"Support\"}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n />\n }\n className={\"w-[225px]\"}\n >\n <DropdownMenu.Item text={\"API Playground\"} icon={<ApiPlaygroundIcon />} />\n <DropdownMenu.Item text={\"Documentation\"} icon={<DocsIcon />} />\n <DropdownMenu.Item text={\"GitHub\"} icon={<GithubIcon />} />\n <DropdownMenu.Item text={\"Slack\"} icon={<ChatIcon />} />\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n text={\n <div className={\"flex items-center\"}>\n Webiny 6.0.0\n <Tag\n variant={\"accent\"}\n content={\"WCP \"}\n className={\"ml-sm-extra\"}\n />\n </div>\n }\n />\n </DropdownMenu>\n }\n >\n <Sidebar.Link\n pinnable\n text={\"Audit Logs\"}\n action={\n <Sidebar.Item.Action\n element={<MoreVertIcon />}\n onClick={() => console.log(\"More action clicked\")}\n />\n }\n to={\"#audit-logs\"}\n active={hash === \"#audit-logs\"}\n icon={<Sidebar.Item.Icon label=\"Audit Logs\" element={<AuditLogsIcon />} />}\n />\n <Sidebar.Link\n pinnable\n text={\"Form Builder\"}\n to={\"#form-builder\"}\n active={hash === \"#form-builder\"}\n icon={<Sidebar.Item.Icon label=\"Form Builder\" element={<FormBuilderIcon />} />}\n />\n <Sidebar.Item\n pinnable\n text={\"File Manager\"}\n onClick={() => {\n alert(\"File Manager clicked\");\n }}\n icon={<Sidebar.Item.Icon label=\"File Manager\" element={<FileManagerIcon />} />}\n />\n <Sidebar.Item\n text={\"Content\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<CmsIcon />} />}\n >\n <Sidebar.Item\n text={\"Vehicles\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<VehiclesIcon />} />}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n >\n <Sidebar.Link\n pinnable\n pinnedIcon={\n <Sidebar.Item.Icon label=\"File Manager\" element={<CarIcon />} />\n }\n text={\"Cars\"}\n to={\"#cms-cars\"}\n active={hash === \"#cms-cars\"}\n />\n <Sidebar.Link\n pinnable\n text={\"Planes\"}\n to={\"#cms-planes\"}\n active={hash === \"#cms-planes\"}\n />\n </Sidebar.Item>{\" \"}\n <Sidebar.Item\n text={\"Ungrouped\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<GridIcon />} />}\n action={<Sidebar.Item.Action element={<MoreVertIcon />} />}\n >\n <Sidebar.Link\n text={\"Articles\"}\n to={\"#cms-articles\"}\n active={hash === \"#cms-articles\"}\n />\n <Sidebar.Link\n text={\"Settings\"}\n to={\"#cms-settings\"}\n active={hash === \"#cms-settings\"}\n />\n </Sidebar.Item>\n </Sidebar.Item>\n <Sidebar.Item\n text={\"Headless CMS\"}\n icon={<Sidebar.Item.Icon label=\"Headless CMS\" element={<CmsIcon />} />}\n >\n <Sidebar.Group text={\"Content Models\"} />\n <Sidebar.Link\n pinnable\n text={\"Groups\"}\n to={\"#cms-groups\"}\n active={hash === \"#cms-groups\"}\n />\n <Sidebar.Link\n pinnable\n text={\"Models\"}\n to={\"#cms-models\"}\n active={hash === \"#cms-models\"}\n />\n </Sidebar.Item>\n <Sidebar.Item\n text={\"Page Builder\"}\n icon={<Sidebar.Item.Icon label=\"Page Builder\" element={<PageBuilderIcon />} />}\n >\n <Sidebar.Group text={\"Blocks\"} />\n <Sidebar.Link\n text={\"Blocks\"}\n to={\"#pb-blocks\"}\n active={hash === \"#pb-blocks\"}\n />\n <Sidebar.Link\n text={\"Categories\"}\n to={\"#pb-blocks-categories\"}\n active={hash === \"#pb-blocks-categories\"}\n />\n\n <Sidebar.Group text={\"Pages\"} active={hash === `#pb-pages`} />\n <Sidebar.Link\n to={\"#pb-pages-categories\"}\n text={\"Categories\"}\n active={hash === `#pb-pages-categories`}\n />\n <Sidebar.Link\n to={\"#pb-pages-menus\"}\n text={\"Menus\"}\n active={hash === `#pb-pages-menus`}\n />\n <Sidebar.Link\n to={\"#pb-pages-pages\"}\n text={\"Pages\"}\n active={hash === `#pb-pages-pages`}\n />\n <Sidebar.Link\n to={\"#pb-pages-templates\"}\n text={\"Templates\"}\n disabled={true}\n active={hash === `#pb-pages-templates`}\n />\n </Sidebar.Item>\n </Sidebar>\n </SidebarProvider>\n );\n};\n"],"names":["meta","Sidebar","Story","Tooltip","MainMenu","AdminUiProvider","HashLink","SidebarComponent","hash","useHash","sidebarState","setSidebarState","React","SidebarProvider","DropdownMenu","InfoIcon","MoreVertIcon","ApiPlaygroundIcon","DocsIcon","GithubIcon","ChatIcon","Tag","console","AuditLogsIcon","FormBuilderIcon","alert","FileManagerIcon","CmsIcon","VehiclesIcon","CarIcon","GridIcon","PageBuilderIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,OAA6B;IAC/B,OAAO;IACP,WAAWC;IAEX,YAAY;QACR,QAAQ;IACZ;IAOA,UAAU,CAAC;IACX,YAAY;Q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BAEZ,oBAACP,QAAQ,IAAI;QACT,IAAI;QACJ,MAAM;QACN,QAAQO,AAAS,sBAATA;sBAEZ,oBAACP,QAAQ,IAAI;QACT,IAAI;QACJ,MAAM;QACN,UAAU;QACV,QAAQO,AAAS,0BAATA;;AAMhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar/components/SidebarProvider.js","sources":["../../../src/Sidebar/components/SidebarProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { SIDEBAR_TRANSITION_DURATION } from \"./constants.js\";\n\ntype PinnedItemData = {\n id: string;\n text: React.ReactNode;\n icon?: React.ReactNode;\n to?: string;\n onClick?: React.MouseEventHandler;\n active?: boolean;\n};\n\ntype SidebarContext = {\n state: \"expanded\" | \"collapsed\";\n expanded: boolean;\n expandedSections: string[];\n pinned: boolean;\n transition: null | \"expanding\" | \"collapsing\";\n setExpanded: (expanded: boolean) => void;\n toggleExpanded: () => void;\n togglePinned: () => void;\n toggleSectionExpanded: (sectionId: string) => void;\n isSectionExpanded: (sectionId: string) => boolean;\n pinnedItems: string[];\n toggleItemPinned: (itemId: string) => void;\n isItemPinned: (itemId: string) => boolean;\n registerPinnedItem: (data: PinnedItemData) => void;\n unregisterPinnedItem: (itemId: string) => void;\n getPinnedItemsData: () => PinnedItemData[];\n};\n\nconst SidebarContext = React.createContext<SidebarContext | null>(null);\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext);\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider.\");\n }\n\n return context;\n}\n\ntype SidebarCachedState = {\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n};\n\ntype SidebarProviderProps = React.HTMLAttributes<HTMLDivElement> & {\n state?: SidebarCachedState;\n onChangeState?: (state: SidebarCachedState) => void;\n};\n\ninterface SidebarState {\n expanded: boolean;\n transition: null | \"expanding\" | \"collapsing\";\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n}\n\nconst createInitialSidebarState = (state?: SidebarCachedState): SidebarState => {\n const pinned = state?.pinned ?? false;\n const expandedSections = state?.expandedSections ?? [];\n const pinnedItems = state?.pinnedItems ?? [];\n return {\n expanded: pinned, // If pinned, we want the sidebar to be open by default.\n pinned,\n expandedSections,\n pinnedItems,\n transition: null\n };\n};\n\nconst SidebarProvider = ({\n className,\n children,\n state: cachedState,\n onChangeState,\n ...props\n}: SidebarProviderProps) => {\n const [sidebarState, setSidebarState] = React.useState<SidebarState>(() =>\n createInitialSidebarState(cachedState)\n );\n const [pinnedItemsData, setPinnedItemsData] = React.useState<Map<string, PinnedItemData>>(\n new Map()\n );\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n const timeoutRef = React.useRef<number | null>(null);\n const isInitialMount = React.useRef(true);\n\n const { expanded, transition, pinned, expandedSections, pinnedItems } = sidebarState;\n\n // Sync state changes to parent via useEffect\n React.useEffect(() => {\n // Skip the initial mount to avoid unnecessary state sync\n if (isInitialMount.current) {\n isInitialMount.current = false;\n return;\n }\n\n if (onChangeState) {\n onChangeState({\n pinned,\n expandedSections,\n pinnedItems\n });\n }\n }, [pinned, expandedSections, pinnedItems, onChangeState]);\n\n const setExpanded = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const newValue = typeof value === \"function\" ? value(expanded) : value;\n setSidebarState(state => ({\n ...state,\n expanded: newValue,\n transition: newValue ? \"expanding\" : \"collapsing\"\n }));\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n timeoutRef.current = window.setTimeout(() => {\n setSidebarState(state => ({\n ...state,\n transition: null\n }));\n }, SIDEBAR_TRANSITION_DURATION);\n },\n [expanded]\n );\n\n const setPinned = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const newValue = typeof value === \"function\" ? value(pinned) : value;\n setSidebarState(state => ({\n ...state,\n pinned: newValue\n }));\n },\n [pinned]\n );\n\n const toggleExpanded = React.useCallback(() => {\n return setExpanded(prev => !prev);\n }, [setExpanded]); // Helper to toggle the sidebar.\n\n const togglePinned = React.useCallback(() => {\n return setPinned(prev => !prev);\n }, [setPinned]);\n\n const toggleSectionExpanded = React.useCallback(\n (sectionId: string) => {\n setSidebarState(state => {\n const expandedSections = state.expandedSections.includes(sectionId)\n ? state.expandedSections.filter(id => id !== sectionId)\n : [...state.expandedSections, sectionId];\n\n return {\n ...state,\n expandedSections\n };\n });\n },\n [setSidebarState]\n );\n\n const isSectionExpanded = React.useCallback(\n (sectionId: string) => {\n return expandedSections.includes(sectionId);\n },\n [expandedSections]\n );\n\n const toggleItemPinned = React.useCallback(\n (itemId: string) => {\n setSidebarState(state => {\n const newPinnedItems = state.pinnedItems.includes(itemId)\n ? state.pinnedItems.filter(id => id !== itemId)\n : [...state.pinnedItems, itemId];\n\n return {\n ...state,\n pinnedItems: newPinnedItems\n };\n });\n },\n [setSidebarState]\n );\n\n const isItemPinned = React.useCallback(\n (itemId: string) => {\n return pinnedItems.includes(itemId);\n },\n [pinnedItems]\n );\n\n const registerPinnedItem = React.useCallback((data: PinnedItemData) => {\n setPinnedItemsData(prev => {\n const newMap = new Map(prev);\n newMap.set(data.id, data);\n return newMap;\n });\n }, []);\n\n const unregisterPinnedItem = React.useCallback((itemId: string) => {\n setPinnedItemsData(prev => {\n const newMap = new Map(prev);\n newMap.delete(itemId);\n return newMap;\n });\n }, []);\n\n const getPinnedItemsData = React.useCallback(() => {\n // Sort by the order in pinnedItems array to maintain consistent ordering\n return pinnedItems\n .map(id => pinnedItemsData.get(id))\n .filter((item): item is PinnedItemData => item !== undefined);\n }, [pinnedItemsData, pinnedItems]);\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = expanded ? \"expanded\" : \"collapsed\";\n\n const contextValue = React.useMemo<SidebarContext>(\n () => ({\n state,\n transition,\n expanded,\n expandedSections,\n pinned,\n setExpanded,\n toggleExpanded,\n toggleSectionExpanded,\n setPinned,\n togglePinned,\n isSectionExpanded,\n pinnedItems,\n toggleItemPinned,\n isItemPinned,\n registerPinnedItem,\n unregisterPinnedItem,\n getPinnedItemsData\n }),\n [\n state,\n transition,\n expanded,\n expandedSections,\n pinned,\n setExpanded,\n setPinned,\n toggleExpanded,\n togglePinned,\n pinnedItems,\n toggleItemPinned,\n isItemPinned,\n registerPinnedItem,\n unregisterPinnedItem,\n getPinnedItemsData\n ]\n );\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n data-sidebar={\"provider\"}\n {...props}\n className={cn(\"group/sidebar-wrapper flex min-h-svh w-full\", className)}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n );\n};\nSidebarProvider.displayName = \"SidebarProvider\";\n\nexport { SidebarProvider, useSidebar, type PinnedItemData };\n"],"names":["SidebarContext","React","useSidebar","context","Error","createInitialSidebarState","state","pinned","expandedSections","pinnedItems","SidebarProvider","className","children","cachedState","onChangeState","props","sidebarState","setSidebarState","pinnedItemsData","setPinnedItemsData","Map","timeoutRef","isInitialMount","expanded","transition","setExpanded","value","newValue","window","SIDEBAR_TRANSITION_DURATION","setPinned","toggleExpanded","prev","togglePinned","toggleSectionExpanded","sectionId","id","isSectionExpanded","toggleItemPinned","itemId","newPinnedItems","isItemPinned","registerPinnedItem","data","newMap","unregisterPinnedItem","getPinnedItemsData","item","undefined","contextValue","cn"],"mappings":";;;AAgCA,MAAMA,iBAAiB,WAAHA,GAAGC,MAAAA,aAAmB,CAAwB;AAElE,SAASC;IACL,MAAMC,UAAUF,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACG,SACD,MAAM,IAAIC,MAAM;IAGpB,OAAOD;AACX;AAqBA,MAAME,4BAA4B,CAACC;IAC/B,MAAMC,SAASD,OAAO,UAAU;IAChC,MAAME,mBAAmBF,OAAO,oBAAoB,EAAE;IACtD,MAAMG,cAAcH,OAAO,eAAe,EAAE;IAC5C,OAAO;QACH,UAAUC;QACVA;QACAC;QACAC;QACA,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A;YACf,MAAMY,SAAS,IAAIxB,IAAIY;YACvBY,OAAO,GAAG,CAACD,KAAK,EAAE,EAAEA;YACpB,OAAOC;QACX;IACJ,GAAG,EAAE;IAEL,MAAMC,uBAAuB5C,MAAAA,WAAiB,CAAC,CAACsC;QAC5CpB,mBAAmBa,CAAAA;YACf,MAAMY,SAAS,IAAIxB,IAAIY;YACvBY,OAAO,MAAM,CAACL;YACd,OAAOK;QACX;IACJ,GAAG,EAAE;IAEL,MAAME,qBAAqB7C,MAAAA,WAAiB,CAAC,IAElCQ,YACF,GAAG,CAAC2B,CAAAA,KAAMlB,gBAAgB,GAAG,CAACkB,KAC9B,MAAM,CAAC,CAACW,OAAiCA,AAASC,WAATD,OAC/C;QAAC7B;QAAiBT;KAAY;IAIjC,MAAMH,QAAQiB,WAAW,aAAa;IAEtC,MAAM0B,eAAehD,MAAAA,OAAa,CAC9B,IAAO;YACHK;YACAkB;YACAD;YACAf;YACAD;YACAkB;YACAM;YACAG;YACAJ;YACAG;YACAI;YACA5B;YACA6B;YACAG;YACAC;YACAG;YACAC;QACJ,IACA;QACIxC;QACAkB;QACAD;QACAf;QACAD;QACAkB;QACAK;QACAC;QACAE;QACAxB;QACA6B;QACAG;QACAC;QACAG;QACAC;KACH;IAGL,OAAO,WAAP,GACI,oBAAC9C,eAAe,QAAQ;QAAC,OAAOiD;qBAC5B,oBAAC;QACG,gBAAc;QACb,GAAGlC,KAAK;QACT,WAAWmC,GAAG,+CAA+CvC;OAE5DC;AAIjB;AACAF,gBAAgB,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"file":"Sidebar/components/SidebarProvider.js","sources":["../../../src/Sidebar/components/SidebarProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { SIDEBAR_TRANSITION_DURATION } from \"./constants.js\";\n\ntype PinnedItemData = {\n id: string;\n text: React.ReactNode;\n icon?: React.ReactNode;\n to?: string;\n onClick?: React.MouseEventHandler;\n active?: boolean;\n};\n\ntype SidebarContext = {\n state: \"expanded\" | \"collapsed\";\n expanded: boolean;\n expandedSections: string[];\n pinned: boolean;\n transition: null | \"expanding\" | \"collapsing\";\n setExpanded: (expanded: boolean) => void;\n toggleExpanded: () => void;\n togglePinned: () => void;\n toggleSectionExpanded: (sectionId: string) => void;\n isSectionExpanded: (sectionId: string) => boolean;\n pinnedItems: string[];\n toggleItemPinned: (itemId: string) => void;\n isItemPinned: (itemId: string) => boolean;\n registerPinnedItem: (data: PinnedItemData) => void;\n unregisterPinnedItem: (itemId: string) => void;\n getPinnedItemsData: () => PinnedItemData[];\n};\n\nconst SidebarContext = React.createContext<SidebarContext | null>(null);\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext);\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider.\");\n }\n\n return context;\n}\n\ntype SidebarCachedState = {\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n};\n\ntype SidebarProviderProps = React.HTMLAttributes<HTMLDivElement> & {\n state?: SidebarCachedState;\n onChangeState?: (state: SidebarCachedState) => void;\n};\n\ninterface SidebarState {\n expanded: boolean;\n transition: null | \"expanding\" | \"collapsing\";\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n}\n\nconst createInitialSidebarState = (state?: SidebarCachedState): SidebarState => {\n const pinned = state?.pinned ?? false;\n const expandedSections = state?.expandedSections ?? [];\n const pinnedItems = state?.pinnedItems ?? [];\n return {\n expanded: pinned, // If pinned, we want the sidebar to be open by default.\n pinned,\n expandedSections,\n pinnedItems,\n transition: null\n };\n};\n\nconst SidebarProvider = ({\n className,\n children,\n state: cachedState,\n onChangeState,\n ...props\n}: SidebarProviderProps) => {\n const [sidebarState, setSidebarState] = React.useState<SidebarState>(() =>\n createInitialSidebarState(cachedState)\n );\n const [pinnedItemsData, setPinnedItemsData] = React.useState<Map<string, PinnedItemData>>(\n new Map()\n );\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n const timeoutRef = React.useRef<number | null>(null);\n const isInitialMount = React.useRef(true);\n\n const { expanded, transition, pinned, expandedSections, pinnedItems } = sidebarState;\n\n // Sync state changes to parent via useEffect\n React.useEffect(() => {\n // Skip the initial mount to avoid unnecessary state sync\n if (isInitialMount.current) {\n isInitialMount.current = false;\n return;\n }\n\n if (onChangeState) {\n onChangeState({\n pinned,\n expandedSections,\n pinnedItems\n });\n }\n }, [pinned, expandedSections, pinnedItems, onChangeState]);\n\n const setExpanded = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const newValue = typeof value === \"function\" ? value(expanded) : value;\n setSidebarState(state => ({\n ...state,\n expanded: newValue,\n transition: newValue ? \"expanding\" : \"collapsing\"\n }));\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n timeoutRef.current = window.setTimeout(() => {\n setSidebarState(state => ({\n ...state,\n transition: null\n }));\n }, SIDEBAR_TRANSITION_DURATION);\n },\n [expanded]\n );\n\n const setPinned = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const newValue = typeof value === \"function\" ? value(pinned) : value;\n setSidebarState(state => ({\n ...state,\n pinned: newValue\n }));\n },\n [pinned]\n );\n\n const toggleExpanded = React.useCallback(() => {\n return setExpanded(prev => !prev);\n }, [setExpanded]); // Helper to toggle the sidebar.\n\n const togglePinned = React.useCallback(() => {\n return setPinned(prev => !prev);\n }, [setPinned]);\n\n const toggleSectionExpanded = React.useCallback(\n (sectionId: string) => {\n setSidebarState(state => {\n const expandedSections = state.expandedSections.includes(sectionId)\n ? state.expandedSections.filter(id => id !== sectionId)\n : [...state.expandedSections, sectionId];\n\n return {\n ...state,\n expandedSections\n };\n });\n },\n [setSidebarState]\n );\n\n const isSectionExpanded = React.useCallback(\n (sectionId: string) => {\n return expandedSections.includes(sectionId);\n },\n [expandedSections]\n );\n\n const toggleItemPinned = React.useCallback(\n (itemId: string) => {\n setSidebarState(state => {\n const newPinnedItems = state.pinnedItems.includes(itemId)\n ? state.pinnedItems.filter(id => id !== itemId)\n : [...state.pinnedItems, itemId];\n\n return {\n ...state,\n pinnedItems: newPinnedItems\n };\n });\n },\n [setSidebarState]\n );\n\n const isItemPinned = React.useCallback(\n (itemId: string) => {\n return pinnedItems.includes(itemId);\n },\n [pinnedItems]\n );\n\n const registerPinnedItem = React.useCallback((data: PinnedItemData) => {\n setPinnedItemsData(prev => {\n const newMap = new Map(prev);\n newMap.set(data.id, data);\n return newMap;\n });\n }, []);\n\n const unregisterPinnedItem = React.useCallback((itemId: string) => {\n setPinnedItemsData(prev => {\n const newMap = new Map(prev);\n newMap.delete(itemId);\n return newMap;\n });\n }, []);\n\n const getPinnedItemsData = React.useCallback(() => {\n // Sort by the order in pinnedItems array to maintain consistent ordering\n return pinnedItems\n .map(id => pinnedItemsData.get(id))\n .filter((item): item is PinnedItemData => item !== undefined);\n }, [pinnedItemsData, pinnedItems]);\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = expanded ? \"expanded\" : \"collapsed\";\n\n const contextValue = React.useMemo<SidebarContext>(\n () => ({\n state,\n transition,\n expanded,\n expandedSections,\n pinned,\n setExpanded,\n toggleExpanded,\n toggleSectionExpanded,\n setPinned,\n togglePinned,\n isSectionExpanded,\n pinnedItems,\n toggleItemPinned,\n isItemPinned,\n registerPinnedItem,\n unregisterPinnedItem,\n getPinnedItemsData\n }),\n [\n state,\n transition,\n expanded,\n expandedSections,\n pinned,\n setExpanded,\n setPinned,\n toggleExpanded,\n togglePinned,\n pinnedItems,\n toggleItemPinned,\n isItemPinned,\n registerPinnedItem,\n unregisterPinnedItem,\n getPinnedItemsData\n ]\n );\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n data-sidebar={\"provider\"}\n {...props}\n className={cn(\"group/sidebar-wrapper flex min-h-svh w-full\", className)}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n );\n};\nSidebarProvider.displayName = \"SidebarProvider\";\n\nexport { SidebarProvider, useSidebar, type PinnedItemData };\n"],"names":["SidebarContext","React","useSidebar","context","Error","createInitialSidebarState","state","pinned","expandedSections","pinnedItems","SidebarProvider","className","children","cachedState","onChangeState","props","sidebarState","setSidebarState","pinnedItemsData","setPinnedItemsData","Map","timeoutRef","isInitialMount","expanded","transition","setExpanded","value","newValue","window","SIDEBAR_TRANSITION_DURATION","setPinned","toggleExpanded","prev","togglePinned","toggleSectionExpanded","sectionId","id","isSectionExpanded","toggleItemPinned","itemId","newPinnedItems","isItemPinned","registerPinnedItem","data","newMap","unregisterPinnedItem","getPinnedItemsData","item","undefined","contextValue","cn"],"mappings":";;;AAgCA,MAAMA,iBAAiB,WAAjBA,GAAiBC,MAAAA,aAAmB,CAAwB;AAElE,SAASC;IACL,MAAMC,UAAUF,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACG,SACD,MAAM,IAAIC,MAAM;IAGpB,OAAOD;AACX;AAqBA,MAAME,4BAA4B,CAACC;IAC/B,MAAMC,SAASD,OAAO,UAAU;IAChC,MAAME,mBAAmBF,OAAO,oBAAoB,EAAE;IACtD,MAAMG,cAAcH,OAAO,eAAe,EAAE;IAC5C,OAAO;QACH,UAAUC;QACVA;QACAC;QACAC;QACA,YAAY;IAChB;AACJ;AAEA,MAAMC,kBAAkB,CAAC,EACrBC,SAAS,EACTC,QAAQ,EACR,OAAOC,WAAW,EAClBC,aAAa,EACb,GAAGC,OACgB;IACnB,MAAM,CAACC,cAAcC,gBAAgB,GAAGhB,MAAAA,QAAc,CAAe,IACjEI,0BAA0BQ;IAE9B,MAAM,CAACK,iBAAiBC,mBAAmB,GAAGlB,MAAAA,QAAc,CACxD,IAAImB;IAIR,MAAMC,aAAapB,MAAAA,MAAY,CAAgB;IAC/C,MAAMqB,iBAAiBrB,MAAAA,MAAY,CAAC;IAEpC,MAAM,EAAEsB,QAAQ,EAAEC,UAAU,EAAEjB,MAAM,EAAEC,gBAAgB,EAAEC,WAAW,EAAE,GAAGO;IAGxEf,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KAAY;IAIjC,MAAMH,QAAQiB,WAAW,aAAa;IAEtC,MAAM0B,eAAehD,MAAAA,OAAa,CAC9B,IAAO;YACHK;YACAkB;YACAD;YACAf;YACAD;YACAkB;YACAM;YACAG;YACAJ;YACAG;YACAI;YACA5B;YACA6B;YACAG;YACAC;YACAG;YACAC;QACJ,IACA;QACIxC;QACAkB;QACAD;QACAf;QACAD;QACAkB;QACAK;QACAC;QACAE;QACAxB;QACA6B;QACAG;QACAC;QACAG;QACAC;KACH;IAGL,OAAO,WAAP,GACI,oBAAC9C,eAAe,QAAQ;QAAC,OAAOiD;qBAC5B,oBAAC;QACG,gBAAc;QACb,GAAGlC,KAAK;QACT,WAAWmC,GAAG,+CAA+CvC;OAE5DC;AAIjB;AACAF,gBAAgB,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar/components/items/SidebarMenuProvider.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuProvider.tsx"],"sourcesContent":["import React from \"react\";\n\ninterface SidebarMenuContext {\n currentLevel: number;\n nextLevel: number;\n parentIcon?: React.ReactNode;\n}\n\ninterface SidebarMenuProviderProps {\n level?: number;\n parentIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nconst SidebarMenuContext = React.createContext<SidebarMenuContext>({\n currentLevel: 0,\n nextLevel: 1,\n parentIcon: undefined\n});\n\nfunction useSidebarMenu() {\n const context = React.useContext(SidebarMenuContext);\n if (!context) {\n throw new Error(\"useSidebarItem must be used within a SidebarMenuProvider.\");\n }\n\n return context;\n}\n\nconst SidebarMenuProvider = ({ level = 0, parentIcon, children }: SidebarMenuProviderProps) => {\n return (\n <SidebarMenuContext.Provider\n value={{ currentLevel: level, nextLevel: level + 1, parentIcon }}\n >\n {children}\n </SidebarMenuContext.Provider>\n );\n};\n\nSidebarMenuProvider.displayName = \"SidebarMenuProvider\";\n\nexport { SidebarMenuProvider, useSidebarMenu };\n"],"names":["SidebarMenuContext","React","undefined","useSidebarMenu","context","Error","SidebarMenuProvider","level","parentIcon","children"],"mappings":";AAcA,MAAMA,qBAAqB,
|
|
1
|
+
{"version":3,"file":"Sidebar/components/items/SidebarMenuProvider.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuProvider.tsx"],"sourcesContent":["import React from \"react\";\n\ninterface SidebarMenuContext {\n currentLevel: number;\n nextLevel: number;\n parentIcon?: React.ReactNode;\n}\n\ninterface SidebarMenuProviderProps {\n level?: number;\n parentIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nconst SidebarMenuContext = React.createContext<SidebarMenuContext>({\n currentLevel: 0,\n nextLevel: 1,\n parentIcon: undefined\n});\n\nfunction useSidebarMenu() {\n const context = React.useContext(SidebarMenuContext);\n if (!context) {\n throw new Error(\"useSidebarItem must be used within a SidebarMenuProvider.\");\n }\n\n return context;\n}\n\nconst SidebarMenuProvider = ({ level = 0, parentIcon, children }: SidebarMenuProviderProps) => {\n return (\n <SidebarMenuContext.Provider\n value={{ currentLevel: level, nextLevel: level + 1, parentIcon }}\n >\n {children}\n </SidebarMenuContext.Provider>\n );\n};\n\nSidebarMenuProvider.displayName = \"SidebarMenuProvider\";\n\nexport { SidebarMenuProvider, useSidebarMenu };\n"],"names":["SidebarMenuContext","React","undefined","useSidebarMenu","context","Error","SidebarMenuProvider","level","parentIcon","children"],"mappings":";AAcA,MAAMA,qBAAqB,WAArBA,GAAqBC,MAAAA,aAAmB,CAAqB;IAC/D,cAAc;IACd,WAAW;IACX,YAAYC;AAChB;AAEA,SAASC;IACL,MAAMC,UAAUH,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACI,SACD,MAAM,IAAIC,MAAM;IAGpB,OAAOD;AACX;AAEA,MAAME,sBAAsB,CAAC,EAAEC,QAAQ,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAA4B,GAC/E,WAAP,GACI,oBAACT,mBAAmB,QAAQ;QACxB,OAAO;YAAE,cAAcO;YAAO,WAAWA,QAAQ;YAAGC;QAAW;OAE9DC;AAKbH,oBAAoB,WAAW,GAAG"}
|
package/Slider/Slider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider/Slider.js","sources":["../../src/Slider/Slider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Label } from \"~/Label/index.js\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport type { SliderPrimitiveProps, SliderPrimitiveRendererProps } from \"./primitives/index.js\";\nimport { SliderPrimitiveRenderer, useSlider, SliderValue } from \"./primitives/index.js\";\nimport type { FormComponentProps } from \"~/FormComponent/index.js\";\nimport {\n FormComponentDescription,\n FormComponentErrorMessage,\n FormComponentLabel,\n FormComponentNote\n} from \"~/FormComponent/index.js\";\n\n/**\n * Slider Renderer with side label\n */\ninterface SliderRendererWithSideValueProps extends SliderPrimitiveRendererProps {\n label?: React.ReactNode;\n invalid?: boolean;\n required?: boolean;\n}\n\nconst SliderRendererWithSideValue = (props: SliderRendererWithSideValueProps) => {\n return (\n <div className={\"w-full flex flex-row items-center justify-between\"}>\n <div className={\"basis-2/12 pr-sm\"}>\n <Label\n text={props.label}\n required={props.required}\n disabled={props.disabled}\n invalid={props.invalid}\n weight={\"light\"}\n />\n </div>\n <div className={\"basis-9/12\"}>\n <SliderPrimitiveRenderer {...props} />\n </div>\n <div className={\"basis-1/12 pl-sm text-right\"}>\n <SliderValue value={props.textValue} disabled={props.disabled} />\n </div>\n </div>\n );\n};\n\n/**\n * Slider\n */\ntype SliderProps = FormComponentProps &\n SliderPrimitiveProps & {\n labelPosition?: \"top\" | \"side\";\n };\n\nconst DecoratableSlider = ({\n description,\n note,\n hint,\n validation,\n labelPosition,\n ...props\n}: SliderProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = validationIsValid === false;\n\n const { vm, changeValue, commitValue } = useSlider(props);\n\n if (labelPosition === \"side\") {\n return (\n <div className={\"w-full\"}>\n <FormComponentDescription text={description} disabled={props.disabled} />\n <SliderRendererWithSideValue\n {...props}\n {...vm}\n invalid={invalid}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={props.disabled}\n />\n <FormComponentNote text={note} disabled={props.disabled} />\n </div>\n );\n }\n\n return (\n <div className={\"w-full\"}>\n <FormComponentLabel\n hint={hint}\n text={<Label text={props.label} value={vm.textValue} />}\n disabled={props.disabled}\n required={props.required}\n invalid={invalid}\n />\n <FormComponentDescription text={description} disabled={props.disabled} />\n <SliderPrimitiveRenderer\n {...props}\n {...vm}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={props.disabled}\n />\n <FormComponentNote text={note} disabled={props.disabled} />\n </div>\n );\n};\nconst Slider = makeDecoratable(\"Slider\", DecoratableSlider);\n\nexport { Slider, type SliderProps };\n"],"names":["SliderRendererWithSideValue","props","Label","SliderPrimitiveRenderer","SliderValue","DecoratableSlider","description","note","hint","validation","labelPosition","validationIsValid","validationMessage","invalid","vm","changeValue","commitValue","useSlider","FormComponentDescription","FormComponentErrorMessage","FormComponentNote","FormComponentLabel","Slider","makeDecoratable"],"mappings":";;;;;AAsBA,MAAMA,8BAA8B,CAACC,QAC1B,WAAP,GACI,sCAAC;QAAI,WAAW;qBACZ,sCAAC;QAAI,WAAW;qBACZ,sCAACC,OAAKA;QACF,MAAMD,MAAM,KAAK;QACjB,UAAUA,MAAM,QAAQ;QACxB,UAAUA,MAAM,QAAQ;QACxB,SAASA,MAAM,OAAO;QACtB,QAAQ;uBAGhB,sCAAC;QAAI,WAAW;qBACZ,sCAACE,yBAA4BF,SAAAA,WAAAA,GAEjC,sCAAC;QAAI,WAAW;qBACZ,sCAACG,aAAWA;QAAC,OAAOH,MAAM,SAAS;QAAE,UAAUA,MAAM,QAAQ;;AAc7E,MAAMI,oBAAoB,CAAC,EACvBC,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,aAAa,EACb,GAAGT,OACO;IACV,MAAM,EAAE,SAASU,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGH,cAAc,CAAC;IAClF,MAAMI,UAAUF,AAAsB,UAAtBA;IAEhB,MAAM,EAAEG,EAAE,EAAEC,WAAW,EAAEC,WAAW,EAAE,GAAGC,UAAUhB;IAEnD,IAAIS,AAAkB,WAAlBA,eACA,OAAO,WAAP,GACI,sCAAC;QAAI,WAAW;qBACZ,sCAACQ,0BAAwBA;QAAC,MAAMZ;QAAa,UAAUL,MAAM,QAAQ;sBACrE,sCAACD,
|
|
1
|
+
{"version":3,"file":"Slider/Slider.js","sources":["../../src/Slider/Slider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Label } from \"~/Label/index.js\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport type { SliderPrimitiveProps, SliderPrimitiveRendererProps } from \"./primitives/index.js\";\nimport { SliderPrimitiveRenderer, useSlider, SliderValue } from \"./primitives/index.js\";\nimport type { FormComponentProps } from \"~/FormComponent/index.js\";\nimport {\n FormComponentDescription,\n FormComponentErrorMessage,\n FormComponentLabel,\n FormComponentNote\n} from \"~/FormComponent/index.js\";\n\n/**\n * Slider Renderer with side label\n */\ninterface SliderRendererWithSideValueProps extends SliderPrimitiveRendererProps {\n label?: React.ReactNode;\n invalid?: boolean;\n required?: boolean;\n}\n\nconst SliderRendererWithSideValue = (props: SliderRendererWithSideValueProps) => {\n return (\n <div className={\"w-full flex flex-row items-center justify-between\"}>\n <div className={\"basis-2/12 pr-sm\"}>\n <Label\n text={props.label}\n required={props.required}\n disabled={props.disabled}\n invalid={props.invalid}\n weight={\"light\"}\n />\n </div>\n <div className={\"basis-9/12\"}>\n <SliderPrimitiveRenderer {...props} />\n </div>\n <div className={\"basis-1/12 pl-sm text-right\"}>\n <SliderValue value={props.textValue} disabled={props.disabled} />\n </div>\n </div>\n );\n};\n\n/**\n * Slider\n */\ntype SliderProps = FormComponentProps &\n SliderPrimitiveProps & {\n labelPosition?: \"top\" | \"side\";\n };\n\nconst DecoratableSlider = ({\n description,\n note,\n hint,\n validation,\n labelPosition,\n ...props\n}: SliderProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = validationIsValid === false;\n\n const { vm, changeValue, commitValue } = useSlider(props);\n\n if (labelPosition === \"side\") {\n return (\n <div className={\"w-full\"}>\n <FormComponentDescription text={description} disabled={props.disabled} />\n <SliderRendererWithSideValue\n {...props}\n {...vm}\n invalid={invalid}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={props.disabled}\n />\n <FormComponentNote text={note} disabled={props.disabled} />\n </div>\n );\n }\n\n return (\n <div className={\"w-full\"}>\n <FormComponentLabel\n hint={hint}\n text={<Label text={props.label} value={vm.textValue} />}\n disabled={props.disabled}\n required={props.required}\n invalid={invalid}\n />\n <FormComponentDescription text={description} disabled={props.disabled} />\n <SliderPrimitiveRenderer\n {...props}\n {...vm}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={props.disabled}\n />\n <FormComponentNote text={note} disabled={props.disabled} />\n </div>\n );\n};\nconst Slider = makeDecoratable(\"Slider\", DecoratableSlider);\n\nexport { Slider, type SliderProps };\n"],"names":["SliderRendererWithSideValue","props","Label","SliderPrimitiveRenderer","SliderValue","DecoratableSlider","description","note","hint","validation","labelPosition","validationIsValid","validationMessage","invalid","vm","changeValue","commitValue","useSlider","FormComponentDescription","FormComponentErrorMessage","FormComponentNote","FormComponentLabel","Slider","makeDecoratable"],"mappings":";;;;;AAsBA,MAAMA,8BAA8B,CAACC,QAC1B,WAAP,GACI,sCAAC;QAAI,WAAW;qBACZ,sCAAC;QAAI,WAAW;qBACZ,sCAACC,OAAKA;QACF,MAAMD,MAAM,KAAK;QACjB,UAAUA,MAAM,QAAQ;QACxB,UAAUA,MAAM,QAAQ;QACxB,SAASA,MAAM,OAAO;QACtB,QA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BAAyBA;QACtB,MAAMP;QACN,SAASC;QACT,UAAUZ,MAAM,QAAQ;sBAE5B,sCAACmB,mBAAiBA;QAAC,MAAMb;QAAM,UAAUN,MAAM,QAAQ;;AAGnE;AACA,MAAMqB,SAASC,gBAAgB,UAAUlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider/primitives/SliderPrimitive.js","sources":["../../../src/Slider/primitives/SliderPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { Slider as SliderPrimitives } from \"radix-ui\";\nimport { useSlider } from \"./useSlider.js\";\nimport { SliderRoot, SliderThumb, SliderTrack, type SliderThumbProps } from \"./components/index.js\";\n\ntype SliderRootProps = Omit<SliderPrimitives.SliderProps, \"min\"> & {\n min: number;\n};\n\ntype SliderPrimitiveRendererProps = SliderRootProps & SliderThumbProps;\n\nconst SliderPrimitiveRenderer = ({\n tooltipSide,\n textValue,\n showTooltip,\n ...sliderProps\n}: SliderPrimitiveVm) => {\n return (\n <div className={\"flex h-md w-full\"}>\n <SliderRoot {...sliderProps}>\n <SliderTrack />\n <SliderThumb\n textValue={textValue}\n showTooltip={showTooltip}\n tooltipSide={tooltipSide}\n />\n </SliderRoot>\n </div>\n );\n};\n\ninterface SliderPrimitiveProps extends Omit<\n SliderPrimitives.SliderProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"onValueCommit\"\n> {\n onValueChange: (value: number) => void;\n onValueCommit?: (value: number) => void;\n showTooltip?: boolean;\n tooltipSide?: \"top\" | \"bottom\";\n transformValue?: (value: number) => string;\n value?: number;\n}\n\ntype SliderPrimitiveVm = SliderRootProps & SliderThumbProps;\n\nconst SliderPrimitive = (props: SliderPrimitiveProps) => {\n const { transformValue, ...restProps } = props;\n const { vm, changeValue, commitValue } = useSlider({ ...restProps, transformValue });\n\n return (\n <SliderPrimitiveRenderer\n {...restProps}\n {...vm}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n );\n};\n\nexport {\n SliderPrimitive,\n SliderPrimitiveRenderer,\n type SliderPrimitiveVm,\n type SliderPrimitiveProps,\n type SliderPrimitiveRendererProps\n};\n"],"names":["SliderPrimitiveRenderer","tooltipSide","textValue","showTooltip","sliderProps","SliderRoot","SliderTrack","SliderThumb","SliderPrimitive","props","transformValue","restProps","vm","changeValue","commitValue","useSlider"],"mappings":";;;AAWA,MAAMA,0BAA0B,CAAC,EAC7BC,WAAW,EACXC,SAAS,EACTC,WAAW,EACX,GAAGC,aACa,GACT,WAAP,GACI,sCAAC;QAAI,WAAW;qBACZ,sCAACC,YAAeD,aAAAA,WAAAA,GACZ,sCAACE,aAAWA,OAAAA,WAAAA,GACZ,sCAACC,aAAWA;QACR,WAAWL;QACX,aAAaC;QACb,aAAaF;;AAqBjC,MAAMO,kBAAkB,CAACC;IACrB,MAAM,EAAEC,cAAc,EAAE,GAAGC,WAAW,GAAGF;IACzC,MAAM,EAAEG,EAAE,EAAEC,WAAW,EAAEC,WAAW,EAAE,GAAGC,UAAU;QAAE,GAAGJ,SAAS;QAAED;IAAe;IAElF,OAAO,WAAP,GACI,sCAACV,
|
|
1
|
+
{"version":3,"file":"Slider/primitives/SliderPrimitive.js","sources":["../../../src/Slider/primitives/SliderPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { Slider as SliderPrimitives } from \"radix-ui\";\nimport { useSlider } from \"./useSlider.js\";\nimport { SliderRoot, SliderThumb, SliderTrack, type SliderThumbProps } from \"./components/index.js\";\n\ntype SliderRootProps = Omit<SliderPrimitives.SliderProps, \"min\"> & {\n min: number;\n};\n\ntype SliderPrimitiveRendererProps = SliderRootProps & SliderThumbProps;\n\nconst SliderPrimitiveRenderer = ({\n tooltipSide,\n textValue,\n showTooltip,\n ...sliderProps\n}: SliderPrimitiveVm) => {\n return (\n <div className={\"flex h-md w-full\"}>\n <SliderRoot {...sliderProps}>\n <SliderTrack />\n <SliderThumb\n textValue={textValue}\n showTooltip={showTooltip}\n tooltipSide={tooltipSide}\n />\n </SliderRoot>\n </div>\n );\n};\n\ninterface SliderPrimitiveProps extends Omit<\n SliderPrimitives.SliderProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"onValueCommit\"\n> {\n onValueChange: (value: number) => void;\n onValueCommit?: (value: number) => void;\n showTooltip?: boolean;\n tooltipSide?: \"top\" | \"bottom\";\n transformValue?: (value: number) => string;\n value?: number;\n}\n\ntype SliderPrimitiveVm = SliderRootProps & SliderThumbProps;\n\nconst SliderPrimitive = (props: SliderPrimitiveProps) => {\n const { transformValue, ...restProps } = props;\n const { vm, changeValue, commitValue } = useSlider({ ...restProps, transformValue });\n\n return (\n <SliderPrimitiveRenderer\n {...restProps}\n {...vm}\n onValueChange={changeValue}\n onValueCommit={commitValue}\n />\n );\n};\n\nexport {\n SliderPrimitive,\n SliderPrimitiveRenderer,\n type SliderPrimitiveVm,\n type SliderPrimitiveProps,\n type SliderPrimitiveRendererProps\n};\n"],"names":["SliderPrimitiveRenderer","tooltipSide","textValue","showTooltip","sliderProps","SliderRoot","SliderTrack","SliderThumb","SliderPrimitive","props","transformValue","restProps","vm","changeValue","commitValue","useSlider"],"mappings":";;;AAWA,MAAMA,0BAA0B,CAAC,EAC7BC,WAAW,EACXC,SAAS,EACTC,WAAW,EACX,GAAGC,aACa,GACT,WAAP,GACI,sCAAC;QAAI,WAAW;qBACZ,sCAACC,YAAeD,aAAAA,WAAAA,GACZ,sCAACE,aAAWA,OAAAA,WAAAA,GACZ,sCAACC,aAAWA;QACR,WAAWL;QACX,aAAaC;QACb,aAAaF;;AAqBjC,MAAMO,kBAAkB,CAACC;IACrB,MAAM,EAAEC,cAAc,EAAE,GAAGC,WAAW,GAAGF;IACzC,MAAM,EAAEG,EAAE,EAAEC,WAAW,EAAEC,WAAW,EAAE,GAAGC,UAAU;QAAE,GAAGJ,SAAS;QAAED;IAAe;IAElF,OAAO,WAAP,GACI,sCAACV,yBAAAA;QACI,GAAGW,SAAS;QACZ,GAAGC,EAAE;QACN,eAAeC;QACf,eAAeC;;AAG3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SteppedProgress/domains/ProgressItemState.js","sources":["../../../src/SteppedProgress/domains/ProgressItemState.ts"],"sourcesContent":["export enum ProgressItemState {\n IN_PROGRESS = \"IN_PROGRESS\",\n IDLE = \"IDLE\",\n COMPLETED = \"COMPLETED\",\n COMPLETED_AFFIRMATIVE = \"COMPLETED_AFFIRMATIVE\"\n}\n"],"names":["ProgressItemState"],"mappings":"AAAO,IAAKA,sCAAiBA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"SteppedProgress/domains/ProgressItemState.js","sources":["../../../src/SteppedProgress/domains/ProgressItemState.ts"],"sourcesContent":["export enum ProgressItemState {\n IN_PROGRESS = \"IN_PROGRESS\",\n IDLE = \"IDLE\",\n COMPLETED = \"COMPLETED\",\n COMPLETED_AFFIRMATIVE = \"COMPLETED_AFFIRMATIVE\"\n}\n"],"names":["ProgressItemState"],"mappings":"AAAO,IAAKA,sCAAiBA,WAAAA,GAAAA,SAAAA,iBAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch/primitives/SwitchPrimitive.js","sources":["../../../src/Switch/primitives/SwitchPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitives } from \"radix-ui\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\nimport { Label } from \"~/Label/index.js\";\nimport { useSwitch } from \"./useSwitch.js\";\nimport type { SwitchItemDto, SwitchItemFormatted } from \"../domains/index.js\";\n\n/**\n * Switch Renderer\n */\n\nconst switchVariants = cva(\"inline-flex items-start space-x-sm\", {\n variants: {\n labelPosition: {\n start: \"\",\n end: \"flex-row-reverse space-x-sm-extra space-x-reverse\"\n }\n },\n defaultVariants: {\n labelPosition: \"start\"\n }\n});\n\ntype SwitchPrimitiveProps = Omit<\n SwitchPrimitives.SwitchProps,\n \"defaultChecked\" | \"onCheckedChange\" | \"onChange\"\n> &\n VariantProps<typeof switchVariants> &\n SwitchItemDto & {\n onChange?: (checked: boolean) => void;\n };\n\ntype SwitchPrimitivVm = {\n item?: SwitchItemFormatted;\n};\n\ntype SwitchRendererProps = Omit<SwitchPrimitiveProps, \"onCheckedChange\"> &\n NonNullable<SwitchPrimitivVm[\"item\"]> & {\n changeChecked: (checked: boolean) => void;\n description?: React.ReactNode;\n };\n\nconst SwitchRenderer = ({\n id,\n label,\n changeChecked,\n description,\n className,\n labelPosition,\n disabled,\n required,\n checked\n}: SwitchRendererProps) => {\n return (\n <div className={cn(switchVariants({ labelPosition }), className)}>\n {label && (\n <Label\n htmlFor={id}\n text={label}\n disabled={disabled}\n required={required}\n hint={description}\n weight={\"light\"}\n className={\"text-md\"}\n />\n )}\n <SwitchPrimitives.Root\n id={id}\n checked={checked}\n className={cn([\n \"peer inline-flex h-md w-[26px] shrink-0 cursor-pointer items-center rounded-xxl border-sm transition-colors\",\n \"border-transparent data-[state=checked]:bg-secondary data-[state=unchecked]:bg-neutral-strong\",\n \"focus-visible:outline-none focus-visible:border-success focus-visible:ring-lg focus-visible:ring-primary-dimmed\",\n \"disabled:cursor-not-allowed disabled:bg-neutral-muted disabled:data-[state=checked]:bg-neutral-muted\",\n // Nudges the switch down to line up with the inline label's text.\n label && \"mt-xxs\"\n ])}\n disabled={disabled}\n onCheckedChange={changeChecked}\n >\n <SwitchPrimitives.Thumb\n className={cn(\n \"pointer-events-none block h-sm-plus w-sm-plus rounded-xxl bg-neutral-base shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-sm-extra data-[state=unchecked]:translate-x-xxs\"\n )}\n />\n </SwitchPrimitives.Root>\n </div>\n );\n};\n\n/**\n * Switch\n */\nconst DecoratableSwitchPrimitive = (props: SwitchPrimitiveProps) => {\n const { vm, changeChecked } = useSwitch(props);\n\n if (!vm.item) {\n return null;\n }\n\n return <SwitchRenderer {...props} {...vm.item} changeChecked={changeChecked} />;\n};\nconst SwitchPrimitive = makeDecoratable(\"SwitchPrimitive\", DecoratableSwitchPrimitive);\n\nexport { SwitchPrimitive, type SwitchPrimitiveProps, type SwitchPrimitivVm };\n"],"names":["switchVariants","cva","SwitchRenderer","id","label","changeChecked","description","className","labelPosition","disabled","required","checked","cn","Label","SwitchPrimitives","DecoratableSwitchPrimitive","props","vm","useSwitch","SwitchPrimitive","makeDecoratable"],"mappings":";;;;;AAWA,MAAMA,iBAAiBC,IAAI,sCAAsC;IAC7D,UAAU;QACN,eAAe;YACX,OAAO;YACP,KAAK;QACT;IACJ;IACA,iBAAiB;QACb,eAAe;IACnB;AACJ;AAqBA,MAAMC,iBAAiB,CAAC,EACpBC,EAAE,EACFC,KAAK,EACLC,aAAa,EACbC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACW,GACX,WAAP,GACI,sCAAC;QAAI,WAAWC,GAAGZ,eAAe;YAAEQ;QAAc,IAAID;OACjDH,SAAS,WAATA,GACG,sCAACS,OAAKA;QACF,SAASV;QACT,MAAMC;QACN,UAAUK;QACV,UAAUC;QACV,MAAMJ;QACN,QAAQ;QACR,WAAW;sBAGnB,sCAACQ,OAAAA,IAAqB;QAClB,IAAIX;QACJ,SAASQ;QACT,WAAWC,GAAG;YACV;YACA;YACA;YACA;YAEAR,SAAS;SACZ;QACD,UAAUK;QACV,iBAAiBJ;qBAEjB,sCAACS,OAAAA,KAAsB;QACnB,WAAWF,GACP;;AAWxB,MAAMG,6BAA6B,CAACC;IAChC,MAAM,EAAEC,EAAE,EAAEZ,aAAa,EAAE,GAAGa,UAAUF;IAExC,IAAI,CAACC,GAAG,IAAI,EACR,OAAO;IAGX,OAAO,WAAP,GAAO,sCAACf,
|
|
1
|
+
{"version":3,"file":"Switch/primitives/SwitchPrimitive.js","sources":["../../../src/Switch/primitives/SwitchPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitives } from \"radix-ui\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\nimport { Label } from \"~/Label/index.js\";\nimport { useSwitch } from \"./useSwitch.js\";\nimport type { SwitchItemDto, SwitchItemFormatted } from \"../domains/index.js\";\n\n/**\n * Switch Renderer\n */\n\nconst switchVariants = cva(\"inline-flex items-start space-x-sm\", {\n variants: {\n labelPosition: {\n start: \"\",\n end: \"flex-row-reverse space-x-sm-extra space-x-reverse\"\n }\n },\n defaultVariants: {\n labelPosition: \"start\"\n }\n});\n\ntype SwitchPrimitiveProps = Omit<\n SwitchPrimitives.SwitchProps,\n \"defaultChecked\" | \"onCheckedChange\" | \"onChange\"\n> &\n VariantProps<typeof switchVariants> &\n SwitchItemDto & {\n onChange?: (checked: boolean) => void;\n };\n\ntype SwitchPrimitivVm = {\n item?: SwitchItemFormatted;\n};\n\ntype SwitchRendererProps = Omit<SwitchPrimitiveProps, \"onCheckedChange\"> &\n NonNullable<SwitchPrimitivVm[\"item\"]> & {\n changeChecked: (checked: boolean) => void;\n description?: React.ReactNode;\n };\n\nconst SwitchRenderer = ({\n id,\n label,\n changeChecked,\n description,\n className,\n labelPosition,\n disabled,\n required,\n checked\n}: SwitchRendererProps) => {\n return (\n <div className={cn(switchVariants({ labelPosition }), className)}>\n {label && (\n <Label\n htmlFor={id}\n text={label}\n disabled={disabled}\n required={required}\n hint={description}\n weight={\"light\"}\n className={\"text-md\"}\n />\n )}\n <SwitchPrimitives.Root\n id={id}\n checked={checked}\n className={cn([\n \"peer inline-flex h-md w-[26px] shrink-0 cursor-pointer items-center rounded-xxl border-sm transition-colors\",\n \"border-transparent data-[state=checked]:bg-secondary data-[state=unchecked]:bg-neutral-strong\",\n \"focus-visible:outline-none focus-visible:border-success focus-visible:ring-lg focus-visible:ring-primary-dimmed\",\n \"disabled:cursor-not-allowed disabled:bg-neutral-muted disabled:data-[state=checked]:bg-neutral-muted\",\n // Nudges the switch down to line up with the inline label's text.\n label && \"mt-xxs\"\n ])}\n disabled={disabled}\n onCheckedChange={changeChecked}\n >\n <SwitchPrimitives.Thumb\n className={cn(\n \"pointer-events-none block h-sm-plus w-sm-plus rounded-xxl bg-neutral-base shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-sm-extra data-[state=unchecked]:translate-x-xxs\"\n )}\n />\n </SwitchPrimitives.Root>\n </div>\n );\n};\n\n/**\n * Switch\n */\nconst DecoratableSwitchPrimitive = (props: SwitchPrimitiveProps) => {\n const { vm, changeChecked } = useSwitch(props);\n\n if (!vm.item) {\n return null;\n }\n\n return <SwitchRenderer {...props} {...vm.item} changeChecked={changeChecked} />;\n};\nconst SwitchPrimitive = makeDecoratable(\"SwitchPrimitive\", DecoratableSwitchPrimitive);\n\nexport { SwitchPrimitive, type SwitchPrimitiveProps, type SwitchPrimitivVm };\n"],"names":["switchVariants","cva","SwitchRenderer","id","label","changeChecked","description","className","labelPosition","disabled","required","checked","cn","Label","SwitchPrimitives","DecoratableSwitchPrimitive","props","vm","useSwitch","SwitchPrimitive","makeDecoratable"],"mappings":";;;;;AAWA,MAAMA,iBAAiBC,IAAI,sCAAsC;IAC7D,UAAU;QACN,eAAe;YACX,OAAO;YACP,KAAK;QACT;IACJ;IACA,iBAAiB;QACb,eAAe;IACnB;AACJ;AAqBA,MAAMC,iBAAiB,CAAC,EACpBC,EAAE,EACFC,KAAK,EACLC,aAAa,EACbC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACW,GACX,WAAP,GACI,sCAAC;QAAI,WAAWC,GAAGZ,eAAe;YAAEQ;QAAc,IAAID;OACjDH,SAAS,WAATA,GACG,sCAACS,OAAKA;QACF,SAASV;QACT,MAAMC;QACN,UAAUK;QACV,UAAUC;QACV,MAAMJ;QACN,QAAQ;QACR,WAAW;sBAGnB,sCAACQ,OAAAA,IAAqB;QAClB,IAAIX;QACJ,SAASQ;QACT,WAAWC,GAAG;YACV;YACA;YACA;YACA;YAEAR,SAAS;SACZ;QACD,UAAUK;QACV,iBAAiBJ;qBAEjB,sCAACS,OAAAA,KAAsB;QACnB,WAAWF,GACP;;AAWxB,MAAMG,6BAA6B,CAACC;IAChC,MAAM,EAAEC,EAAE,EAAEZ,aAAa,EAAE,GAAGa,UAAUF;IAExC,IAAI,CAACC,GAAG,IAAI,EACR,OAAO;IAGX,OAAO,WAAP,GAAO,sCAACf,gBAAAA;QAAgB,GAAGc,KAAK;QAAG,GAAGC,GAAG,IAAI;QAAE,eAAeZ;;AAClE;AACA,MAAMc,kBAAkBC,gBAAgB,mBAAmBL"}
|
package/Tabs/Tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs/Tabs.js","sources":["../../src/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { Tabs as TabsPrimitive } from \"radix-ui\";\nimport { cn, makeDecoratable, type VariantProps, withStaticProps } from \"~/utils.js\";\nimport type { ITabsContext, TabItem, TabProps } from \"./components/index.js\";\nimport { Content, List, Tab, TabsContext, Trigger, tabListVariants } from \"./components/index.js\";\n\nconst Root = TabsPrimitive.Root;\n\ninterface TabsProps extends Omit<TabsPrimitive.TabsProps, \"children\"> {\n tabs: React.ReactElement<TabProps>[];\n size?: VariantProps<typeof tabListVariants>[\"size\"];\n spacing?: VariantProps<typeof tabListVariants>[\"spacing\"];\n separator?: VariantProps<typeof tabListVariants>[\"separator\"];\n loading?: boolean;\n /**\n * Controls rendered at the end of the tab row, e.g. a filter checkbox or a button.\n */\n actions?: React.ReactNode;\n}\n\nconst DecoratableTabs = ({\n defaultValue: initialValue,\n size,\n spacing,\n separator,\n loading,\n actions,\n tabs: tabComponents,\n ...props\n}: TabsProps) => {\n const [tabs, setTabs] = useState<TabItem[]>([]);\n\n const defaultValue = useMemo(() => {\n return (\n initialValue ||\n tabComponents.find(tab => !tab.props.disabled && tab.props.visible !== false)?.props\n .value\n );\n }, [initialValue, tabComponents]);\n\n const triggers = useMemo(() => {\n const triggerList = tabs.map(tab => (\n <Trigger\n data-testid={tab[\"data-testid\"]}\n disabled={tab.disabled}\n icon={tab.icon}\n key={tab.id}\n loading={loading}\n size={size}\n text={tab.trigger}\n value={tab.value}\n visible={tab.visible}\n />\n ));\n const listKey = tabs.map(tab => tab.id).join(\";\");\n\n if (!actions) {\n return (\n <List key={listKey} size={size} spacing={spacing} separator={separator}>\n {triggerList}\n </List>\n );\n }\n\n // Actions sit outside the tablist, so arrow keys only move between tabs.\n return (\n <div className={cn(tabListVariants({ size, spacing, separator }))}>\n <List key={listKey} size={size} className={\"w-auto\"}>\n {triggerList}\n </List>\n <div className={\"ml-auto flex items-center gap-sm\"}>{actions}</div>\n </div>\n );\n }, [tabs, size, spacing, separator, loading, actions]);\n\n const contents = useMemo(\n () =>\n tabs.map(tab => (\n <Content\n key={tab.id}\n value={tab.value}\n content={tab.content}\n spacing={tab.spacing ?? spacing}\n className={tab.className}\n />\n )),\n [tabs, spacing]\n );\n\n const context: ITabsContext = useMemo(\n () => ({\n addTab(props) {\n setTabs(tabs => {\n const existingIndex = tabs.findIndex(tab => tab.value === props.value);\n if (existingIndex > -1) {\n return [\n ...tabs.slice(0, existingIndex),\n props,\n ...tabs.slice(existingIndex + 1)\n ];\n }\n return [...tabs, props];\n });\n },\n removeTab(id) {\n setTabs(tabs => tabs.filter(tab => tab.id !== id));\n }\n }),\n [setTabs]\n );\n\n return (\n <Root {...props} defaultValue={defaultValue}>\n {triggers}\n {contents}\n <TabsContext.Provider value={context}>{tabComponents}</TabsContext.Provider>\n </Root>\n );\n};\n\nconst BaseTabs = makeDecoratable(\"Tabs\", DecoratableTabs);\n\nconst Tabs = withStaticProps(BaseTabs, {\n Tab\n});\n\nexport { Tabs, type TabsProps };\n"],"names":["Root","TabsPrimitive","DecoratableTabs","initialValue","size","spacing","separator","loading","actions","tabComponents","props","tabs","setTabs","useState","defaultValue","useMemo","tab","triggers","triggerList","Trigger","listKey","List","cn","tabListVariants","contents","Content","context","existingIndex","id","TabsContext","BaseTabs","makeDecoratable","Tabs","withStaticProps","Tab"],"mappings":";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AAMgB,WAAWT,QACb,IACIJ,KAAK,GAAG,CAACK,CAAAA,MAAAA,WAAAA,GACL,oBAACS,SAAOA;gBACJ,KAAKT,IAAI,EAAE;gBACX,OAAOA,IAAI,KAAK;gBAChB,SAASA,IAAI,OAAO;gBACpB,SAASA,IAAI,OAAO,IAAIX;gBACxB,WAAWW,IAAI,SAAS;iBAGpC;QAACL;QAAMN;KAAQ;IAGnB,MAAMqB,UAAwBX,QAC1B,IAAO;YACH,QAAOL,KAAK;gBACRE,QAAQD,CAAAA;oBACJ,MAAMgB,gBAAgBhB,KAAK,SAAS,CAACK,CAAAA,MAAOA,IAAI,KAAK,KAAKN,MAAM,KAAK;oBACrE,IAAIiB,gBAAgB,IAChB,OAAO;2BACAhB,KAAK,KAAK,CAAC,GAAGgB;wBACjBjB;2BACGC,KAAK,KAAK,CAACgB,gBAAgB;qBACjC;oBAEL,OAAO;2BAAIhB;wBAAMD;qBAAM;gBAC3B;YACJ;YACA,WAAUkB,EAAE;gBACRhB,QAAQD,CAAAA,OAAQA,KAAK,MAAM,CAACK,CAAAA,MAAOA,IAAI,EAAE,KAAKY;YAClD;QACJ,IACA;QAAChB;KAAQ;IAGb,OAAO,WAAP,GACI,oBAACZ,
|
|
1
|
+
{"version":3,"file":"Tabs/Tabs.js","sources":["../../src/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { Tabs as TabsPrimitive } from \"radix-ui\";\nimport { cn, makeDecoratable, type VariantProps, withStaticProps } from \"~/utils.js\";\nimport type { ITabsContext, TabItem, TabProps } from \"./components/index.js\";\nimport { Content, List, Tab, TabsContext, Trigger, tabListVariants } from \"./components/index.js\";\n\nconst Root = TabsPrimitive.Root;\n\ninterface TabsProps extends Omit<TabsPrimitive.TabsProps, \"children\"> {\n tabs: React.ReactElement<TabProps>[];\n size?: VariantProps<typeof tabListVariants>[\"size\"];\n spacing?: VariantProps<typeof tabListVariants>[\"spacing\"];\n separator?: VariantProps<typeof tabListVariants>[\"separator\"];\n loading?: boolean;\n /**\n * Controls rendered at the end of the tab row, e.g. a filter checkbox or a button.\n */\n actions?: React.ReactNode;\n}\n\nconst DecoratableTabs = ({\n defaultValue: initialValue,\n size,\n spacing,\n separator,\n loading,\n actions,\n tabs: tabComponents,\n ...props\n}: TabsProps) => {\n const [tabs, setTabs] = useState<TabItem[]>([]);\n\n const defaultValue = useMemo(() => {\n return (\n initialValue ||\n tabComponents.find(tab => !tab.props.disabled && tab.props.visible !== false)?.props\n .value\n );\n }, [initialValue, tabComponents]);\n\n const triggers = useMemo(() => {\n const triggerList = tabs.map(tab => (\n <Trigger\n data-testid={tab[\"data-testid\"]}\n disabled={tab.disabled}\n icon={tab.icon}\n key={tab.id}\n loading={loading}\n size={size}\n text={tab.trigger}\n value={tab.value}\n visible={tab.visible}\n />\n ));\n const listKey = tabs.map(tab => tab.id).join(\";\");\n\n if (!actions) {\n return (\n <List key={listKey} size={size} spacing={spacing} separator={separator}>\n {triggerList}\n </List>\n );\n }\n\n // Actions sit outside the tablist, so arrow keys only move between tabs.\n return (\n <div className={cn(tabListVariants({ size, spacing, separator }))}>\n <List key={listKey} size={size} className={\"w-auto\"}>\n {triggerList}\n </List>\n <div className={\"ml-auto flex items-center gap-sm\"}>{actions}</div>\n </div>\n );\n }, [tabs, size, spacing, separator, loading, actions]);\n\n const contents = useMemo(\n () =>\n tabs.map(tab => (\n <Content\n key={tab.id}\n value={tab.value}\n content={tab.content}\n spacing={tab.spacing ?? spacing}\n className={tab.className}\n />\n )),\n [tabs, spacing]\n );\n\n const context: ITabsContext = useMemo(\n () => ({\n addTab(props) {\n setTabs(tabs => {\n const existingIndex = tabs.findIndex(tab => tab.value === props.value);\n if (existingIndex > -1) {\n return [\n ...tabs.slice(0, existingIndex),\n props,\n ...tabs.slice(existingIndex + 1)\n ];\n }\n return [...tabs, props];\n });\n },\n removeTab(id) {\n setTabs(tabs => tabs.filter(tab => tab.id !== id));\n }\n }),\n [setTabs]\n );\n\n return (\n <Root {...props} defaultValue={defaultValue}>\n {triggers}\n {contents}\n <TabsContext.Provider value={context}>{tabComponents}</TabsContext.Provider>\n </Root>\n );\n};\n\nconst BaseTabs = makeDecoratable(\"Tabs\", DecoratableTabs);\n\nconst Tabs = withStaticProps(BaseTabs, {\n Tab\n});\n\nexport { Tabs, type TabsProps };\n"],"names":["Root","TabsPrimitive","DecoratableTabs","initialValue","size","spacing","separator","loading","actions","tabComponents","props","tabs","setTabs","useState","defaultValue","useMemo","tab","triggers","triggerList","Trigger","listKey","List","cn","tabListVariants","contents","Content","context","existingIndex","id","TabsContext","BaseTabs","makeDecoratable","Tabs","withStaticProps","Tab"],"mappings":";;;;AAMA,MAAMA,OAAOC,KAAAA,IAAkB;AAc/B,MAAMC,kBAAkB,CAAC,EACrB,cAAcC,YAAY,EAC1BC,IAAI,EACJC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,OAAO,EACP,MAAMC,aAAa,EACnB,GAAGC,OACK;IACR,MAAM,CAACC,MAAMC,QAAQ,GAAGC,SAAoB,EAAE;IAE9C,MAAMC,eAAeC,QAAQ,IAErBZ,gBACAM,cAAc,IAAI,CAACO,CAAAA,MAAO,CAACA,IAAI,KAAK,CAAC,QAAQ,IAAIA,AAAsB,UAAtBA,IAAI,KAAK,CAAC,OAAO,GAAa,MAC1E,OAEV;QAACb;QAAcM;KAAc;IAEhC,MAAMQ,WAAWF,QAAQ;QACrB,MAAMG,cAAcP,KAAK,GAAG,CAACK,CAAAA,MAAAA,WAAAA,GACzB,oBAACG,SAAOA;gBACJ,eAAaH,GAAG,CAAC,cAAc;gBAC/B,UAAUA,IAAI,QAAQ;gBACtB,MAAMA,IAAI,IAAI;gBACd,KAAKA,IAAI,EAAE;gBACX,SAAST;gBACT,MAAMH;gBACN,MAAMY,IAAI,OAAO;gBACjB,OAAOA,IAAI,KAAK;gBAChB,SAASA,IAAI,OAAO;;QAG5B,MAAMI,UAAUT,KAAK,GAAG,CAACK,CAAAA,MAAOA,IAAI,EAAE,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A,GACD,oBAACK,YAAY,QAAQ;QAAC,OAAOH;OAAUjB;AAGnD;AAEA,MAAMqB,WAAWC,gBAAgB,QAAQ7B;AAEzC,MAAM8B,YAAOC,gBAAgBH,UAAU;IACnCI,KAAGA;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs/components/Context.js","sources":["../../../src/Tabs/components/Context.tsx"],"sourcesContent":["import { createContext } from \"react\";\nimport type { TabItem } from \"./Tab.js\";\n\ninterface ITabsContext {\n addTab(props: TabItem): void;\n removeTab(id: string): void;\n}\n\nconst TabsContext = createContext<ITabsContext | undefined>(undefined);\n\nexport { TabsContext, type ITabsContext };\n"],"names":["TabsContext","createContext","undefined"],"mappings":";AAQA,MAAMA,cAAc,
|
|
1
|
+
{"version":3,"file":"Tabs/components/Context.js","sources":["../../../src/Tabs/components/Context.tsx"],"sourcesContent":["import { createContext } from \"react\";\nimport type { TabItem } from \"./Tab.js\";\n\ninterface ITabsContext {\n addTab(props: TabItem): void;\n removeTab(id: string): void;\n}\n\nconst TabsContext = createContext<ITabsContext | undefined>(undefined);\n\nexport { TabsContext, type ITabsContext };\n"],"names":["TabsContext","createContext","undefined"],"mappings":";AAQA,MAAMA,cAAc,WAAdA,GAAcC,cAAwCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast/components/ToastIcon.js","sources":["../../../src/Toast/components/ToastIcon.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as NotificationsIconActive } from \"@webiny/icons/notifications_active.svg\";\nimport { Icon as BaseIcon } from \"~/Icon/index.js\";\n\nconst ToastNotificationIcon = (\n <BaseIcon\n icon={<NotificationsIconActive />}\n label={\"Notification\"}\n size={\"md\"}\n color={\"accent\"}\n />\n);\n\ntype ToastIconProps = {\n icon?: React.ReactElement<typeof BaseIcon>;\n};\n\nconst ToastIcon = ({ icon }: ToastIconProps) => {\n return (\n <span>\n {React.isValidElement(icon)\n ? React.cloneElement(icon, { ...ToastNotificationIcon.props, ...icon.props })\n : React.cloneElement(ToastNotificationIcon)}\n </span>\n );\n};\n\nexport { ToastIcon, type ToastIconProps };\n"],"names":["ToastNotificationIcon","BaseIcon","NotificationsIconActive","ToastIcon","icon","React"],"mappings":";;;AAIA,MAAMA,wBAAwB,
|
|
1
|
+
{"version":3,"file":"Toast/components/ToastIcon.js","sources":["../../../src/Toast/components/ToastIcon.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as NotificationsIconActive } from \"@webiny/icons/notifications_active.svg\";\nimport { Icon as BaseIcon } from \"~/Icon/index.js\";\n\nconst ToastNotificationIcon = (\n <BaseIcon\n icon={<NotificationsIconActive />}\n label={\"Notification\"}\n size={\"md\"}\n color={\"accent\"}\n />\n);\n\ntype ToastIconProps = {\n icon?: React.ReactElement<typeof BaseIcon>;\n};\n\nconst ToastIcon = ({ icon }: ToastIconProps) => {\n return (\n <span>\n {React.isValidElement(icon)\n ? React.cloneElement(icon, { ...ToastNotificationIcon.props, ...icon.props })\n : React.cloneElement(ToastNotificationIcon)}\n </span>\n );\n};\n\nexport { ToastIcon, type ToastIconProps };\n"],"names":["ToastNotificationIcon","BaseIcon","NotificationsIconActive","ToastIcon","icon","React"],"mappings":";;;AAIA,MAAMA,wBAAwB,WAAxBA,GACF,oBAACC,MAAQA;IACL,oBAAM,oBAACC,gBAAuBA;IAC9B,OAAO;IACP,MAAM;IACN,OAAO;;AAQf,MAAMC,YAAY,CAAC,EAAEC,IAAI,EAAkB,GAChC,WAAP,GACI,oBAAC,4BACIC,MAAAA,cAAoB,CAACD,QAAAA,WAAAA,GAChBC,MAAAA,YAAkB,CAACD,MAAM;QAAE,GAAGJ,sBAAsB,KAAK;QAAE,GAAGI,KAAK,KAAK;IAAC,mBACzEC,MAAAA,YAAkB,CAACL"}
|