@webiny/admin-ui 6.6.0-alpha.1 → 6.6.0-alpha.10
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/Alert/Alert.d.ts +1 -20
- package/Alert/Alert.js.map +1 -1
- package/AutoComplete/primitives/AutoCompletePrimitive.d.ts +8 -2
- package/AutoComplete/primitives/AutoCompletePrimitive.js +1 -0
- package/AutoComplete/primitives/AutoCompletePrimitive.js.map +1 -1
- package/Breadcrumbs/Breadcrumbs.js +2 -2
- package/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/Button/Button.d.ts +1 -1
- package/Button/Button.js +14 -0
- package/Button/Button.js.map +1 -1
- package/Button/Button.mdx +13 -0
- package/Button/Button.stories.d.ts +1 -0
- package/Button/Button.stories.js +10 -2
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.test.d.ts +1 -0
- package/Button/Button.test.js +28 -0
- package/Button/Button.test.js.map +1 -0
- package/Checkbox/primitives/presenters/CheckboxPresenter.js +5 -2
- package/Checkbox/primitives/presenters/CheckboxPresenter.js.map +1 -1
- package/Checkbox/primitives/presenters/CheckboxPresenter.jsxLabel.test.d.ts +1 -0
- package/Checkbox/primitives/presenters/CheckboxPresenter.jsxLabel.test.js +61 -0
- package/Checkbox/primitives/presenters/CheckboxPresenter.jsxLabel.test.js.map +1 -0
- package/CheckboxGroup/CheckboxGroup.js +4 -1
- package/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/CheckboxGroup/primitives/CheckboxGroupPrimitive.d.ts +6 -1
- package/CheckboxGroup/primitives/CheckboxGroupPrimitive.js +5 -2
- package/CheckboxGroup/primitives/CheckboxGroupPrimitive.js.map +1 -1
- package/CheckboxGroup/primitives/presenters/CheckboxGroupPresenter.js +5 -2
- package/CheckboxGroup/primitives/presenters/CheckboxGroupPresenter.js.map +1 -1
- package/CheckboxGroup/primitives/presenters/CheckboxGroupPresenter.jsxLabel.test.d.ts +1 -0
- package/CheckboxGroup/primitives/presenters/CheckboxGroupPresenter.jsxLabel.test.js +108 -0
- package/CheckboxGroup/primitives/presenters/CheckboxGroupPresenter.jsxLabel.test.js.map +1 -0
- package/Code/Code.d.ts +29 -0
- package/Code/Code.js +23 -0
- package/Code/Code.js.map +1 -0
- package/Code/index.d.ts +1 -0
- package/Code/index.js +1 -0
- package/CodeEditor/CodeEditor.js +6 -0
- package/CodeEditor/CodeEditor.js.map +1 -1
- package/ColorPicker/ColorPicker.js +4 -1
- package/ColorPicker/ColorPicker.js.map +1 -1
- package/ColorPicker/primitives/ColorPickerPrimitive.d.ts +1 -1
- package/ColorPicker/primitives/ColorPickerPrimitive.js +3 -1
- package/ColorPicker/primitives/ColorPickerPrimitive.js.map +1 -1
- package/Command/components/List.d.ts +1 -1
- package/Command/components/List.js +9 -5
- package/Command/components/List.js.map +1 -1
- package/DataTable/DataTable.d.ts +28 -3
- package/DataTable/DataTable.js +105 -20
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/DataTable.mdx +64 -0
- package/DataTable/DataTable.stories.d.ts +4 -0
- package/DataTable/DataTable.stories.js +40 -1
- package/DataTable/DataTable.stories.js.map +1 -1
- package/DataTable/DataTable.subRows.test.d.ts +1 -0
- package/DataTable/DataTable.subRows.test.js +216 -0
- package/DataTable/DataTable.subRows.test.js.map +1 -0
- package/DatePicker/DatePicker.d.ts +5 -2
- package/DatePicker/DatePicker.js +14 -3
- package/DatePicker/DatePicker.js.map +1 -1
- package/DatePicker/DatePicker.stories.d.ts +10 -0
- package/DatePicker/DatePicker.stories.js +44 -1
- package/DatePicker/DatePicker.stories.js.map +1 -1
- package/DatePicker/primitives/BirthdayPicker.d.ts +13 -0
- package/DatePicker/primitives/BirthdayPicker.js +355 -0
- package/DatePicker/primitives/BirthdayPicker.js.map +1 -0
- package/DatePicker/primitives/BirthdayPickerCell.d.ts +14 -0
- package/DatePicker/primitives/BirthdayPickerCell.js +19 -0
- package/DatePicker/primitives/BirthdayPickerCell.js.map +1 -0
- package/DatePicker/primitives/BirthdayPickerSegments.d.ts +9 -0
- package/DatePicker/primitives/BirthdayPickerSegments.js +43 -0
- package/DatePicker/primitives/BirthdayPickerSegments.js.map +1 -0
- package/DatePicker/primitives/DateOnlyPicker.d.ts +1 -1
- package/DatePicker/primitives/DateOnlyPicker.js +13 -4
- package/DatePicker/primitives/DateOnlyPicker.js.map +1 -1
- package/DatePicker/primitives/DatePickerPrimitive.js +3 -0
- package/DatePicker/primitives/DatePickerPrimitive.js.map +1 -1
- package/DatePicker/primitives/DateRangePicker.d.ts +1 -1
- package/DatePicker/primitives/DateRangePicker.js +5 -4
- package/DatePicker/primitives/DateRangePicker.js.map +1 -1
- package/DatePicker/primitives/DateTimePicker.d.ts +1 -1
- package/DatePicker/primitives/DateTimePicker.js +14 -17
- package/DatePicker/primitives/DateTimePicker.js.map +1 -1
- package/DatePicker/primitives/MonthPicker.d.ts +1 -1
- package/DatePicker/primitives/MonthPicker.js +2 -1
- package/DatePicker/primitives/MonthPicker.js.map +1 -1
- package/DatePicker/primitives/MultipleDatesPicker.d.ts +1 -1
- package/DatePicker/primitives/MultipleDatesPicker.js +5 -4
- package/DatePicker/primitives/MultipleDatesPicker.js.map +1 -1
- package/DatePicker/primitives/MultipleMonthsPicker.d.ts +1 -1
- package/DatePicker/primitives/MultipleMonthsPicker.js +2 -1
- package/DatePicker/primitives/MultipleMonthsPicker.js.map +1 -1
- package/DatePicker/primitives/MultipleYearsPicker.d.ts +1 -1
- package/DatePicker/primitives/MultipleYearsPicker.js +2 -1
- package/DatePicker/primitives/MultipleYearsPicker.js.map +1 -1
- package/DatePicker/primitives/TimeOnlyPicker.d.ts +1 -1
- package/DatePicker/primitives/TimeOnlyPicker.js +2 -1
- package/DatePicker/primitives/TimeOnlyPicker.js.map +1 -1
- package/DatePicker/primitives/WeekPicker.d.ts +1 -1
- package/DatePicker/primitives/WeekPicker.js +2 -1
- package/DatePicker/primitives/WeekPicker.js.map +1 -1
- package/DatePicker/primitives/YearPicker.d.ts +1 -1
- package/DatePicker/primitives/YearPicker.js +2 -1
- package/DatePicker/primitives/YearPicker.js.map +1 -1
- package/DatePicker/primitives/components/TimePicker.d.ts +2 -1
- package/DatePicker/primitives/components/TimePicker.js +2 -1
- package/DatePicker/primitives/components/TimePicker.js.map +1 -1
- package/DatePicker/utils/birthdayHelpers.d.ts +77 -0
- package/DatePicker/utils/birthdayHelpers.js +145 -0
- package/DatePicker/utils/birthdayHelpers.js.map +1 -0
- package/DatePicker/utils/birthdayHelpers.test.d.ts +1 -0
- package/DatePicker/utils/birthdayHelpers.test.js +394 -0
- package/DatePicker/utils/birthdayHelpers.test.js.map +1 -0
- package/DatePicker/utils/dateHelpers.d.ts +6 -1
- package/DatePicker/utils/dateHelpers.js +13 -5
- package/DatePicker/utils/dateHelpers.js.map +1 -1
- package/DatePicker/utils/dateHelpers.test.d.ts +1 -0
- package/DatePicker/utils/dateHelpers.test.js +119 -0
- package/DatePicker/utils/dateHelpers.test.js.map +1 -0
- package/DatePicker/utils/index.d.ts +1 -0
- package/DatePicker/utils/index.js +1 -0
- package/DatePicker/utils/timezoneHelpers.d.ts +3 -0
- package/DatePicker/utils/timezoneHelpers.js +32 -0
- package/DatePicker/utils/timezoneHelpers.js.map +1 -0
- package/DatePicker/utils/types.d.ts +15 -2
- package/DelayedOnChange/DelayedOnChange.d.ts +9 -2
- package/DelayedOnChange/DelayedOnChange.js.map +1 -1
- package/Dialog/Dialog.d.ts +8 -7
- package/Dialog/Dialog.js.map +1 -1
- package/Drawer/Drawer.d.ts +10 -6
- package/Drawer/Drawer.js +2 -1
- package/Drawer/Drawer.js.map +1 -1
- package/Drawer/Drawer.stories.d.ts +1 -0
- package/Drawer/Drawer.stories.js +20 -2
- package/Drawer/Drawer.stories.js.map +1 -1
- package/Drawer/components/DrawerHeader.d.ts +2 -2
- package/Drawer/components/DrawerHeader.js +11 -8
- package/Drawer/components/DrawerHeader.js.map +1 -1
- package/Drawer/components/Icon.d.ts +1 -1
- package/Drawer/components/Icon.js +3 -4
- package/Drawer/components/Icon.js.map +1 -1
- package/EmptyState/EmptyState.d.ts +2 -1
- package/EmptyState/EmptyState.js +8 -2
- package/EmptyState/EmptyState.js.map +1 -1
- package/FilePicker/FilePicker.js +6 -1
- package/FilePicker/FilePicker.js.map +1 -1
- package/FilePicker/FilePicker.stories.d.ts +6 -0
- package/FilePicker/FilePicker.stories.js +24 -1
- package/FilePicker/FilePicker.stories.js.map +1 -1
- package/FilePicker/primitives/FilePickerPrimitive.d.ts +1 -1
- package/FilePicker/primitives/FilePickerPrimitive.js +3 -1
- package/FilePicker/primitives/FilePickerPrimitive.js.map +1 -1
- package/FilePicker/primitives/components/Label.d.ts +3 -1
- package/FilePicker/primitives/components/Label.js +2 -1
- package/FilePicker/primitives/components/Label.js.map +1 -1
- package/FilePicker/primitives/components/previews/ItemActions.js +1 -1
- package/FilePicker/primitives/components/previews/ItemActions.js.map +1 -1
- package/FilePicker/primitives/components/previews/ItemDescription.js +1 -1
- package/FilePicker/primitives/components/previews/ItemDescription.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.d.ts +5 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.js +45 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.d.ts +5 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js +14 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js +52 -11
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.d.ts +5 -4
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js +9 -66
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.d.ts +11 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js +24 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.d.ts +10 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js +46 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js.map +1 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.d.ts +7 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.js +20 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.js.map +1 -0
- package/FilePicker/primitives/components/previews/fileName.d.ts +4 -0
- package/FilePicker/primitives/components/previews/fileName.js +26 -0
- package/FilePicker/primitives/components/previews/fileName.js.map +1 -0
- package/FilePicker/primitives/components/previews/index.d.ts +1 -0
- package/FilePicker/primitives/components/previews/index.js +1 -0
- package/FormComponent/Label.d.ts +6 -1
- package/FormComponent/Label.js +5 -2
- package/FormComponent/Label.js.map +1 -1
- package/FormComponent/labels.test.d.ts +1 -0
- package/FormComponent/labels.test.js +276 -0
- package/FormComponent/labels.test.js.map +1 -0
- package/Icon/Icon.d.ts +6 -1
- package/Icon/Icon.js.map +1 -1
- package/IconPicker/IconPicker.js +6 -1
- package/IconPicker/IconPicker.js.map +1 -1
- package/IconPicker/domains/IconPickerIcon.js +1 -1
- package/IconPicker/domains/IconPickerIcon.js.map +1 -1
- package/IconPicker/primitives/IconPickerPrimitive.d.ts +2 -0
- package/IconPicker/primitives/IconPickerPrimitive.js +2 -2
- package/IconPicker/primitives/IconPickerPrimitive.js.map +1 -1
- package/IconPicker/primitives/components/IconPickerGrid.js.map +1 -1
- package/Input/InputPrimitive.d.ts +4 -4
- package/Input/InputPrimitive.js +0 -1
- package/Input/InputPrimitive.js.map +1 -1
- package/Kbd/Kbd.d.ts +35 -0
- package/Kbd/Kbd.js +34 -0
- package/Kbd/Kbd.js.map +1 -0
- package/Kbd/index.d.ts +1 -0
- package/Kbd/index.js +1 -0
- package/Link/Link.d.ts +1 -1
- package/Link/Link.js +1 -1
- package/Link/Link.js.map +1 -1
- package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.d.ts +8 -2
- package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js +1 -0
- package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js.map +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompletePresenter.test.js +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompletePresenter.test.js.map +1 -1
- package/MultiAutoComplete/primitives/useMultiAutoComplete.js +3 -2
- package/MultiAutoComplete/primitives/useMultiAutoComplete.js.map +1 -1
- package/MultiSelect/MultiSelect.js +6 -1
- package/MultiSelect/MultiSelect.js.map +1 -1
- package/MultiSelect/primitives/MultiSelectPrimitive.d.ts +3 -1
- package/MultiSelect/primitives/MultiSelectPrimitive.js +16 -7
- package/MultiSelect/primitives/MultiSelectPrimitive.js.map +1 -1
- package/Popover/Popover.stories.d.ts +7 -0
- package/Popover/Popover.stories.js +24 -1
- package/Popover/Popover.stories.js.map +1 -1
- package/Popover/primitives/components/PopoverContent.js +6 -1
- package/Popover/primitives/components/PopoverContent.js.map +1 -1
- package/RadioGroup/RadioGroup.js +4 -1
- package/RadioGroup/RadioGroup.js.map +1 -1
- package/RadioGroup/primitives/RadioGroupPrimitive.d.ts +1 -1
- package/RadioGroup/primitives/RadioGroupPrimitive.js +4 -2
- package/RadioGroup/primitives/RadioGroupPrimitive.js.map +1 -1
- package/RadioGroup/primitives/presenters/RadioGroupPresenter.js +4 -2
- package/RadioGroup/primitives/presenters/RadioGroupPresenter.js.map +1 -1
- package/RadioGroup/primitives/presenters/RadioGroupPresenter.jsxLabel.test.d.ts +1 -0
- package/RadioGroup/primitives/presenters/RadioGroupPresenter.jsxLabel.test.js +88 -0
- package/RadioGroup/primitives/presenters/RadioGroupPresenter.jsxLabel.test.js.map +1 -0
- package/RangeSlider/RangeSlider.js +4 -1
- package/RangeSlider/RangeSlider.js.map +1 -1
- package/RangeSlider/primitives/RangeSliderPrimitive.d.ts +1 -1
- package/RangeSlider/primitives/RangeSliderPrimitive.js +3 -1
- package/RangeSlider/primitives/RangeSliderPrimitive.js.map +1 -1
- package/ScrollArea/ScrollArea.d.ts +16 -2
- package/ScrollArea/ScrollArea.js +19 -5
- package/ScrollArea/ScrollArea.js.map +1 -1
- package/SegmentedControl/SegmentedControl.js +4 -1
- package/SegmentedControl/SegmentedControl.js.map +1 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.d.ts +5 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.js +2 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.js.map +1 -1
- package/Select/Select.js +6 -1
- package/Select/Select.js.map +1 -1
- package/Select/primitives/SelectPrimitive.d.ts +4 -0
- package/Select/primitives/SelectPrimitive.js +4 -2
- package/Select/primitives/SelectPrimitive.js.map +1 -1
- package/Select/primitives/components/SelectContent.js +4 -6
- package/Select/primitives/components/SelectContent.js.map +1 -1
- package/SidePanel/SidePanel.d.ts +46 -0
- package/SidePanel/SidePanel.js +47 -0
- package/SidePanel/SidePanel.js.map +1 -0
- package/SidePanel/SidePanelBody.d.ts +37 -0
- package/SidePanel/SidePanelBody.js +14 -0
- package/SidePanel/SidePanelBody.js.map +1 -0
- package/SidePanel/SidePanelFooter.d.ts +27 -0
- package/SidePanel/SidePanelFooter.js +10 -0
- package/SidePanel/SidePanelFooter.js.map +1 -0
- package/SidePanel/index.d.ts +3 -0
- package/SidePanel/index.js +3 -0
- package/Sidebar/Sidebar.groups.test.d.ts +1 -0
- package/Sidebar/Sidebar.groups.test.js +113 -0
- package/Sidebar/Sidebar.groups.test.js.map +1 -0
- package/Sidebar/components/SidebarContent.js +1 -1
- package/Sidebar/components/SidebarContent.js.map +1 -1
- package/Sidebar/components/SidebarRoot.js +1 -1
- package/Sidebar/components/SidebarRoot.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuRootButton.js +1 -0
- package/Sidebar/components/items/SidebarMenuRootButton.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuSubButton.js +8 -5
- package/Sidebar/components/items/SidebarMenuSubButton.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuSubItem.js +3 -3
- package/Sidebar/components/items/SidebarMenuSubItem.js.map +1 -1
- package/Slider/Slider.js +10 -2
- package/Slider/Slider.js.map +1 -1
- package/Slider/primitives/SliderPrimitive.d.ts +1 -1
- package/Slider/primitives/SliderPrimitive.js +2 -1
- package/Slider/primitives/SliderPrimitive.js.map +1 -1
- package/Slider/primitives/components/SliderThumb.d.ts +5 -2
- package/Slider/primitives/components/SliderThumb.js +2 -1
- package/Slider/primitives/components/SliderThumb.js.map +1 -1
- package/Switch/Switch.d.ts +4 -4
- package/Switch/Switch.js +21 -7
- package/Switch/Switch.js.map +1 -1
- package/Switch/domains/SwitchItemDto.d.ts +1 -1
- package/Switch/primitives/SwitchPrimitive.js +4 -3
- package/Switch/primitives/SwitchPrimitive.js.map +1 -1
- package/Tabs/Tabs.d.ts +7 -2
- package/Tabs/Tabs.js +29 -11
- package/Tabs/Tabs.js.map +1 -1
- package/Tabs/Tabs.mdx +27 -0
- package/Tabs/Tabs.stories.d.ts +1 -0
- package/Tabs/Tabs.stories.js +19 -1
- package/Tabs/Tabs.stories.js.map +1 -1
- package/Tag/Tag.d.ts +1 -1
- package/Tag/Tag.js +5 -0
- package/Tag/Tag.js.map +1 -1
- package/Tag/TagIcon.js +7 -1
- package/Tag/TagIcon.js.map +1 -1
- package/Tags/primitives/TagsPrimitive.d.ts +2 -2
- package/Tags/primitives/TagsPrimitive.js.map +1 -1
- package/ToggleGroup/ToggleGroup.js +4 -1
- package/ToggleGroup/ToggleGroup.js.map +1 -1
- package/ToggleGroup/primitives/ToggleGroupPrimitive.d.ts +2 -0
- package/ToggleGroup/primitives/ToggleGroupPrimitive.js +3 -2
- package/ToggleGroup/primitives/ToggleGroupPrimitive.js.map +1 -1
- package/Tree/useTree.js +6 -2
- package/Tree/useTree.js.map +1 -1
- package/exports/admin/ui.d.ts +1 -0
- package/exports/admin/ui.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useEscapeScrollLock.d.ts +13 -0
- package/hooks/useEscapeScrollLock.js +21 -0
- package/hooks/useEscapeScrollLock.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +30 -28
- package/theme.css +34 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer/Drawer.stories.js","sources":["../../src/Drawer/Drawer.stories.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { Drawer } from \"./Drawer.js\";\nimport { Button } from \"~/Button/index.js\";\nimport { DropdownMenu } from \"~/DropdownMenu/index.js\";\nimport { Tabs } from \"~/Tabs/index.js\";\nimport { ReactComponent as DoorbellIcon } from \"@webiny/icons/ring_volume.svg\";\n\nconst meta: Meta<typeof Drawer> = {\n title: \"Components/Drawer\",\n component: Drawer,\n argTypes: {}\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof Drawer>;\n\nexport const Default: Story = {\n args: {\n trigger: <Button variant=\"primary\" text={\"Open\"} />,\n title: \"Drawer Title\",\n description: \"A short dialog description.\",\n info: (\n <>\n Learn more about this <a href={\"#\"}>here</a>.\n </>\n ),\n children: (\n <>\n <p className={\"mb-md\"}>\n The amazing, splendid, and most useful umbrella, resistant to rain and friendly\n to winds, is something that deserves all admiration. Crafted with perfect\n textures, it bravely withstands storms and gently shades the rays of the sun. A\n remarkable innovation, with an ergonomically designed grip most suited to the\n hand, it remains stable even in the fiercest weather.\n </p>\n <p className={\"mb-md\"}>\n Its fabric, woven from the highest quality materials, ensures that you stay dry,\n no matter the intensity of the rain. With a frame engineered for strength yet\n lightweight enough to carry with ease, this umbrella is a marvel of modern\n design. Not just a shield against the elements, but a companion in your everyday\n journey, it provides peace of mind, knowing you’re prepared for whatever the\n skies may bring.\n </p>\n <p className={\"mb-md\"}>\n The sleek, stylish design complements any outfit, making it not only a practical\n accessory but also a fashion statement. With its smooth opening mechanism, you\n can effortlessly transition from a sunny day to a rainy one without missing a\n beat. Whether you are navigating through a busy city street or enjoying a quiet\n stroll in the park, this umbrella offers unmatched comfort and protection.\n </p>\n <p className={\"mb-md\"}>\n Indeed, it is not just an umbrella — it is an experience. One that elevates your\n daily routine, making every step in both sun and storm feel just a little bit\n brighter.\n </p>\n </>\n ),\n onOpenChange: opened => {\n console.log(`Drawer is ${opened ? \"opened\" : \"closed\"}.`);\n },\n actions: (\n <>\n <Drawer.CancelButton />\n <Drawer.ConfirmButton />\n </>\n ),\n bodyPadding: true,\n headerSeparator: true,\n footerSeparator: true\n },\n argTypes: {}\n};\n\nexport const SizeSmall: Story = {\n args: {\n ...Default.args,\n size: \"sm\"\n }\n};\n\nexport const SizeMedium: Story = {\n args: {\n ...Default.args,\n size: \"md\"\n }\n};\n\nexport const SizeLarge: Story = {\n args: {\n ...Default.args,\n size: \"lg\"\n }\n};\n\nexport const SizeExtraLarge: Story = {\n args: {\n ...Default.args,\n size: \"xl\"\n }\n};\n\nexport const ControlledVisibility: Story = {\n render: props => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <Button variant=\"primary\" text={\"Open\"} onClick={() => setOpen(true)} />\n <Drawer\n {...props}\n open={open}\n onOpenChange={open => {\n if (!open) {\n setOpen(false);\n }\n }}\n />\n </>\n );\n },\n args: {\n ...Default.args,\n trigger: null,\n children: <>This drawer's visibility is controlled by the open state.</>\n }\n};\n\nexport const WithOpenCloseEventHandler: Story = {\n args: {\n ...Default.args,\n onClose: () => {\n console.log(\"onClose triggered\");\n },\n onOpen: () => {\n console.log(\"onOpen triggered\");\n }\n }\n};\n\nexport const WithDropdownMenu: Story = {\n render: props => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <DropdownMenu trigger={<Button variant=\"primary\" text={\"Open\"} />}>\n <DropdownMenu.Item\n text={\"Open Drawer\"}\n content={\"Open Drawer\"}\n onClick={() => setOpen(true)}\n />\n </DropdownMenu>\n\n <Drawer {...props} open={open} onOpenChange={() => setOpen(false)} />\n </>\n );\n },\n args: {\n ...Default.args,\n trigger: null,\n children: <>This drawer is opened from a dropdown menu item.</>\n }\n};\n\nexport const WithoutCloseButton: Story = {\n args: {\n ...Default.args,\n showCloseButton: false,\n children: <>This drawer is opened from a dropdown menu item.</>\n }\n};\n\nexport const CustomWidth: Story = {\n args: {\n ...Default.args,\n width: 1000,\n children: <>This drawer has a custom width of 1000px, making it wider than the default.</>\n }\n};\n\nexport const WithTabs: Story = {\n args: {\n ...Default.args,\n bodyPadding: false,\n headerSeparator: false,\n children: (\n <>\n <Tabs\n separator={true}\n spacing={\"lg\"}\n tabs={[\n <Tabs.Tab\n key=\"account\"\n value=\"account\"\n trigger={\"Account\"}\n content={\"Make changes to your account here.\"}\n />,\n <Tabs.Tab\n key=\"company\"\n value=\"company\"\n trigger={\"Company\"}\n content={\"Make changes to your company info here.\"}\n />,\n <Tabs.Tab\n key=\"security\"\n value=\"security\"\n trigger={\"Security\"}\n content={\"Make changes to your security settings here.\"}\n />,\n <Tabs.Tab\n key=\"development\"\n value=\"development\"\n trigger={\"Development\"}\n content={\"Make changes to your development settings here.\"}\n />\n ]}\n />\n </>\n )\n }\n};\n\nexport const DropdownMenuInDrawer: Story = {\n args: {\n ...Default.args,\n children: (\n <>\n <DropdownMenu trigger={<Button variant=\"primary\" text={\"Open\"} />}>\n <DropdownMenu.Item content={\"Billing\"} />\n <DropdownMenu.Item content={\"Settings\"} />\n <DropdownMenu.Item content={\"Keyboard shortcuts\"} />\n </DropdownMenu>\n </>\n )\n }\n};\n\nexport const WithIcon: Story = {\n args: {\n ...Default.args,\n icon: <Drawer.Icon icon={<DoorbellIcon />} label={\"Icon label...\"} />,\n children: <>The icon helps to visually identify the purpose of this drawer.</>\n }\n};\n\nexport const AsModal: Story = {\n args: {\n ...Default.args,\n modal: true,\n children: (\n <>\n This drawer has modal=true, which means it will show an overlay behind it and\n prevent interaction with the content underneath.\n </>\n )\n }\n};\n\nexport const Documentation: Story = {\n render: args => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <Button variant=\"primary\" text=\"Open Drawer\" onClick={() => setOpen(true)} />\n\n <Drawer {...args} open={open} onOpenChange={open => setOpen(open)} />\n </>\n );\n },\n args: {\n title: \"Drawer Title\",\n description: \"A short drawer description.\",\n showCloseButton: true,\n bodyPadding: true,\n headerSeparator: true,\n footerSeparator: true,\n side: \"right\",\n modal: false,\n info: (\n <>\n Learn more about this <a href={\"#\"}>here</a>.\n </>\n ),\n children: (\n <>\n <p className={\"mb-md, mt-md\"}>\n This is the drawer content area. You can place any content here including forms,\n text, images, or other components.\n </p>\n <p className={\"mb-md\"}>\n Drawers are useful for displaying additional information or actions without\n navigating away from the current page.\n </p>\n </>\n ),\n actions: (\n <>\n <Drawer.CancelButton />\n <Drawer.ConfirmButton />\n </>\n ),\n width: undefined\n },\n argTypes: {\n title: {\n description: \"Title displayed in the header\",\n control: \"text\"\n },\n description: {\n description: \"Description displayed below the title\",\n control: \"text\"\n },\n side: {\n description: \"Side from which the drawer appears\",\n control: \"select\",\n options: [\"left\", \"right\"],\n defaultValue: \"right\"\n },\n size: {\n description: \"Controls the size of the drawer\",\n control: \"select\",\n options: [\"sm\", \"md\", \"lg\", \"xl\"],\n defaultValue: \"md\"\n },\n showCloseButton: {\n description: \"Show close button in the top-right corner\",\n control: \"boolean\",\n defaultValue: true\n },\n modal: {\n description: \"Whether the drawer should behave as a modal\",\n control: \"boolean\",\n defaultValue: false\n },\n bodyPadding: {\n description: \"Add padding to the drawer body\",\n control: \"boolean\",\n defaultValue: true\n },\n headerSeparator: {\n description: \"Show separator below the header\",\n control: \"boolean\",\n defaultValue: true\n },\n footerSeparator: {\n description: \"Show separator above the footer\",\n control: \"boolean\",\n defaultValue: true\n },\n width: {\n description:\n 'Width defines the horizontal size of the Drawer and accepts any valid CSS width value. You can pass a number (interpreted as pixels) or a string like \"80%\", \"50vw\", \"auto\", etc., following React.CSSProperties[\"width\"] types.'\n },\n info: {\n description:\n \"Additional info displayed below the description, please refer to the example below for details.\"\n },\n children: {\n description:\n \"Content of the Drawer, please refer to the 'With Dropdown Menu' and ''With Tabs' example below for details.\"\n },\n actions: {\n description:\n \"Actions displayed in the footer, please refer to the code example for details.\"\n }\n }\n};\n"],"names":["meta","Drawer","Default","Button","opened","console","SizeSmall","SizeMedium","SizeLarge","SizeExtraLarge","ControlledVisibility","props","open","setOpen","React","WithOpenCloseEventHandler","WithDropdownMenu","DropdownMenu","WithoutCloseButton","CustomWidth","WithTabs","Tabs","DropdownMenuInDrawer","WithIcon","DoorbellIcon","AsModal","Documentation","args","undefined"],"mappings":";;;;;;AAQA,MAAMA,OAA4B;IAC9B,OAAO;IACP,WAAWC;IACX,UAAU,CAAC;AACf;AAEA,uBAAeD;AAIR,MAAME,UAAiB;IAC1B,MAAM;QACF,SAAS,WAAT,GAAS,oBAACC,QAAMA;YAAC,SAAQ;YAAU,MAAM;;QACzC,OAAO;QACP,aAAa;QACb,MAAM,WAAN,GACI,0CAAE,wCACwB,oBAAC;YAAE,MAAM;WAAK,SAAQ;QAGpD,UAAU,WAAV,GACI,wDACI,oBAAC;YAAE,WAAW;WAAS,gYAOvB,oBAAC;YAAE,WAAW;WAAS,2aAQvB,oBAAC;YAAE,WAAW;WAAS,2ZAOvB,oBAAC;YAAE,WAAW;WAAS;QAO/B,cAAcC,CAAAA;YACVC,QAAQ,GAAG,CAAC,CAAC,UAAU,EAAED,SAAS,WAAW,SAAS,CAAC,CAAC;QAC5D;QACA,SAAS,WAAT,GACI,wDACI,oBAACH,OAAO,YAAY,uBACpB,oBAACA,OAAO,aAAa;QAG7B,aAAa;QACb,iBAAiB;QACjB,iBAAiB;IACrB;IACA,UAAU,CAAC;AACf;AAEO,MAAMK,YAAmB;IAC5B,MAAM;QACF,GAAGJ,QAAQ,IAAI;QACf,MAA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a;YACb,SAAS;YACT,cAAc;QAClB;QACA,iBAAiB;YACb,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,OAAO;YACH,aACI;QACR;QACA,MAAM;YACF,aACI;QACR;QACA,UAAU;YACN,aACI;QACR;QACA,SAAS;YACL,aACI;QACR;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"Drawer/Drawer.stories.js","sources":["../../src/Drawer/Drawer.stories.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { Drawer } from \"./Drawer.js\";\nimport { Button, IconButton } from \"~/Button/index.js\";\nimport { DropdownMenu } from \"~/DropdownMenu/index.js\";\nimport { Tabs } from \"~/Tabs/index.js\";\nimport { ReactComponent as DoorbellIcon } from \"@webiny/icons/ring_volume.svg\";\nimport { ReactComponent as RefreshIcon } from \"@webiny/icons/refresh.svg\";\n\nconst meta: Meta<typeof Drawer> = {\n title: \"Components/Drawer\",\n component: Drawer,\n argTypes: {}\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof Drawer>;\n\nexport const Default: Story = {\n args: {\n trigger: <Button variant=\"primary\" text={\"Open\"} />,\n title: \"Drawer Title\",\n description: \"A short dialog description.\",\n info: (\n <>\n Learn more about this <a href={\"#\"}>here</a>.\n </>\n ),\n children: (\n <>\n <p className={\"mb-md\"}>\n The amazing, splendid, and most useful umbrella, resistant to rain and friendly\n to winds, is something that deserves all admiration. Crafted with perfect\n textures, it bravely withstands storms and gently shades the rays of the sun. A\n remarkable innovation, with an ergonomically designed grip most suited to the\n hand, it remains stable even in the fiercest weather.\n </p>\n <p className={\"mb-md\"}>\n Its fabric, woven from the highest quality materials, ensures that you stay dry,\n no matter the intensity of the rain. With a frame engineered for strength yet\n lightweight enough to carry with ease, this umbrella is a marvel of modern\n design. Not just a shield against the elements, but a companion in your everyday\n journey, it provides peace of mind, knowing you’re prepared for whatever the\n skies may bring.\n </p>\n <p className={\"mb-md\"}>\n The sleek, stylish design complements any outfit, making it not only a practical\n accessory but also a fashion statement. With its smooth opening mechanism, you\n can effortlessly transition from a sunny day to a rainy one without missing a\n beat. Whether you are navigating through a busy city street or enjoying a quiet\n stroll in the park, this umbrella offers unmatched comfort and protection.\n </p>\n <p className={\"mb-md\"}>\n Indeed, it is not just an umbrella — it is an experience. One that elevates your\n daily routine, making every step in both sun and storm feel just a little bit\n brighter.\n </p>\n </>\n ),\n onOpenChange: opened => {\n console.log(`Drawer is ${opened ? \"opened\" : \"closed\"}.`);\n },\n actions: (\n <>\n <Drawer.CancelButton />\n <Drawer.ConfirmButton />\n </>\n ),\n bodyPadding: true,\n headerSeparator: true,\n footerSeparator: true\n },\n argTypes: {}\n};\n\nexport const SizeSmall: Story = {\n args: {\n ...Default.args,\n size: \"sm\"\n }\n};\n\nexport const SizeMedium: Story = {\n args: {\n ...Default.args,\n size: \"md\"\n }\n};\n\nexport const SizeLarge: Story = {\n args: {\n ...Default.args,\n size: \"lg\"\n }\n};\n\nexport const SizeExtraLarge: Story = {\n args: {\n ...Default.args,\n size: \"xl\"\n }\n};\n\nexport const ControlledVisibility: Story = {\n render: props => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <Button variant=\"primary\" text={\"Open\"} onClick={() => setOpen(true)} />\n <Drawer\n {...props}\n open={open}\n onOpenChange={open => {\n if (!open) {\n setOpen(false);\n }\n }}\n />\n </>\n );\n },\n args: {\n ...Default.args,\n trigger: null,\n children: <>This drawer's visibility is controlled by the open state.</>\n }\n};\n\nexport const WithOpenCloseEventHandler: Story = {\n args: {\n ...Default.args,\n onClose: () => {\n console.log(\"onClose triggered\");\n },\n onOpen: () => {\n console.log(\"onOpen triggered\");\n }\n }\n};\n\nexport const WithDropdownMenu: Story = {\n render: props => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <DropdownMenu trigger={<Button variant=\"primary\" text={\"Open\"} />}>\n <DropdownMenu.Item\n text={\"Open Drawer\"}\n content={\"Open Drawer\"}\n onClick={() => setOpen(true)}\n />\n </DropdownMenu>\n\n <Drawer {...props} open={open} onOpenChange={() => setOpen(false)} />\n </>\n );\n },\n args: {\n ...Default.args,\n trigger: null,\n children: <>This drawer is opened from a dropdown menu item.</>\n }\n};\n\nexport const WithoutCloseButton: Story = {\n args: {\n ...Default.args,\n showCloseButton: false,\n children: <>This drawer is opened from a dropdown menu item.</>\n }\n};\n\nexport const CustomWidth: Story = {\n args: {\n ...Default.args,\n width: 1000,\n children: <>This drawer has a custom width of 1000px, making it wider than the default.</>\n }\n};\n\nexport const WithTabs: Story = {\n args: {\n ...Default.args,\n bodyPadding: false,\n headerSeparator: false,\n children: (\n <>\n <Tabs\n separator={true}\n spacing={\"lg\"}\n tabs={[\n <Tabs.Tab\n key=\"account\"\n value=\"account\"\n trigger={\"Account\"}\n content={\"Make changes to your account here.\"}\n />,\n <Tabs.Tab\n key=\"company\"\n value=\"company\"\n trigger={\"Company\"}\n content={\"Make changes to your company info here.\"}\n />,\n <Tabs.Tab\n key=\"security\"\n value=\"security\"\n trigger={\"Security\"}\n content={\"Make changes to your security settings here.\"}\n />,\n <Tabs.Tab\n key=\"development\"\n value=\"development\"\n trigger={\"Development\"}\n content={\"Make changes to your development settings here.\"}\n />\n ]}\n />\n </>\n )\n }\n};\n\nexport const DropdownMenuInDrawer: Story = {\n args: {\n ...Default.args,\n children: (\n <>\n <DropdownMenu trigger={<Button variant=\"primary\" text={\"Open\"} />}>\n <DropdownMenu.Item content={\"Billing\"} />\n <DropdownMenu.Item content={\"Settings\"} />\n <DropdownMenu.Item content={\"Keyboard shortcuts\"} />\n </DropdownMenu>\n </>\n )\n }\n};\n\nexport const WithIcon: Story = {\n args: {\n ...Default.args,\n icon: <Drawer.Icon icon={<DoorbellIcon />} label={\"Icon label...\"} />,\n children: <>The icon helps to visually identify the purpose of this drawer.</>\n }\n};\n\nexport const WithHeaderActions: Story = {\n args: {\n ...Default.args,\n headerActions: (\n <IconButton\n variant={\"ghost\"}\n size={\"md\"}\n iconSize={\"lg\"}\n title={\"Refresh\"}\n aria-label={\"Refresh\"}\n icon={<RefreshIcon />}\n />\n ),\n children: <>Header actions sit next to the close button.</>\n }\n};\n\nexport const AsModal: Story = {\n args: {\n ...Default.args,\n modal: true,\n children: (\n <>\n This drawer has modal=true, which means it will show an overlay behind it and\n prevent interaction with the content underneath.\n </>\n )\n }\n};\n\nexport const Documentation: Story = {\n render: args => {\n const [open, setOpen] = React.useState(false);\n\n return (\n <>\n <Button variant=\"primary\" text=\"Open Drawer\" onClick={() => setOpen(true)} />\n\n <Drawer {...args} open={open} onOpenChange={open => setOpen(open)} />\n </>\n );\n },\n args: {\n title: \"Drawer Title\",\n description: \"A short drawer description.\",\n showCloseButton: true,\n bodyPadding: true,\n headerSeparator: true,\n footerSeparator: true,\n side: \"right\",\n modal: false,\n info: (\n <>\n Learn more about this <a href={\"#\"}>here</a>.\n </>\n ),\n children: (\n <>\n <p className={\"mb-md, mt-md\"}>\n This is the drawer content area. You can place any content here including forms,\n text, images, or other components.\n </p>\n <p className={\"mb-md\"}>\n Drawers are useful for displaying additional information or actions without\n navigating away from the current page.\n </p>\n </>\n ),\n actions: (\n <>\n <Drawer.CancelButton />\n <Drawer.ConfirmButton />\n </>\n ),\n width: undefined\n },\n argTypes: {\n title: {\n description: \"Title displayed in the header\",\n control: \"text\"\n },\n description: {\n description: \"Description displayed below the title\",\n control: \"text\"\n },\n side: {\n description: \"Side from which the drawer appears\",\n control: \"select\",\n options: [\"left\", \"right\"],\n defaultValue: \"right\"\n },\n size: {\n description: \"Controls the size of the drawer\",\n control: \"select\",\n options: [\"sm\", \"md\", \"lg\", \"xl\"],\n defaultValue: \"md\"\n },\n showCloseButton: {\n description: \"Show close button in the top-right corner\",\n control: \"boolean\",\n defaultValue: true\n },\n modal: {\n description: \"Whether the drawer should behave as a modal\",\n control: \"boolean\",\n defaultValue: false\n },\n bodyPadding: {\n description: \"Add padding to the drawer body\",\n control: \"boolean\",\n defaultValue: true\n },\n headerSeparator: {\n description: \"Show separator below the header\",\n control: \"boolean\",\n defaultValue: true\n },\n headerActions: {\n description:\n \"Controls rendered in the header, next to the close button, e.g. icon buttons.\"\n },\n footerSeparator: {\n description: \"Show separator above the footer\",\n control: \"boolean\",\n defaultValue: true\n },\n width: {\n description:\n 'Width defines the horizontal size of the Drawer and accepts any valid CSS width value. You can pass a number (interpreted as pixels) or a string like \"80%\", \"50vw\", \"auto\", etc., following React.CSSProperties[\"width\"] types.'\n },\n info: {\n description:\n \"Additional info displayed below the description, please refer to the example below for details.\"\n },\n children: {\n description:\n \"Content of the Drawer, please refer to the 'With Dropdown Menu' and ''With Tabs' example below for details.\"\n },\n actions: {\n description:\n \"Actions displayed in the footer, please refer to the code example for details.\"\n }\n }\n};\n"],"names":["meta","Drawer","Default","Button","opened","console","SizeSmall","SizeMedium","SizeLarge","SizeExtraLarge","ControlledVisibility","props","open","setOpen","React","WithOpenCloseEventHandler","WithDropdownMenu","DropdownMenu","WithoutCloseButton","CustomWidth","WithTabs","Tabs","DropdownMenuInDrawer","WithIcon","DoorbellIcon","WithHeaderActions","IconButton","RefreshIcon","AsModal","Documentation","args","undefined"],"mappings":";;;;;;;AASA,MAAMA,OAA4B;IAC9B,OAAO;IACP,WAAWC;IACX,UAAU,CAAC;AACf;AAEA,uBAAeD;AAIR,MAAME,UAAiB;IAC1B,MAAM;QACF,SAAS,WAAT,GAAS,oBAACC,QAAMA;YAAC,SAAQ;YAAU,MAAM;;QACzC,OAAO;QACP,aAAa;QACb,MAAM,WAAN,GACI,0CAAE,wCACwB,oBAAC;YAAE,MAAM;WAAK,SAAQ;QAGpD,UAAU,WAAV,GACI,wDACI,oBAAC;YAAE,WAAW;WAAS,gYAOvB,oBAAC;YAAE,WAAW;WAAS,2aAQvB,oBAAC;YAAE,WAAW;WAAS,2ZAOvB,oBAAC;YAAE,WAAW;WAAS;QAO/B,cAAcC,CAAAA;YACVC,QAAQ,GAAG,CAAC,CAAC,UAAU,EAAED,SAAS,WAAW,SAAS,CAAC,CAAC;QAC5D;QACA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,UAAU;QACN,OAAO;YACH,aAAa;YACb,SAAS;QACb;QACA,aAAa;YACT,aAAa;YACb,SAAS;QACb;QACA,MAAM;YACF,aAAa;YACb,SAAS;YACT,SAAS;gBAAC;gBAAQ;aAAQ;YAC1B,cAAc;QAClB;QACA,MAAM;YACF,aAAa;YACb,SAAS;YACT,SAAS;gBAAC;gBAAM;gBAAM;gBAAM;aAAK;YACjC,cAAc;QAClB;QACA,iBAAiB;YACb,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,OAAO;YACH,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,aAAa;YACT,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,iBAAiB;YACb,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,eAAe;YACX,aACI;QACR;QACA,iBAAiB;YACb,aAAa;YACb,SAAS;YACT,cAAc;QAClB;QACA,OAAO;YACH,aACI;QACR;QACA,MAAM;YACF,aACI;QACR;QACA,UAAU;YACN,aACI;QACR;QACA,SAAS;YACL,aACI;QACR;IACJ;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type DrawerProps } from "../Drawer.js";
|
|
3
|
-
export type DrawerHeaderProps = Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & Pick<DrawerProps, "title" | "icon" | "description" | "showCloseButton"> & {
|
|
3
|
+
export type DrawerHeaderProps = Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & Pick<DrawerProps, "title" | "icon" | "description" | "showCloseButton" | "headerActions"> & {
|
|
4
4
|
separator?: DrawerProps["headerSeparator"];
|
|
5
5
|
};
|
|
6
|
-
export declare const DrawerHeader: ({ title, icon, description, showCloseButton, separator, className, ...props }: DrawerHeaderProps) => React.JSX.Element | null;
|
|
6
|
+
export declare const DrawerHeader: ({ title, icon, description, showCloseButton, headerActions, separator, className, ...props }: DrawerHeaderProps) => React.JSX.Element | null;
|
|
@@ -6,29 +6,32 @@ import { IconButton } from "../../Button/index.js";
|
|
|
6
6
|
import { Dialog } from "radix-ui";
|
|
7
7
|
import { Separator } from "../../Separator/index.js";
|
|
8
8
|
import * as __rspack_external_react from "react";
|
|
9
|
-
const DrawerHeader = ({ title, icon, description, showCloseButton, separator, className, ...props })=>{
|
|
10
|
-
const nothingToRender = (0, __rspack_external_react.useMemo)(()=>!title && !description && !icon && !showCloseButton, [
|
|
9
|
+
const DrawerHeader = ({ title, icon, description, showCloseButton, headerActions, separator, className, ...props })=>{
|
|
10
|
+
const nothingToRender = (0, __rspack_external_react.useMemo)(()=>!title && !description && !icon && !showCloseButton && !headerActions, [
|
|
11
11
|
title,
|
|
12
12
|
description,
|
|
13
13
|
icon,
|
|
14
|
-
showCloseButton
|
|
14
|
+
showCloseButton,
|
|
15
|
+
headerActions
|
|
15
16
|
]);
|
|
16
17
|
if (nothingToRender) return null;
|
|
17
18
|
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external_react.Fragment, null, /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
18
19
|
...props,
|
|
19
20
|
className: cn("flex flex-col gap-sm px-lg py-md text-center sm:text-left text-neutral-primary", className)
|
|
20
|
-
}, /*#__PURE__*/ __rspack_external_react.createElement(DrawerTitle, {
|
|
21
|
-
className: "flex justify-between"
|
|
22
21
|
}, /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
23
|
-
className: "flex gap-
|
|
24
|
-
},
|
|
22
|
+
className: "flex items-center justify-between gap-sm"
|
|
23
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(DrawerTitle, {
|
|
24
|
+
className: "items-center gap-xs"
|
|
25
|
+
}, icon, title), /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
26
|
+
className: "flex items-center gap-xs"
|
|
27
|
+
}, headerActions, false !== showCloseButton && /*#__PURE__*/ __rspack_external_react.createElement(Dialog.Close, {
|
|
25
28
|
asChild: true
|
|
26
29
|
}, /*#__PURE__*/ __rspack_external_react.createElement(IconButton, {
|
|
27
30
|
size: "md",
|
|
28
31
|
iconSize: "lg",
|
|
29
32
|
variant: "ghost",
|
|
30
33
|
icon: /*#__PURE__*/ __rspack_external_react.createElement(ReactComponent, null)
|
|
31
|
-
}))), description && /*#__PURE__*/ __rspack_external_react.createElement(DrawerDescription, null, description)), separator && /*#__PURE__*/ __rspack_external_react.createElement(Separator, null));
|
|
34
|
+
})))), description && /*#__PURE__*/ __rspack_external_react.createElement(DrawerDescription, null, description)), separator && /*#__PURE__*/ __rspack_external_react.createElement(Separator, null));
|
|
32
35
|
};
|
|
33
36
|
export { DrawerHeader };
|
|
34
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer/components/DrawerHeader.js","sources":["../../../src/Drawer/components/DrawerHeader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { type DrawerProps } from \"../Drawer.js\";\nimport { DrawerTitle } from \"./DrawerTitle.js\";\nimport { DrawerDescription } from \"./DrawerDescription.js\";\nimport { ReactComponent as XIcon } from \"@webiny/icons/close.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Dialog as DrawerPrimitive } from \"radix-ui\";\nimport { useMemo } from \"react\";\nimport { Separator } from \"~/Separator/index.js\";\n\nexport type DrawerHeaderProps = Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> &\n Pick<DrawerProps, \"title\" | \"icon\" | \"description\" | \"showCloseButton\"> & {\n separator?: DrawerProps[\"headerSeparator\"];\n };\n\nexport const DrawerHeader = ({\n title,\n icon,\n description,\n showCloseButton,\n separator,\n className,\n ...props\n}: DrawerHeaderProps) => {\n const nothingToRender = useMemo(() => {\n return !title && !description && !icon && !showCloseButton;\n }, [title, description, icon, showCloseButton]);\n\n if (nothingToRender) {\n return null;\n }\n\n return (\n <>\n <div\n {...props}\n className={cn(\n \"flex flex-col gap-sm px-lg py-md text-center sm:text-left text-neutral-primary\",\n className\n )}\n >\n <
|
|
1
|
+
{"version":3,"file":"Drawer/components/DrawerHeader.js","sources":["../../../src/Drawer/components/DrawerHeader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { type DrawerProps } from \"../Drawer.js\";\nimport { DrawerTitle } from \"./DrawerTitle.js\";\nimport { DrawerDescription } from \"./DrawerDescription.js\";\nimport { ReactComponent as XIcon } from \"@webiny/icons/close.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Dialog as DrawerPrimitive } from \"radix-ui\";\nimport { useMemo } from \"react\";\nimport { Separator } from \"~/Separator/index.js\";\n\nexport type DrawerHeaderProps = Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> &\n Pick<DrawerProps, \"title\" | \"icon\" | \"description\" | \"showCloseButton\" | \"headerActions\"> & {\n separator?: DrawerProps[\"headerSeparator\"];\n };\n\nexport const DrawerHeader = ({\n title,\n icon,\n description,\n showCloseButton,\n headerActions,\n separator,\n className,\n ...props\n}: DrawerHeaderProps) => {\n const nothingToRender = useMemo(() => {\n return !title && !description && !icon && !showCloseButton && !headerActions;\n }, [title, description, icon, showCloseButton, headerActions]);\n\n if (nothingToRender) {\n return null;\n }\n\n return (\n <>\n <div\n {...props}\n className={cn(\n \"flex flex-col gap-sm px-lg py-md text-center sm:text-left text-neutral-primary\",\n className\n )}\n >\n {/* Buttons stay outside the title, so they don't become part of the dialog's name. */}\n <div className={\"flex items-center justify-between gap-sm\"}>\n <DrawerTitle className={\"items-center gap-xs\"}>\n {icon}\n {title}\n </DrawerTitle>\n\n <div className={\"flex items-center gap-xs\"}>\n {headerActions}\n {showCloseButton !== false && (\n <DrawerPrimitive.Close asChild>\n <IconButton\n size=\"md\"\n iconSize=\"lg\"\n variant={\"ghost\"}\n icon={<XIcon />}\n />\n </DrawerPrimitive.Close>\n )}\n </div>\n </div>\n {description && <DrawerDescription>{description}</DrawerDescription>}\n </div>\n {separator && <Separator />}\n </>\n );\n};\n"],"names":["DrawerHeader","title","icon","description","showCloseButton","headerActions","separator","className","props","nothingToRender","useMemo","cn","DrawerTitle","DrawerPrimitive","IconButton","XIcon","DrawerDescription","Separator"],"mappings":";;;;;;;;AAgBO,MAAMA,eAAe,CAAC,EACzBC,KAAK,EACLC,IAAI,EACJC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,SAAS,EACTC,SAAS,EACT,GAAGC,OACa;IAChB,MAAMC,kBAAkBC,AAAAA,IAAAA,wBAAAA,OAAAA,AAAAA,EAAQ,IACrB,CAACT,SAAS,CAACE,eAAe,CAACD,QAAQ,CAACE,mBAAmB,CAACC,eAChE;QAACJ;QAAOE;QAAaD;QAAME;QAAiBC;KAAc;IAE7D,IAAII,iBACA,OAAO;IAGX,OAAO,WAAP,GACI,4FACI,sCAAC;QACI,GAAGD,KAAK;QACT,WAAWG,GACP,kFACAJ;qBAIJ,sCAAC;QAAI,WAAW;qBACZ,sCAACK,aAAWA;QAAC,WAAW;OACnBV,MACAD,QAAAA,WAAAA,GAGL,sCAAC;QAAI,WAAW;OACXI,eACAD,AAAoB,UAApBA,mBAA6B,WAAT,GACjB,sCAACS,OAAAA,KAAqB;QAAC;qBACnB,sCAACC,YAAUA;QACP,MAAK;QACL,UAAS;QACT,SAAS;QACT,oBAAM,sCAACC,gBAAKA;WAM/BZ,eAAe,WAAfA,GAAe,sCAACa,mBAAiBA,MAAEb,eAEvCG,aAAa,WAAbA,GAAa,sCAACW,WAASA;AAGpC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { IconProps as IconComponentProps } from "../../Icon/index.js";
|
|
3
3
|
type IconProps = IconComponentProps;
|
|
4
|
-
declare const IconBase: (
|
|
4
|
+
declare const IconBase: (props: IconProps) => React.JSX.Element;
|
|
5
5
|
export declare const Icon: typeof IconBase & {
|
|
6
6
|
original: typeof IconBase;
|
|
7
7
|
originalName: string;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeDecoratable } from "../../utils.js";
|
|
2
2
|
import { Icon } from "../../Icon/index.js";
|
|
3
3
|
import * as __rspack_external_react from "react";
|
|
4
|
-
const IconBase = (
|
|
4
|
+
const IconBase = (props)=>/*#__PURE__*/ __rspack_external_react.createElement(Icon, {
|
|
5
5
|
size: "lg",
|
|
6
6
|
color: "neutral-strong",
|
|
7
|
-
...props
|
|
8
|
-
className: cn("pt-xs", className)
|
|
7
|
+
...props
|
|
9
8
|
});
|
|
10
9
|
const Icon_Icon = makeDecoratable("Icon", IconBase);
|
|
11
10
|
export { Icon_Icon as Icon };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer/components/Icon.js","sources":["../../../src/Drawer/components/Icon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"Drawer/components/Icon.js","sources":["../../../src/Drawer/components/Icon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport type { IconProps as IconComponentProps } from \"~/Icon/index.js\";\nimport { Icon as IconComponent } from \"~/Icon/index.js\";\n\ntype IconProps = IconComponentProps;\n\nconst IconBase = (props: IconProps) => {\n return <IconComponent size={\"lg\"} color={\"neutral-strong\"} {...props} />;\n};\n\nexport const Icon = makeDecoratable(\"Icon\", IconBase);\n"],"names":["IconBase","props","IconComponent","Icon","makeDecoratable"],"mappings":";;;AAOA,MAAMA,WAAW,CAACC,QACP,WAAP,GAAO,sCAACC,MAAaA;QAAC,MAAM;QAAM,OAAO;QAAmB,GAAGD,KAAK;;AAGjE,MAAME,YAAOC,gBAAgB,QAAQJ"}
|
|
@@ -18,9 +18,10 @@ interface EmptyStateProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "ti
|
|
|
18
18
|
title?: React.ReactNode;
|
|
19
19
|
description?: React.ReactNode;
|
|
20
20
|
illustration?: boolean;
|
|
21
|
+
icon?: React.ReactElement;
|
|
21
22
|
actions?: React.ReactNode;
|
|
22
23
|
}
|
|
23
|
-
declare const DecoratableEmptyState: ({ size, type, title, description, illustration, actions, className, ...props }: EmptyStateProps) => React.JSX.Element;
|
|
24
|
+
declare const DecoratableEmptyState: ({ size, type, title, description, illustration, icon, actions, className, ...props }: EmptyStateProps) => React.JSX.Element;
|
|
24
25
|
declare const EmptyState: typeof DecoratableEmptyState & {
|
|
25
26
|
original: typeof DecoratableEmptyState;
|
|
26
27
|
originalName: string;
|
package/EmptyState/EmptyState.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { cn, cva, makeDecoratable } from "../utils.js";
|
|
3
3
|
import { Text } from "../Text/index.js";
|
|
4
|
+
import { Icon } from "../Icon/index.js";
|
|
4
5
|
import { ContentIllustration, LayoutIllustration, ListingIllustration, SelectIllustration, TableIllustration, UploadIllustration } from "./illustrations/index.js";
|
|
5
6
|
const ILLUSTRATIONS = {
|
|
6
7
|
content: ContentIllustration,
|
|
@@ -58,7 +59,7 @@ const DESCRIPTION_SIZE = {
|
|
|
58
59
|
md: "md",
|
|
59
60
|
lg: "md"
|
|
60
61
|
};
|
|
61
|
-
const DecoratableEmptyState = ({ size = "md", type = "content", title, description, illustration = true, actions, className, ...props })=>{
|
|
62
|
+
const DecoratableEmptyState = ({ size = "md", type = "content", title, description, illustration = true, icon, actions, className, ...props })=>{
|
|
62
63
|
const resolvedSize = size ?? "md";
|
|
63
64
|
const Illustration = ILLUSTRATIONS[type];
|
|
64
65
|
return /*#__PURE__*/ react.createElement("div", {
|
|
@@ -66,7 +67,12 @@ const DecoratableEmptyState = ({ size = "md", type = "content", title, descripti
|
|
|
66
67
|
size: resolvedSize
|
|
67
68
|
}), className),
|
|
68
69
|
...props
|
|
69
|
-
},
|
|
70
|
+
}, icon ? /*#__PURE__*/ react.createElement(Icon, {
|
|
71
|
+
icon: icon,
|
|
72
|
+
size: "lg",
|
|
73
|
+
color: "neutral-strong",
|
|
74
|
+
label: ""
|
|
75
|
+
}) : null, !icon && illustration ? /*#__PURE__*/ react.createElement(Illustration, {
|
|
70
76
|
className: "shrink-0",
|
|
71
77
|
width: ILLUSTRATION_DIMENSIONS[resolvedSize].width,
|
|
72
78
|
height: ILLUSTRATION_DIMENSIONS[resolvedSize].height,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState/EmptyState.js","sources":["../../src/EmptyState/EmptyState.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, cva, type VariantProps, makeDecoratable } from \"~/utils.js\";\nimport { Text } from \"~/Text/index.js\";\nimport {\n ContentIllustration,\n LayoutIllustration,\n ListingIllustration,\n SelectIllustration,\n TableIllustration,\n UploadIllustration\n} from \"./illustrations/index.js\";\n\nconst ILLUSTRATIONS = {\n content: ContentIllustration,\n table: TableIllustration,\n listing: ListingIllustration,\n layout: LayoutIllustration,\n upload: UploadIllustration,\n select: SelectIllustration\n};\n\ntype EmptyStateType = keyof typeof ILLUSTRATIONS;\n\nconst emptyStateVariants = cva(\n \"w-full flex flex-col items-center justify-center text-center px-lg\",\n {\n variants: {\n size: {\n sm: \"gap-md py-[56px]\",\n md: \"gap-md-plus py-[80px]\",\n lg: \"gap-lg py-[96px]\"\n }\n },\n defaultVariants: {\n size: \"md\"\n }\n }\n);\n\n// Illustration dimensions per size. Set as explicit SVG `width`/`height` so the\n// rendered size is deterministic and doesn't depend on Tailwind generating\n// arbitrary width/height utilities for consumers.\nconst ILLUSTRATION_DIMENSIONS = {\n sm: { width: 88, height: 73 },\n md: { width: 145, height: 120 },\n lg: { width: 181, height: 150 }\n} as const;\n\nconst contentVariants = cva(\n \"flex flex-col items-center w-full text-neutral-strong [word-break:break-word]\",\n {\n variants: {\n size: {\n sm: \"gap-sm\",\n md: \"gap-sm\",\n lg: \"gap-sm-extra\"\n }\n },\n defaultVariants: {\n size: \"md\"\n }\n }\n);\n\n// The title scales up at the largest size; the description shrinks at the smallest.\nconst TITLE_SIZE = { sm: \"lg\", md: \"lg\", lg: \"xl\" } as const;\nconst DESCRIPTION_SIZE = { sm: \"sm\", md: \"md\", lg: \"md\" } as const;\n\ninterface EmptyStateProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, \"title\">,\n VariantProps<typeof emptyStateVariants> {\n // The illustration that best matches the empty context.\n type?: EmptyStateType;\n title?: React.ReactNode;\n description?: React.ReactNode;\n // Whether to render the illustration. Defaults to `true`.\n illustration?: boolean;\n // Optional call-to-action buttons, rendered below the text.\n actions?: React.ReactNode;\n}\n\nconst DecoratableEmptyState = ({\n size = \"md\",\n type = \"content\",\n title,\n description,\n illustration = true,\n actions,\n className,\n ...props\n}: EmptyStateProps) => {\n const resolvedSize = size ?? \"md\";\n const Illustration = ILLUSTRATIONS[type];\n\n return (\n <div className={cn(emptyStateVariants({ size: resolvedSize }), className)} {...props}>\n {illustration ? (\n <Illustration\n className={\"shrink-0\"}\n width={ILLUSTRATION_DIMENSIONS[resolvedSize].width}\n height={ILLUSTRATION_DIMENSIONS[resolvedSize].height}\n aria-hidden={true}\n />\n ) : null}\n {title || description ? (\n <div className={contentVariants({ size: resolvedSize })}>\n {title ? (\n <Text\n as={\"div\"}\n size={TITLE_SIZE[resolvedSize]}\n className={\"font-semibold max-w-[520px]\"}\n >\n {title}\n </Text>\n ) : null}\n {description ? (\n <Text\n as={\"div\"}\n size={DESCRIPTION_SIZE[resolvedSize]}\n className={\"max-w-[600px]\"}\n >\n {description}\n </Text>\n ) : null}\n </div>\n ) : null}\n {actions ? (\n <div className={\"flex items-center justify-center gap-sm-extra\"}>{actions}</div>\n ) : null}\n </div>\n );\n};\n\nconst EmptyState = makeDecoratable(\"EmptyState\", DecoratableEmptyState);\n\nexport { EmptyState, type EmptyStateProps, type EmptyStateType };\n"],"names":["ILLUSTRATIONS","ContentIllustration","TableIllustration","ListingIllustration","LayoutIllustration","UploadIllustration","SelectIllustration","emptyStateVariants","cva","ILLUSTRATION_DIMENSIONS","contentVariants","TITLE_SIZE","DESCRIPTION_SIZE","DecoratableEmptyState","size","type","title","description","illustration","actions","className","props","resolvedSize","Illustration","cn","Text","EmptyState","makeDecoratable"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmptyState/EmptyState.js","sources":["../../src/EmptyState/EmptyState.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, cva, type VariantProps, makeDecoratable } from \"~/utils.js\";\nimport { Text } from \"~/Text/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport {\n ContentIllustration,\n LayoutIllustration,\n ListingIllustration,\n SelectIllustration,\n TableIllustration,\n UploadIllustration\n} from \"./illustrations/index.js\";\n\nconst ILLUSTRATIONS = {\n content: ContentIllustration,\n table: TableIllustration,\n listing: ListingIllustration,\n layout: LayoutIllustration,\n upload: UploadIllustration,\n select: SelectIllustration\n};\n\ntype EmptyStateType = keyof typeof ILLUSTRATIONS;\n\nconst emptyStateVariants = cva(\n \"w-full flex flex-col items-center justify-center text-center px-lg\",\n {\n variants: {\n size: {\n sm: \"gap-md py-[56px]\",\n md: \"gap-md-plus py-[80px]\",\n lg: \"gap-lg py-[96px]\"\n }\n },\n defaultVariants: {\n size: \"md\"\n }\n }\n);\n\n// Illustration dimensions per size. Set as explicit SVG `width`/`height` so the\n// rendered size is deterministic and doesn't depend on Tailwind generating\n// arbitrary width/height utilities for consumers.\nconst ILLUSTRATION_DIMENSIONS = {\n sm: { width: 88, height: 73 },\n md: { width: 145, height: 120 },\n lg: { width: 181, height: 150 }\n} as const;\n\nconst contentVariants = cva(\n \"flex flex-col items-center w-full text-neutral-strong [word-break:break-word]\",\n {\n variants: {\n size: {\n sm: \"gap-sm\",\n md: \"gap-sm\",\n lg: \"gap-sm-extra\"\n }\n },\n defaultVariants: {\n size: \"md\"\n }\n }\n);\n\n// The title scales up at the largest size; the description shrinks at the smallest.\nconst TITLE_SIZE = { sm: \"lg\", md: \"lg\", lg: \"xl\" } as const;\nconst DESCRIPTION_SIZE = { sm: \"sm\", md: \"md\", lg: \"md\" } as const;\n\ninterface EmptyStateProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, \"title\">,\n VariantProps<typeof emptyStateVariants> {\n // The illustration that best matches the empty context.\n type?: EmptyStateType;\n title?: React.ReactNode;\n description?: React.ReactNode;\n // Whether to render the illustration. Defaults to `true`.\n illustration?: boolean;\n // A 24px icon in place of the illustration, for a small empty state inside a panel or a palette.\n icon?: React.ReactElement;\n // Optional call-to-action buttons, rendered below the text.\n actions?: React.ReactNode;\n}\n\nconst DecoratableEmptyState = ({\n size = \"md\",\n type = \"content\",\n title,\n description,\n illustration = true,\n icon,\n actions,\n className,\n ...props\n}: EmptyStateProps) => {\n const resolvedSize = size ?? \"md\";\n const Illustration = ILLUSTRATIONS[type];\n\n return (\n <div className={cn(emptyStateVariants({ size: resolvedSize }), className)} {...props}>\n {icon ? <Icon icon={icon} size={\"lg\"} color={\"neutral-strong\"} label={\"\"} /> : null}\n {!icon && illustration ? (\n <Illustration\n className={\"shrink-0\"}\n width={ILLUSTRATION_DIMENSIONS[resolvedSize].width}\n height={ILLUSTRATION_DIMENSIONS[resolvedSize].height}\n aria-hidden={true}\n />\n ) : null}\n {title || description ? (\n <div className={contentVariants({ size: resolvedSize })}>\n {title ? (\n <Text\n as={\"div\"}\n size={TITLE_SIZE[resolvedSize]}\n className={\"font-semibold max-w-[520px]\"}\n >\n {title}\n </Text>\n ) : null}\n {description ? (\n <Text\n as={\"div\"}\n size={DESCRIPTION_SIZE[resolvedSize]}\n className={\"max-w-[600px]\"}\n >\n {description}\n </Text>\n ) : null}\n </div>\n ) : null}\n {actions ? (\n <div className={\"flex items-center justify-center gap-sm-extra\"}>{actions}</div>\n ) : null}\n </div>\n );\n};\n\nconst EmptyState = makeDecoratable(\"EmptyState\", DecoratableEmptyState);\n\nexport { EmptyState, type EmptyStateProps, type EmptyStateType };\n"],"names":["ILLUSTRATIONS","ContentIllustration","TableIllustration","ListingIllustration","LayoutIllustration","UploadIllustration","SelectIllustration","emptyStateVariants","cva","ILLUSTRATION_DIMENSIONS","contentVariants","TITLE_SIZE","DESCRIPTION_SIZE","DecoratableEmptyState","size","type","title","description","illustration","icon","actions","className","props","resolvedSize","Illustration","cn","Icon","Text","EmptyState","makeDecoratable"],"mappings":";;;;;AAaA,MAAMA,gBAAgB;IAClB,SAASC;IACT,OAAOC;IACP,SAASC;IACT,QAAQC;IACR,QAAQC;IACR,QAAQC;AACZ;AAIA,MAAMC,qBAAqBC,IACvB,sEACA;IACI,UAAU;QACN,MAAM;YACF,IAAI;YACJ,IAAI;YACJ,IAAI;QACR;IACJ;IACA,iBAAiB;QACb,MAAM;IACV;AACJ;AAMJ,MAAMC,0BAA0B;IAC5B,IAAI;QAAE,OAAO;QAAI,QAAQ;IAAG;IAC5B,IAAI;QAAE,OAAO;QAAK,QAAQ;IAAI;IAC9B,IAAI;QAAE,OAAO;QAAK,QAAQ;IAAI;AAClC;AAEA,MAAMC,kBAAkBF,IACpB,iFACA;IACI,UAAU;QACN,MAAM;YACF,IAAI;YACJ,IAAI;YACJ,IAAI;QACR;IACJ;IACA,iBAAiB;QACb,MAAM;IACV;AACJ;AAIJ,MAAMG,aAAa;IAAE,IAAI;IAAM,IAAI;IAAM,IAAI;AAAK;AAClD,MAAMC,mBAAmB;IAAE,IAAI;IAAM,IAAI;IAAM,IAAI;AAAK;AAkBxD,MAAMC,wBAAwB,CAAC,EAC3BC,OAAO,IAAI,EACXC,OAAO,SAAS,EAChBC,KAAK,EACLC,WAAW,EACXC,eAAe,IAAI,EACnBC,IAAI,EACJC,OAAO,EACPC,SAAS,EACT,GAAGC,OACW;IACd,MAAMC,eAAeT,QAAQ;IAC7B,MAAMU,eAAexB,aAAa,CAACe,KAAK;IAExC,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWU,GAAGlB,mBAAmB;YAAE,MAAMgB;QAAa,IAAIF;QAAa,GAAGC,KAAK;OAC/EH,OAAO,WAAPA,GAAO,oBAACO,MAAIA;QAAC,MAAMP;QAAM,MAAM;QAAM,OAAO;QAAkB,OAAO;SAAS,MAC9E,CAACA,QAAQD,eAAe,WAAfA,GACN,oBAACM,cAAAA;QACG,WAAW;QACX,OAAOf,uBAAuB,CAACc,aAAa,CAAC,KAAK;QAClD,QAAQd,uBAAuB,CAACc,aAAa,CAAC,MAAM;QACpD,eAAa;SAEjB,MACHP,SAASC,cAAc,WAAdA,GACN,oBAAC;QAAI,WAAWP,gBAAgB;YAAE,MAAMa;QAAa;OAChDP,QAAQ,WAARA,GACG,oBAACW,MAAIA;QACD,IAAI;QACJ,MAAMhB,UAAU,CAACY,aAAa;QAC9B,WAAW;OAEVP,SAEL,MACHC,cAAc,WAAdA,GACG,oBAACU,MAAIA;QACD,IAAI;QACJ,MAAMf,gBAAgB,CAACW,aAAa;QACpC,WAAW;OAEVN,eAEL,QAER,MACHG,UAAU,WAAVA,GACG,oBAAC;QAAI,WAAW;OAAkDA,WAClE;AAGhB;AAEA,MAAMQ,aAAaC,gBAAgB,cAAchB"}
|
package/FilePicker/FilePicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import react, { useCallback, useMemo } from "react";
|
|
2
|
-
import { makeDecoratable, withStaticProps } from "../utils.js";
|
|
2
|
+
import { generateId, makeDecoratable, withStaticProps } from "../utils.js";
|
|
3
3
|
import { FilePickerDescription, FilePickerLabel, FilePickerPrimitive } from "./primitives/index.js";
|
|
4
4
|
import { FormComponentErrorMessage, FormComponentNote } from "../FormComponent/index.js";
|
|
5
5
|
import { ImagePreview, RichItemPreview, TextOnlyPreview } from "./primitives/components/index.js";
|
|
@@ -8,6 +8,9 @@ const BaseFilePicker = ({ label, hint, description, note, required, disabled, va
|
|
|
8
8
|
const invalid = useMemo(()=>false === validationIsValid, [
|
|
9
9
|
validationIsValid
|
|
10
10
|
]);
|
|
11
|
+
const id = useMemo(()=>generateId(props.id), [
|
|
12
|
+
props.id
|
|
13
|
+
]);
|
|
11
14
|
const onBlur = useCallback(async (e)=>{
|
|
12
15
|
if (validate) {
|
|
13
16
|
e.persist();
|
|
@@ -21,6 +24,7 @@ const BaseFilePicker = ({ label, hint, description, note, required, disabled, va
|
|
|
21
24
|
return /*#__PURE__*/ react.createElement("div", {
|
|
22
25
|
className: "w-full"
|
|
23
26
|
}, "area" !== type && /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(FilePickerLabel, {
|
|
27
|
+
htmlFor: id,
|
|
24
28
|
label: label,
|
|
25
29
|
hint: hint,
|
|
26
30
|
required: required,
|
|
@@ -31,6 +35,7 @@ const BaseFilePicker = ({ label, hint, description, note, required, disabled, va
|
|
|
31
35
|
disabled: disabled
|
|
32
36
|
})), /*#__PURE__*/ react.createElement(FilePickerPrimitive, {
|
|
33
37
|
...props,
|
|
38
|
+
id: id,
|
|
34
39
|
label: label,
|
|
35
40
|
description: description,
|
|
36
41
|
disabled: disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/FilePicker.js","sources":["../../src/FilePicker/FilePicker.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport { makeDecoratable, withStaticProps } from \"~/utils.js\";\nimport {\n FilePickerDescription,\n FilePickerLabel,\n FilePickerPrimitive,\n type FilePickerPrimitiveProps\n} from \"./primitives/index.js\";\nimport {\n FormComponentErrorMessage,\n FormComponentNote,\n type FormComponentProps\n} from \"~/FormComponent/index.js\";\nimport {\n ImagePreview,\n RichItemPreview,\n TextOnlyPreview\n} from \"~/FilePicker/primitives/components/index.js\";\n\ntype FilePickerProps = FilePickerPrimitiveProps & Omit<FormComponentProps, \"value\">;\n\nconst BaseFilePicker = ({\n label,\n hint,\n description,\n note,\n required,\n disabled,\n validation,\n validate,\n onBlur: originalOnBlur,\n type = \"area\",\n ...props\n}: FilePickerProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n\n const onBlur = useCallback(\n async (e: React.FocusEvent<HTMLInputElement>) => {\n if (validate) {\n // Since we are accessing event in an async operation, we need to persist it.\n // See https://reactjs.org/docs/events.html#event-pooling.\n e.persist();\n await validate();\n }\n originalOnBlur && originalOnBlur(e);\n },\n [validate, originalOnBlur]\n );\n\n return (\n <div className={\"w-full\"}>\n {type !== \"area\" && (\n <>\n <FilePickerLabel\n label={label}\n hint={hint}\n required={required}\n disabled={disabled}\n invalid={invalid}\n />\n <FilePickerDescription description={description} disabled={disabled} />\n </>\n )}\n <FilePickerPrimitive\n {...props}\n label={label}\n description={description}\n disabled={disabled}\n invalid={invalid}\n onBlur={onBlur}\n type={type}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={disabled}\n />\n <FormComponentNote text={note} disabled={disabled} />\n </div>\n );\n};\n\nconst DecoratableFilePicker = makeDecoratable(\"FilePicker\", BaseFilePicker);\n\nconst FilePicker = withStaticProps(DecoratableFilePicker, {\n Preview: {\n Image: ImagePreview,\n RichItem: RichItemPreview,\n TextOnly: TextOnlyPreview\n }\n});\nexport { FilePicker, type FilePickerProps };\n"],"names":["BaseFilePicker","label","hint","description","note","required","disabled","validation","validate","originalOnBlur","type","props","validationIsValid","validationMessage","invalid","useMemo","onBlur","useCallback","e","FilePickerLabel","FilePickerDescription","FilePickerPrimitive","FormComponentErrorMessage","FormComponentNote","DecoratableFilePicker","makeDecoratable","FilePicker","withStaticProps","ImagePreview","RichItemPreview","TextOnlyPreview"],"mappings":";;;;;AAqBA,MAAMA,iBAAiB,CAAC,EACpBC,KAAK,EACLC,IAAI,EACJC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACR,QAAQC,cAAc,EACtBC,OAAO,MAAM,EACb,GAAGC,OACW;IACd,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGN,cAAc,CAAC;IAClF,MAAMO,UAAUC,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,MAAMI,SAASC,YACX,OAAOC;QACH,
|
|
1
|
+
{"version":3,"file":"FilePicker/FilePicker.js","sources":["../../src/FilePicker/FilePicker.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport { makeDecoratable, withStaticProps, generateId } from \"~/utils.js\";\nimport {\n FilePickerDescription,\n FilePickerLabel,\n FilePickerPrimitive,\n type FilePickerPrimitiveProps\n} from \"./primitives/index.js\";\nimport {\n FormComponentErrorMessage,\n FormComponentNote,\n type FormComponentProps\n} from \"~/FormComponent/index.js\";\nimport {\n ImagePreview,\n RichItemPreview,\n TextOnlyPreview\n} from \"~/FilePicker/primitives/components/index.js\";\n\ntype FilePickerProps = FilePickerPrimitiveProps & Omit<FormComponentProps, \"value\">;\n\nconst BaseFilePicker = ({\n label,\n hint,\n description,\n note,\n required,\n disabled,\n validation,\n validate,\n onBlur: originalOnBlur,\n type = \"area\",\n ...props\n}: FilePickerProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n /* The label names the trigger button, wherever the label is drawn. */\n const id = useMemo(() => generateId(props.id), [props.id]);\n\n const onBlur = useCallback(\n async (e: React.FocusEvent<HTMLInputElement>) => {\n if (validate) {\n // Since we are accessing event in an async operation, we need to persist it.\n // See https://reactjs.org/docs/events.html#event-pooling.\n e.persist();\n await validate();\n }\n originalOnBlur && originalOnBlur(e);\n },\n [validate, originalOnBlur]\n );\n\n return (\n <div className={\"w-full\"}>\n {type !== \"area\" && (\n <>\n <FilePickerLabel\n htmlFor={id}\n label={label}\n hint={hint}\n required={required}\n disabled={disabled}\n invalid={invalid}\n />\n <FilePickerDescription description={description} disabled={disabled} />\n </>\n )}\n <FilePickerPrimitive\n {...props}\n id={id}\n label={label}\n description={description}\n disabled={disabled}\n invalid={invalid}\n onBlur={onBlur}\n type={type}\n />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={disabled}\n />\n <FormComponentNote text={note} disabled={disabled} />\n </div>\n );\n};\n\nconst DecoratableFilePicker = makeDecoratable(\"FilePicker\", BaseFilePicker);\n\nconst FilePicker = withStaticProps(DecoratableFilePicker, {\n Preview: {\n Image: ImagePreview,\n RichItem: RichItemPreview,\n TextOnly: TextOnlyPreview\n }\n});\nexport { FilePicker, type FilePickerProps };\n"],"names":["BaseFilePicker","label","hint","description","note","required","disabled","validation","validate","originalOnBlur","type","props","validationIsValid","validationMessage","invalid","useMemo","id","generateId","onBlur","useCallback","e","FilePickerLabel","FilePickerDescription","FilePickerPrimitive","FormComponentErrorMessage","FormComponentNote","DecoratableFilePicker","makeDecoratable","FilePicker","withStaticProps","ImagePreview","RichItemPreview","TextOnlyPreview"],"mappings":";;;;;AAqBA,MAAMA,iBAAiB,CAAC,EACpBC,KAAK,EACLC,IAAI,EACJC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACR,QAAQC,cAAc,EACtBC,OAAO,MAAM,EACb,GAAGC,OACW;IACd,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGN,cAAc,CAAC;IAClF,MAAMO,UAAUC,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,MAAMI,KAAKD,QAAQ,IAAME,WAAWN,MAAM,EAAE,GAAG;QAACA,MAAM,EAAE;KAAC;IAEzD,MAAMO,SAASC,YACX,OAAOC;QACH,IAAIZ,UAAU;YAGVY,EAAE,OAAO;YACT,MAAMZ;QACV;QACAC,kBAAkBA,eAAeW;IACrC,GACA;QAACZ;QAAUC;KAAe;IAG9B,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXC,AAAS,WAATA,QAAmB,WAAV,GACN,wDACI,oBAACW,iBAAeA;QACZ,SAASL;QACT,OAAOf;QACP,MAAMC;QACN,UAAUG;QACV,UAAUC;QACV,SAASQ;sBAEb,oBAACQ,uBAAqBA;QAAC,aAAanB;QAAa,UAAUG;uBAGnE,oBAACiB,qBAAmBA;QACf,GAAGZ,KAAK;QACT,IAAIK;QACJ,OAAOf;QACP,aAAaE;QACb,UAAUG;QACV,SAASQ;QACT,QAAQI;QACR,MAAMR;sBAEV,oBAACc,2BAAyBA;QACtB,MAAMX;QACN,SAASC;QACT,UAAUR;sBAEd,oBAACmB,mBAAiBA;QAAC,MAAMrB;QAAM,UAAUE;;AAGrD;AAEA,MAAMoB,wBAAwBC,gBAAgB,cAAc3B;AAE5D,MAAM4B,aAAaC,gBAAgBH,uBAAuB;IACtD,SAAS;QACL,OAAOI;QACP,UAAUC;QACV,UAAUC;IACd;AACJ"}
|
|
@@ -22,4 +22,10 @@ export declare const CompactWithErrors: Story;
|
|
|
22
22
|
export declare const CompactDisabled: Story;
|
|
23
23
|
export declare const CompactWithValidateFunction: Story;
|
|
24
24
|
export declare const CompactFullExample: Story;
|
|
25
|
+
/**
|
|
26
|
+
* Reproduces the Website Builder style sidebar at its 206px value column: the preview stacks,
|
|
27
|
+
* the file name truncates in the middle so the extension and version suffix survive, and the
|
|
28
|
+
* actions spell themselves out instead of costing a fixed block of the row.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CompactWithLongFileNameInNarrowContainer: Story;
|
|
25
31
|
export declare const Documentation: Story;
|
|
@@ -210,6 +210,29 @@ const CompactFullExample = {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
+
const CompactWithLongFileNameInNarrowContainer = {
|
|
214
|
+
args: {
|
|
215
|
+
...Compact.args
|
|
216
|
+
},
|
|
217
|
+
render: (args)=>{
|
|
218
|
+
const [selectedFile, setSelectedFile] = useState({
|
|
219
|
+
name: "tide-cc-statuses-2026-08-21-final-v2.png",
|
|
220
|
+
mimeType: "image/png",
|
|
221
|
+
size: 674161,
|
|
222
|
+
url: "https://picsum.photos/1200/800"
|
|
223
|
+
});
|
|
224
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
225
|
+
style: {
|
|
226
|
+
width: 206
|
|
227
|
+
}
|
|
228
|
+
}, /*#__PURE__*/ react.createElement(FilePicker, {
|
|
229
|
+
...args,
|
|
230
|
+
value: selectedFile,
|
|
231
|
+
onSelectItem: ()=>setSelectedFile(getFile()),
|
|
232
|
+
onRemoveItem: ()=>setSelectedFile(null)
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
};
|
|
213
236
|
const Documentation = {
|
|
214
237
|
render: (args)=>{
|
|
215
238
|
const [selectedFile, setSelectedFile] = useState(args.value);
|
|
@@ -324,6 +347,6 @@ const Documentation = {
|
|
|
324
347
|
}
|
|
325
348
|
};
|
|
326
349
|
export default FilePicker_stories;
|
|
327
|
-
export { AreaDisabled, AreaFullExample, AreaType, AreaWithDescription, AreaWithErrors, AreaWithLabel, AreaWithLabelRequired, AreaWithNotes, AreaWithValidateFunction, Compact, CompactDisabled, CompactFullExample, CompactWithDescription, CompactWithErrors, CompactWithLabel, CompactWithLabelRequired, CompactWithNotes, CompactWithValidateFunction, Default, Documentation };
|
|
350
|
+
export { AreaDisabled, AreaFullExample, AreaType, AreaWithDescription, AreaWithErrors, AreaWithLabel, AreaWithLabelRequired, AreaWithNotes, AreaWithValidateFunction, Compact, CompactDisabled, CompactFullExample, CompactWithDescription, CompactWithErrors, CompactWithLabel, CompactWithLabelRequired, CompactWithLongFileNameInNarrowContainer, CompactWithNotes, CompactWithValidateFunction, Default, Documentation };
|
|
328
351
|
|
|
329
352
|
//# sourceMappingURL=FilePicker.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/FilePicker.stories.js","sources":["../../src/FilePicker/FilePicker.stories.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { type FileItemDto, FilePicker } from \"~/FilePicker/index.js\";\n\nconst getRandomNumber = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n\nconst getFile = (): FileItemDto => {\n const width = getRandomNumber(500, 2000); // Random width between 500 and 2000\n const height = getRandomNumber(500, 2000); // Random height between 500 and 2000\n const fileSize = getRandomNumber(500000, 5000000); // Random file size between 500KB and 5MB\n\n return {\n name: \"selected-file.jpg\",\n mimeType: \"image/jpeg\",\n size: fileSize,\n url: `https://picsum.photos/${width}/${height}`\n };\n};\n\nconst meta: Meta<typeof FilePicker> = {\n title: \"Components/Form/FilePicker\",\n component: FilePicker,\n argTypes: {\n onSelectItem: { action: \"onSelectItem\" },\n onEditItem: { action: \"onEditItem\" },\n onRemoveItem: { action: \"onRemoveItem\" },\n disabled: {\n control: \"boolean\",\n defaultValue: false\n }\n },\n parameters: {\n layout: \"padded\"\n },\n render: args => {\n const [selectedFile, setSelectedFile] = useState(args.value);\n return (\n <FilePicker\n {...args}\n value={selectedFile}\n onSelectItem={() => setSelectedFile(getFile())}\n onRemoveItem={() => setSelectedFile(null)}\n onEditItem={() => alert(`Editing File`)}\n />\n );\n }\n};\n\nexport default meta;\ntype Story = StoryObj<typeof FilePicker>;\n\nexport const Default: Story = {};\n\nexport const AreaType: Story = {\n args: {\n ...Default.args,\n type: \"area\"\n }\n};\n\nexport const AreaWithLabel: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\"\n }\n};\n\nexport const AreaWithLabelRequired: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n required: true\n }\n};\n\nexport const AreaWithDescription: Story = {\n args: {\n ...AreaType.args,\n description: \"Provide the required information for processing your request.\"\n }\n};\n\nexport const AreaWithNotes: Story = {\n args: {\n ...AreaType.args,\n note: \"Note: Ensure your selection or input is accurate before proceeding.\"\n }\n};\n\nexport const AreaWithErrors: Story = {\n args: {\n ...AreaType.args,\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const AreaDisabled: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n disabled: true\n }\n};\n\nexport const AreaWithValidateFunction: Story = {\n args: {\n ...AreaType.args\n },\n render: args => {\n const [validation, setValidation] = useState<any>({ isValid: true, message: undefined });\n\n const validate = async () => {\n setValidation({ isValid: false, message: \"Any custom error message.\" });\n };\n\n return <FilePicker {...args} validate={validate} validation={validation} />;\n }\n};\n\nexport const AreaFullExample: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n required: true,\n description: \"Provide the required information for processing your request.\",\n note: \"Note: Ensure your selection or input is accurate before proceeding.\",\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const Compact: Story = {\n args: {\n ...Default.args,\n type: \"compact\"\n }\n};\n\nexport const CompactWithLabel: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\"\n }\n};\n\nexport const CompactWithLabelRequired: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n required: true\n }\n};\n\nexport const CompactWithDescription: Story = {\n args: {\n ...Compact.args,\n description: \"Provide the required information for processing your request.\"\n }\n};\n\nexport const CompactWithNotes: Story = {\n args: {\n ...Compact.args,\n note: \"Note: Ensure your selection or input is accurate before proceeding.\"\n }\n};\n\nexport const CompactWithErrors: Story = {\n args: {\n ...Compact.args,\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const CompactDisabled: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n disabled: true\n }\n};\n\nexport const CompactWithValidateFunction: Story = {\n args: {\n ...Compact.args\n },\n render: args => {\n const [validation, setValidation] = useState<any>({ isValid: true, message: undefined });\n\n const validate = async () => {\n setValidation({ isValid: false, message: \"Any custom error message.\" });\n };\n\n return <FilePicker {...args} validate={validate} validation={validation} />;\n }\n};\n\nexport const CompactFullExample: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n required: true,\n description: \"Provide the required information for processing your request.\",\n note: \"Note: Ensure your selection or input is accurate before proceeding.\",\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const Documentation: Story = {\n render: args => {\n const [selectedFile, setSelectedFile] = useState(args.value);\n const [validation, setValidation] = useState({ isValid: true, message: \"\" });\n\n // Update value when args.value changes\n useEffect(() => {\n setSelectedFile(args.value);\n }, [args.value]);\n\n const handleSelect = () => {\n setSelectedFile(getFile());\n setValidation({ isValid: true, message: \"\" });\n };\n\n const handleEdit = (file: any) => {\n if (file) {\n console.log(\"Editing file:\", file);\n alert(`Editing File: ${file.name}`);\n }\n };\n\n const handleRemove = () => {\n setSelectedFile(null);\n\n if (args.required) {\n setValidation({ isValid: false, message: \"Please select a file\" });\n }\n };\n\n // Validate on required change or value change\n useEffect(() => {\n if (args.required && !selectedFile) {\n setValidation({ isValid: false, message: \"Please select a file\" });\n } else {\n setValidation({ isValid: true, message: \"\" });\n }\n }, [args.required, selectedFile]);\n\n return (\n <FilePicker\n {...args}\n value={selectedFile}\n onSelectItem={handleSelect}\n onRemoveItem={handleRemove}\n onEditItem={handleEdit}\n validation={validation}\n />\n );\n },\n args: {\n label: \"Upload Image\",\n required: true,\n disabled: false,\n description: \"Select a file to upload (JPG, PNG, PDF)\",\n note: \"Note: Maximum file size is 5MB\",\n type: \"area\",\n value: null,\n validation: undefined,\n onSelectItem: undefined,\n onEditItem: undefined,\n onRemoveItem: undefined\n },\n argTypes: {\n label: {\n description: \"Label text for the file picker\",\n control: \"text\"\n },\n required: {\n description: \"Makes the field required when set to true\",\n control: \"boolean\"\n },\n disabled: {\n description: \"Disables the file picker when set to true\",\n control: \"boolean\"\n },\n description: {\n description: \"Additional description text below the field\",\n control: \"text\"\n },\n note: {\n description: \"Additional note text below the field\",\n control: \"text\"\n },\n type: {\n description: \"The visual style of the file picker\",\n control: \"radio\",\n options: [\"area\", \"compact\"]\n },\n value: {\n description: \"The currently selected file\",\n control: \"object\"\n },\n validation: {\n description:\n \"Object containing validation state and message. Please refer to the example code for details on usage.\"\n },\n onSelectItem: {\n description: \"Function called when a file is selected\"\n },\n onEditItem: {\n description: \"Function called when a file is edited\"\n },\n onRemoveItem: {\n description: \"Function called when a file is removed\"\n }\n }\n};\n"],"names":["getRandomNumber","min","max","Math","getFile","width","height","fileSize","meta","FilePicker","args","selectedFile","setSelectedFile","useState","alert","Default","AreaType","AreaWithLabel","AreaWithLabelRequired","AreaWithDescription","AreaWithNotes","AreaWithErrors","AreaDisabled","AreaWithValidateFunction","validation","setValidation","undefined","validate","AreaFullExample","Compact","CompactWithLabel","CompactWithLabelRequired","CompactWithDescription","CompactWithNotes","CompactWithErrors","CompactDisabled","CompactWithValidateFunction","CompactFullExample","Documentation","useEffect","handleSelect","handleEdit","file","console","handleRemove"],"mappings":";;AAIA,MAAMA,kBAAkB,CAACC,KAAaC,MAClCC,KAAK,KAAK,CAACA,KAAK,MAAM,KAAMD,CAAAA,MAAMD,MAAM,MAAMA;AAElD,MAAMG,UAAU;IACZ,MAAMC,QAAQL,gBAAgB,KAAK;IACnC,MAAMM,SAASN,gBAAgB,KAAK;IACpC,MAAMO,WAAWP,gBAAgB,QAAQ;IAEzC,OAAO;QACH,MAAM;QACN,UAAU;QACV,MAAMO;QACN,KAAK,CAAC,sBAAsB,EAAEF,MAAM,CAAC,EAAEC,QAAQ;IACnD;AACJ;AAEA,MAAME,OAAgC;IAClC,OAAO;IACP,WAAWC;IACX,UAAU;QACN,cAAc;YAAE,QAAQ;QAAe;QACvC,YAAY;YAAE,QAAQ;QAAa;QACnC,cAAc;YAAE,QAAQ;QAAe;QACvC,UAAU;YACN,SAAS;YACT,cAAc;QAClB;IACJ;IACA,YAAY;QACR,QAAQ;IACZ;IACA,QAAQC,CAAAA;QACJ,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,SAASH,KAAK,KAAK;QAC3D,OAAO,WAAP,GACI,oBAACD,YAAUA;YACN,GAAGC,IAAI;YACR,OAAOC;YACP,cAAc,IAAMC,gBAAgBR;YACpC,cAAc,IAAMQ,gBAAgB;YACpC,YAAY,IAAME,MAAM;;IAGpC;AACJ;AAEA,2BAAeN;AAGR,MAAMO,UAAiB,CAAC;AAExB,MAAMC,WAAkB;IAC3B,MAAM;QACF,GAAGD,QAAQ,IAAI;QACf,MAAM;IACV;AACJ;AAEO,MAAME,gBAAuB;IAChC,MAAM;QACF,GAAGD,SAAS,IAAI;QAChB,OAAO;IACX;A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G,CAAC,iBAAiBD;gBAC7B5B,MAAM,CAAC,cAAc,EAAE4B,KAAK,IAAI,EAAE;YACtC;QACJ;QAEA,MAAME,eAAe;YACjBhC,gBAAgB;YAEhB,IAAIF,KAAK,QAAQ,EACbe,cAAc;gBAAE,SAAS;gBAAO,SAAS;YAAuB;QAExE;QAGAc,UAAU;YACF7B,KAAK,QAAQ,IAAI,CAACC,eAClBc,cAAc;gBAAE,SAAS;gBAAO,SAAS;YAAuB,KAEhEA,cAAc;gBAAE,SAAS;gBAAM,SAAS;YAAG;QAEnD,GAAG;YAACf,KAAK,QAAQ;YAAEC;SAAa;QAEhC,OAAO,WAAP,GACI,oBAACF,YAAUA;YACN,GAAGC,IAAI;YACR,OAAOC;YACP,cAAc6B;YACd,cAAcI;YACd,YAAYH;YACZ,YAAYjB;;IAGxB;IACA,MAAM;QACF,OAAO;QACP,UAAU;QACV,UAAU;QACV,aAAa;QACb,MAAM;QACN,MAAM;QACN,OAAO;QACP,YAAYE;QACZ,cAAcA;QACd,YAAYA;QACZ,cAAcA;IAClB;IACA,UAAU;QACN,OAAO;YACH,aAAa;YACb,SAAS;QACb;QACA,UAAU;YACN,aAAa;YACb,SAAS;QACb;QACA,UAAU;YACN,aAAa;YACb,SAAS;QACb;QACA,aAAa;YACT,aAAa;YACb,SAAS;QACb;QACA,MAAM;YACF,aAAa;YACb,SAAS;QACb;QACA,MAAM;YACF,aAAa;YACb,SAAS;YACT,SAAS;gBAAC;gBAAQ;aAAU;QAChC;QACA,OAAO;YACH,aAAa;YACb,SAAS;QACb;QACA,YAAY;YACR,aACI;QACR;QACA,cAAc;YACV,aAAa;QACjB;QACA,YAAY;YACR,aAAa;QACjB;QACA,cAAc;YACV,aAAa;QACjB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"FilePicker/FilePicker.stories.js","sources":["../../src/FilePicker/FilePicker.stories.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { type FileItemDto, FilePicker } from \"~/FilePicker/index.js\";\n\nconst getRandomNumber = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n\nconst getFile = (): FileItemDto => {\n const width = getRandomNumber(500, 2000); // Random width between 500 and 2000\n const height = getRandomNumber(500, 2000); // Random height between 500 and 2000\n const fileSize = getRandomNumber(500000, 5000000); // Random file size between 500KB and 5MB\n\n return {\n name: \"selected-file.jpg\",\n mimeType: \"image/jpeg\",\n size: fileSize,\n url: `https://picsum.photos/${width}/${height}`\n };\n};\n\nconst meta: Meta<typeof FilePicker> = {\n title: \"Components/Form/FilePicker\",\n component: FilePicker,\n argTypes: {\n onSelectItem: { action: \"onSelectItem\" },\n onEditItem: { action: \"onEditItem\" },\n onRemoveItem: { action: \"onRemoveItem\" },\n disabled: {\n control: \"boolean\",\n defaultValue: false\n }\n },\n parameters: {\n layout: \"padded\"\n },\n render: args => {\n const [selectedFile, setSelectedFile] = useState(args.value);\n return (\n <FilePicker\n {...args}\n value={selectedFile}\n onSelectItem={() => setSelectedFile(getFile())}\n onRemoveItem={() => setSelectedFile(null)}\n onEditItem={() => alert(`Editing File`)}\n />\n );\n }\n};\n\nexport default meta;\ntype Story = StoryObj<typeof FilePicker>;\n\nexport const Default: Story = {};\n\nexport const AreaType: Story = {\n args: {\n ...Default.args,\n type: \"area\"\n }\n};\n\nexport const AreaWithLabel: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\"\n }\n};\n\nexport const AreaWithLabelRequired: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n required: true\n }\n};\n\nexport const AreaWithDescription: Story = {\n args: {\n ...AreaType.args,\n description: \"Provide the required information for processing your request.\"\n }\n};\n\nexport const AreaWithNotes: Story = {\n args: {\n ...AreaType.args,\n note: \"Note: Ensure your selection or input is accurate before proceeding.\"\n }\n};\n\nexport const AreaWithErrors: Story = {\n args: {\n ...AreaType.args,\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const AreaDisabled: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n disabled: true\n }\n};\n\nexport const AreaWithValidateFunction: Story = {\n args: {\n ...AreaType.args\n },\n render: args => {\n const [validation, setValidation] = useState<any>({ isValid: true, message: undefined });\n\n const validate = async () => {\n setValidation({ isValid: false, message: \"Any custom error message.\" });\n };\n\n return <FilePicker {...args} validate={validate} validation={validation} />;\n }\n};\n\nexport const AreaFullExample: Story = {\n args: {\n ...AreaType.args,\n label: \"Any field label\",\n required: true,\n description: \"Provide the required information for processing your request.\",\n note: \"Note: Ensure your selection or input is accurate before proceeding.\",\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const Compact: Story = {\n args: {\n ...Default.args,\n type: \"compact\"\n }\n};\n\nexport const CompactWithLabel: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\"\n }\n};\n\nexport const CompactWithLabelRequired: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n required: true\n }\n};\n\nexport const CompactWithDescription: Story = {\n args: {\n ...Compact.args,\n description: \"Provide the required information for processing your request.\"\n }\n};\n\nexport const CompactWithNotes: Story = {\n args: {\n ...Compact.args,\n note: \"Note: Ensure your selection or input is accurate before proceeding.\"\n }\n};\n\nexport const CompactWithErrors: Story = {\n args: {\n ...Compact.args,\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\nexport const CompactDisabled: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n disabled: true\n }\n};\n\nexport const CompactWithValidateFunction: Story = {\n args: {\n ...Compact.args\n },\n render: args => {\n const [validation, setValidation] = useState<any>({ isValid: true, message: undefined });\n\n const validate = async () => {\n setValidation({ isValid: false, message: \"Any custom error message.\" });\n };\n\n return <FilePicker {...args} validate={validate} validation={validation} />;\n }\n};\n\nexport const CompactFullExample: Story = {\n args: {\n ...Compact.args,\n label: \"Any field label\",\n required: true,\n description: \"Provide the required information for processing your request.\",\n note: \"Note: Ensure your selection or input is accurate before proceeding.\",\n validation: {\n isValid: false,\n message: \"This field is required.\"\n }\n }\n};\n\n/**\n * Reproduces the Website Builder style sidebar at its 206px value column: the preview stacks,\n * the file name truncates in the middle so the extension and version suffix survive, and the\n * actions spell themselves out instead of costing a fixed block of the row.\n */\nexport const CompactWithLongFileNameInNarrowContainer: Story = {\n args: {\n ...Compact.args\n },\n render: args => {\n const [selectedFile, setSelectedFile] = useState<FileItemDto | null>({\n name: \"tide-cc-statuses-2026-08-21-final-v2.png\",\n mimeType: \"image/png\",\n size: 674161,\n url: \"https://picsum.photos/1200/800\"\n });\n\n return (\n <div style={{ width: 206 }}>\n <FilePicker\n {...args}\n value={selectedFile}\n onSelectItem={() => setSelectedFile(getFile())}\n onRemoveItem={() => setSelectedFile(null)}\n />\n </div>\n );\n }\n};\n\nexport const Documentation: Story = {\n render: args => {\n const [selectedFile, setSelectedFile] = useState(args.value);\n const [validation, setValidation] = useState({ isValid: true, message: \"\" });\n\n // Update value when args.value changes\n useEffect(() => {\n setSelectedFile(args.value);\n }, [args.value]);\n\n const handleSelect = () => {\n setSelectedFile(getFile());\n setValidation({ isValid: true, message: \"\" });\n };\n\n const handleEdit = (file: any) => {\n if (file) {\n console.log(\"Editing file:\", file);\n alert(`Editing File: ${file.name}`);\n }\n };\n\n const handleRemove = () => {\n setSelectedFile(null);\n\n if (args.required) {\n setValidation({ isValid: false, message: \"Please select a file\" });\n }\n };\n\n // Validate on required change or value change\n useEffect(() => {\n if (args.required && !selectedFile) {\n setValidation({ isValid: false, message: \"Please select a file\" });\n } else {\n setValidation({ isValid: true, message: \"\" });\n }\n }, [args.required, selectedFile]);\n\n return (\n <FilePicker\n {...args}\n value={selectedFile}\n onSelectItem={handleSelect}\n onRemoveItem={handleRemove}\n onEditItem={handleEdit}\n validation={validation}\n />\n );\n },\n args: {\n label: \"Upload Image\",\n required: true,\n disabled: false,\n description: \"Select a file to upload (JPG, PNG, PDF)\",\n note: \"Note: Maximum file size is 5MB\",\n type: \"area\",\n value: null,\n validation: undefined,\n onSelectItem: undefined,\n onEditItem: undefined,\n onRemoveItem: undefined\n },\n argTypes: {\n label: {\n description: \"Label text for the file picker\",\n control: \"text\"\n },\n required: {\n description: \"Makes the field required when set to true\",\n control: \"boolean\"\n },\n disabled: {\n description: \"Disables the file picker when set to true\",\n control: \"boolean\"\n },\n description: {\n description: \"Additional description text below the field\",\n control: \"text\"\n },\n note: {\n description: \"Additional note text below the field\",\n control: \"text\"\n },\n type: {\n description: \"The visual style of the file picker\",\n control: \"radio\",\n options: [\"area\", \"compact\"]\n },\n value: {\n description: \"The currently selected file\",\n control: \"object\"\n },\n validation: {\n description:\n \"Object containing validation state and message. Please refer to the example code for details on usage.\"\n },\n onSelectItem: {\n description: \"Function called when a file is selected\"\n },\n onEditItem: {\n description: \"Function called when a file is edited\"\n },\n onRemoveItem: {\n description: \"Function called when a file is removed\"\n }\n }\n};\n"],"names":["getRandomNumber","min","max","Math","getFile","width","height","fileSize","meta","FilePicker","args","selectedFile","setSelectedFile","useState","alert","Default","AreaType","AreaWithLabel","AreaWithLabelRequired","AreaWithDescription","AreaWithNotes","AreaWithErrors","AreaDisabled","AreaWithValidateFunction","validation","setValidation","undefined","validate","AreaFullExample","Compact","CompactWithLabel","CompactWithLabelRequired","CompactWithDescription","CompactWithNotes","CompactWithErrors","CompactDisabled","CompactWithValidateFunction","CompactFullExample","CompactWithLongFileNameInNarrowContainer","Documentation","useEffect","handleSelect","handleEdit","file","console","handleRemove"],"mappings":";;AAIA,MAAMA,kBAAkB,CAACC,KAAaC,MAClCC,KAAK,KAAK,CAACA,KAAK,MAAM,KAAMD,CAAAA,MAAMD,MAAM,MAAMA;AAElD,MAAMG,UAAU;IACZ,MAAMC,QAAQL,gBAAgB,KAAK;IACnC,MAAMM,SAASN,gBAAgB,KAAK;IACpC,MAAMO,WAAWP,gBAAgB,QAAQ;IAEzC,OAAO;QACH,MAAM;QACN,UAAU;QACV,MAAMO;QACN,KAAK,CAAC,sBAAsB,EAAEF,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AE,SAAS;gBAAO,SAAS;YAAuB;QAExE;QAGAe,UAAU;YACF9B,KAAK,QAAQ,IAAI,CAACC,eAClBc,cAAc;gBAAE,SAAS;gBAAO,SAAS;YAAuB,KAEhEA,cAAc;gBAAE,SAAS;gBAAM,SAAS;YAAG;QAEnD,GAAG;YAACf,KAAK,QAAQ;YAAEC;SAAa;QAEhC,OAAO,WAAP,GACI,oBAACF,YAAUA;YACN,GAAGC,IAAI;YACR,OAAOC;YACP,cAAc8B;YACd,cAAcI;YACd,YAAYH;YACZ,YAAYlB;;IAGxB;IACA,MAAM;QACF,OAAO;QACP,UAAU;QACV,UAAU;QACV,aAAa;QACb,MAAM;QACN,MAAM;QACN,OAAO;QACP,YAAYE;QACZ,cAAcA;QACd,YAAYA;QACZ,cAAcA;IAClB;IACA,UAAU;QACN,OAAO;YACH,aAAa;YACb,SAAS;QACb;QACA,UAAU;YACN,aAAa;YACb,SAAS;QACb;QACA,UAAU;YACN,aAAa;YACb,SAAS;QACb;QACA,aAAa;YACT,aAAa;YACb,SAAS;QACb;QACA,MAAM;YACF,aAAa;YACb,SAAS;QACb;QACA,MAAM;YACF,aAAa;YACb,SAAS;YACT,SAAS;gBAAC;gBAAQ;aAAU;QAChC;QACA,OAAO;YACH,aAAa;YACb,SAAS;QACb;QACA,YAAY;YACR,aACI;QACR;QACA,cAAc;YACV,aAAa;QACjB;QACA,YAAY;YACR,aAAa;QACjB;QACA,cAAc;YACV,aAAa;QACjB;IACJ;AACJ"}
|
|
@@ -63,7 +63,7 @@ interface FilePickerPrimitiveProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
63
63
|
*/
|
|
64
64
|
value?: FileItemDto | string | null;
|
|
65
65
|
}
|
|
66
|
-
declare const BaseFilePickerPrimitive: ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
|
|
66
|
+
declare const BaseFilePickerPrimitive: ({ id, className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
|
|
67
67
|
declare const FilePickerPrimitive: typeof BaseFilePickerPrimitive & {
|
|
68
68
|
original: typeof BaseFilePickerPrimitive;
|
|
69
69
|
originalName: string;
|
|
@@ -31,7 +31,7 @@ const filePickerVariants = cva([
|
|
|
31
31
|
variant: "primary"
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
const BaseFilePickerPrimitive = ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type = "area", value, variant })=>{
|
|
34
|
+
const BaseFilePickerPrimitive = ({ id, className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type = "area", value, variant })=>{
|
|
35
35
|
const { vm } = useFilePicker({
|
|
36
36
|
value
|
|
37
37
|
});
|
|
@@ -50,6 +50,7 @@ const BaseFilePickerPrimitive = ({ className, containerStyle, description, disab
|
|
|
50
50
|
}, label && /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
51
51
|
className: "mb-xs"
|
|
52
52
|
}, "string" == typeof label ? /*#__PURE__*/ __rspack_external_react.createElement(FilePickerLabel, {
|
|
53
|
+
htmlFor: id,
|
|
53
54
|
label: label,
|
|
54
55
|
className: "m-0",
|
|
55
56
|
disabled: disabled
|
|
@@ -66,6 +67,7 @@ const BaseFilePickerPrimitive = ({ className, containerStyle, description, disab
|
|
|
66
67
|
type: type,
|
|
67
68
|
value: vm.file
|
|
68
69
|
}) : /*#__PURE__*/ __rspack_external_react.createElement(Trigger, {
|
|
70
|
+
id: id,
|
|
69
71
|
disabled: disabled,
|
|
70
72
|
onSelectItem: onSelectItem,
|
|
71
73
|
renderTrigger: renderTrigger,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/primitives/FilePickerPrimitive.js","sources":["../../../src/FilePicker/primitives/FilePickerPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, type VariantProps, makeDecoratable, withStaticProps } from \"~/utils.js\";\nimport { FilePickerLabel, FilePickerDescription, Trigger } from \"./components/index.js\";\nimport type { Label } from \"~/Label/index.js\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { inputVariants } from \"~/Input/index.js\";\nimport { ImagePreview, RichItemPreview, TextOnlyPreview, FilePreview } from \"./components/index.js\";\nimport { FileItem, type FileItemDto, type FileItemFormatted } from \"../domains/index.js\";\nimport { useFilePicker } from \"./useFilePicker.js\";\nimport type { FilePreviewRendererProps, TriggerRendererProps } from \"./components/types.js\";\n\nconst filePickerVariants = cva(\n [\n \"w-full border-sm text-md peer rounded-md\",\n \"focus-visible:outline-none\",\n \"data-[disabled=true]:cursor-not-allowed\",\n \"flex flex-col items-start gap-y-sm-extra\"\n ],\n {\n variants: {\n type: {\n area: [\n \"px-[calc(var(--padding-sm-extra)-(var(--border-width-sm)))] py-[calc(var(--padding-sm-extra)-(var(--border-width-sm)))]\"\n ],\n compact: [\n \"py-[calc(var(--padding-xs-plus)-(var(--border-width-sm)))] px-[calc(var(--padding-sm)-(var(--border-width-sm)))]\"\n ]\n },\n variant: {\n primary: \"\",\n secondary: \"\",\n ghost: [\"hover:bg-transparent\"]\n }\n },\n defaultVariants: {\n type: \"area\",\n variant: \"primary\"\n }\n }\n);\n\ninterface FilePickerPrimitiveProps\n extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof filePickerVariants> {\n /**\n * Custom styles for the container.\n */\n containerStyle?: React.CSSProperties;\n /**\n * Indicates if the file picker is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Label for the file picker.\n */\n label?: React.ReactElement<typeof Label> | React.ReactNode | string;\n /**\n * Description for the file picker.\n */\n description?: React.ReactNode | string;\n /**\n * Callback triggered when an item is edited.\n */\n onEditItem?: (item: FileItemFormatted | null) => void;\n /**\n * Callback triggered when an item is removed.\n */\n onRemoveItem?: (item: FileItemFormatted | null) => void;\n /**\n * Callback triggered when an item is selected.\n */\n onSelectItem: () => void;\n /**\n * Placeholder text for the file picker.\n */\n placeholder?: string;\n /**\n * Custom renderer for the file preview.\n */\n renderFilePreview?: (props: FilePreviewRendererProps) => React.ReactElement<any>;\n /**\n * Custom renderer for the trigger.\n */\n renderTrigger?: (props: TriggerRendererProps) => React.ReactElement<any>;\n /**\n * Custom styles for the file picker.\n */\n style?: React.CSSProperties;\n /**\n * Value of the selected file.\n */\n value?: FileItemDto | string | null;\n}\n\nconst BaseFilePickerPrimitive = ({\n className,\n containerStyle,\n description,\n disabled,\n invalid,\n label,\n onEditItem,\n onRemoveItem,\n onSelectItem,\n placeholder,\n renderFilePreview,\n renderTrigger,\n type = \"area\",\n value,\n variant\n}: FilePickerPrimitiveProps) => {\n const { vm } = useFilePicker({ value });\n\n return (\n <div\n data-disabled={disabled}\n className={cn(\n inputVariants({ variant, invalid }),\n filePickerVariants({ type, variant }),\n className\n )}\n style={containerStyle}\n >\n {type === \"area\" && (label || description) && (\n <div className={\"w-full\"}>\n {label && (\n <div className={\"mb-xs\"}>\n {typeof label === \"string\" ? (\n <FilePickerLabel\n label={label}\n className={\"m-0\"}\n disabled={disabled}\n />\n ) : (\n label\n )}\n </div>\n )}\n {description && (\n <FilePickerDescription\n description={description}\n disabled={disabled}\n className={\"m-0\"}\n />\n )}\n </div>\n )}\n {vm.file ? (\n <FilePreview\n disabled={disabled}\n onEditItem={onEditItem ? () => onEditItem(vm.file) : undefined}\n onRemoveItem={onRemoveItem ? () => onRemoveItem(vm.file) : undefined}\n onReplaceItem={onSelectItem}\n renderFilePreview={renderFilePreview}\n type={type}\n value={vm.file}\n />\n ) : (\n <Trigger\n disabled={disabled}\n onSelectItem={onSelectItem}\n renderTrigger={renderTrigger}\n text={placeholder}\n type={type}\n variant={variant}\n />\n )}\n </div>\n );\n};\n\nconst DecoratableFilePickerPrimitive = makeDecoratable(\n \"FilePickerPrimitive\",\n BaseFilePickerPrimitive\n);\n\nconst FilePickerPrimitive = withStaticProps(DecoratableFilePickerPrimitive, {\n Preview: {\n Image: ImagePreview,\n RichItem: RichItemPreview,\n TextOnly: TextOnlyPreview\n }\n});\n\nexport { FilePickerPrimitive, FileItem, type FilePickerPrimitiveProps, filePickerVariants };\n"],"names":["filePickerVariants","cva","BaseFilePickerPrimitive","className","containerStyle","description","disabled","invalid","label","onEditItem","onRemoveItem","onSelectItem","placeholder","renderFilePreview","renderTrigger","type","value","variant","vm","useFilePicker","cn","inputVariants","FilePickerLabel","FilePickerDescription","FilePreview","undefined","Trigger","DecoratableFilePickerPrimitive","makeDecoratable","FilePickerPrimitive","withStaticProps","ImagePreview","RichItemPreview","TextOnlyPreview"],"mappings":";;;;;AAWA,MAAMA,qBAAqBC,IACvB;IACI;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,MAAM;YACF,MAAM;gBACF;aACH;YACD,SAAS;gBACL;aACH;QACL;QACA,SAAS;YACL,SAAS;YACT,WAAW;YACX,OAAO;gBAAC;aAAuB;QACnC;IACJ;IACA,iBAAiB;QACb,MAAM;QACN,SAAS;IACb;AACJ;AA4DJ,MAAMC,0BAA0B,CAAC,EAC7BC,SAAS,EACTC,cAAc,EACdC,WAAW,EACXC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,OAAO,MAAM,EACbC,KAAK,EACLC,OAAO,EACgB;IACvB,MAAM,EAAEC,EAAE,EAAE,GAAGC,cAAc;QAAEH;IAAM;IAErC,OAAO,WAAP,GACI,sCAAC;QACG,iBAAeV;QACf,WAAWc,GACPC,cAAc;YAAEJ;YAASV;QAAQ,
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/FilePickerPrimitive.js","sources":["../../../src/FilePicker/primitives/FilePickerPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, type VariantProps, makeDecoratable, withStaticProps } from \"~/utils.js\";\nimport { FilePickerLabel, FilePickerDescription, Trigger } from \"./components/index.js\";\nimport type { Label } from \"~/Label/index.js\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { inputVariants } from \"~/Input/index.js\";\nimport { ImagePreview, RichItemPreview, TextOnlyPreview, FilePreview } from \"./components/index.js\";\nimport { FileItem, type FileItemDto, type FileItemFormatted } from \"../domains/index.js\";\nimport { useFilePicker } from \"./useFilePicker.js\";\nimport type { FilePreviewRendererProps, TriggerRendererProps } from \"./components/types.js\";\n\nconst filePickerVariants = cva(\n [\n \"w-full border-sm text-md peer rounded-md\",\n \"focus-visible:outline-none\",\n \"data-[disabled=true]:cursor-not-allowed\",\n \"flex flex-col items-start gap-y-sm-extra\"\n ],\n {\n variants: {\n type: {\n area: [\n \"px-[calc(var(--padding-sm-extra)-(var(--border-width-sm)))] py-[calc(var(--padding-sm-extra)-(var(--border-width-sm)))]\"\n ],\n compact: [\n \"py-[calc(var(--padding-xs-plus)-(var(--border-width-sm)))] px-[calc(var(--padding-sm)-(var(--border-width-sm)))]\"\n ]\n },\n variant: {\n primary: \"\",\n secondary: \"\",\n ghost: [\"hover:bg-transparent\"]\n }\n },\n defaultVariants: {\n type: \"area\",\n variant: \"primary\"\n }\n }\n);\n\ninterface FilePickerPrimitiveProps\n extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof filePickerVariants> {\n /**\n * Custom styles for the container.\n */\n containerStyle?: React.CSSProperties;\n /**\n * Indicates if the file picker is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Label for the file picker.\n */\n label?: React.ReactElement<typeof Label> | React.ReactNode | string;\n /**\n * Description for the file picker.\n */\n description?: React.ReactNode | string;\n /**\n * Callback triggered when an item is edited.\n */\n onEditItem?: (item: FileItemFormatted | null) => void;\n /**\n * Callback triggered when an item is removed.\n */\n onRemoveItem?: (item: FileItemFormatted | null) => void;\n /**\n * Callback triggered when an item is selected.\n */\n onSelectItem: () => void;\n /**\n * Placeholder text for the file picker.\n */\n placeholder?: string;\n /**\n * Custom renderer for the file preview.\n */\n renderFilePreview?: (props: FilePreviewRendererProps) => React.ReactElement<any>;\n /**\n * Custom renderer for the trigger.\n */\n renderTrigger?: (props: TriggerRendererProps) => React.ReactElement<any>;\n /**\n * Custom styles for the file picker.\n */\n style?: React.CSSProperties;\n /**\n * Value of the selected file.\n */\n value?: FileItemDto | string | null;\n}\n\nconst BaseFilePickerPrimitive = ({\n id,\n className,\n containerStyle,\n description,\n disabled,\n invalid,\n label,\n onEditItem,\n onRemoveItem,\n onSelectItem,\n placeholder,\n renderFilePreview,\n renderTrigger,\n type = \"area\",\n value,\n variant\n}: FilePickerPrimitiveProps) => {\n const { vm } = useFilePicker({ value });\n\n return (\n <div\n data-disabled={disabled}\n className={cn(\n inputVariants({ variant, invalid }),\n filePickerVariants({ type, variant }),\n className\n )}\n style={containerStyle}\n >\n {type === \"area\" && (label || description) && (\n <div className={\"w-full\"}>\n {label && (\n <div className={\"mb-xs\"}>\n {typeof label === \"string\" ? (\n <FilePickerLabel\n htmlFor={id}\n label={label}\n className={\"m-0\"}\n disabled={disabled}\n />\n ) : (\n label\n )}\n </div>\n )}\n {description && (\n <FilePickerDescription\n description={description}\n disabled={disabled}\n className={\"m-0\"}\n />\n )}\n </div>\n )}\n {vm.file ? (\n <FilePreview\n disabled={disabled}\n onEditItem={onEditItem ? () => onEditItem(vm.file) : undefined}\n onRemoveItem={onRemoveItem ? () => onRemoveItem(vm.file) : undefined}\n onReplaceItem={onSelectItem}\n renderFilePreview={renderFilePreview}\n type={type}\n value={vm.file}\n />\n ) : (\n <Trigger\n id={id}\n disabled={disabled}\n onSelectItem={onSelectItem}\n renderTrigger={renderTrigger}\n text={placeholder}\n type={type}\n variant={variant}\n />\n )}\n </div>\n );\n};\n\nconst DecoratableFilePickerPrimitive = makeDecoratable(\n \"FilePickerPrimitive\",\n BaseFilePickerPrimitive\n);\n\nconst FilePickerPrimitive = withStaticProps(DecoratableFilePickerPrimitive, {\n Preview: {\n Image: ImagePreview,\n RichItem: RichItemPreview,\n TextOnly: TextOnlyPreview\n }\n});\n\nexport { FilePickerPrimitive, FileItem, type FilePickerPrimitiveProps, filePickerVariants };\n"],"names":["filePickerVariants","cva","BaseFilePickerPrimitive","id","className","containerStyle","description","disabled","invalid","label","onEditItem","onRemoveItem","onSelectItem","placeholder","renderFilePreview","renderTrigger","type","value","variant","vm","useFilePicker","cn","inputVariants","FilePickerLabel","FilePickerDescription","FilePreview","undefined","Trigger","DecoratableFilePickerPrimitive","makeDecoratable","FilePickerPrimitive","withStaticProps","ImagePreview","RichItemPreview","TextOnlyPreview"],"mappings":";;;;;AAWA,MAAMA,qBAAqBC,IACvB;IACI;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,MAAM;YACF,MAAM;gBACF;aACH;YACD,SAAS;gBACL;aACH;QACL;QACA,SAAS;YACL,SAAS;YACT,WAAW;YACX,OAAO;gBAAC;aAAuB;QACnC;IACJ;IACA,iBAAiB;QACb,MAAM;QACN,SAAS;IACb;AACJ;AA4DJ,MAAMC,0BAA0B,CAAC,EAC7BC,EAAE,EACFC,SAAS,EACTC,cAAc,EACdC,WAAW,EACXC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,OAAO,MAAM,EACbC,KAAK,EACLC,OAAO,EACgB;IACvB,MAAM,EAAEC,EAAE,EAAE,GAAGC,cAAc;QAAEH;IAAM;IAErC,OAAO,WAAP,GACI,sCAAC;QACG,iBAAeV;QACf,WAAWc,GACPC,cAAc;YAAEJ;YAASV;QAAQ,IACjCR,mBAAmB;YAAEgB;YAAME;QAAQ,IACnCd;QAEJ,OAAOC;OAENW,AAAS,WAATA,QAAoBP,CAAAA,SAASH,WAAU,mBACpC,sCAAC;QAAI,WAAW;OACXG,SAAS,WAATA,GACG,sCAAC;QAAI,WAAW;OACX,AAAiB,YAAjB,OAAOA,QAAqB,WAAX,GACd,sCAACc,iBAAeA;QACZ,SAASpB;QACT,OAAOM;QACP,WAAW;QACX,UAAUF;SAGdE,QAIXH,eAAe,WAAfA,GACG,sCAACkB,uBAAqBA;QAClB,aAAalB;QACb,UAAUC;QACV,WAAW;SAK1BY,GAAG,IAAI,GAAG,WAAH,GACJ,sCAACM,aAAWA;QACR,UAAUlB;QACV,YAAYG,aAAa,IAAMA,WAAWS,GAAG,IAAI,IAAIO;QACrD,cAAcf,eAAe,IAAMA,aAAaQ,GAAG,IAAI,IAAIO;QAC3D,eAAed;QACf,mBAAmBE;QACnB,MAAME;QACN,OAAOG,GAAG,IAAI;uBAGlB,sCAACQ,SAAOA;QACJ,IAAIxB;QACJ,UAAUI;QACV,cAAcK;QACd,eAAeG;QACf,MAAMF;QACN,MAAMG;QACN,SAASE;;AAK7B;AAEA,MAAMU,iCAAiCC,gBACnC,uBACA3B;AAGJ,MAAM4B,sBAAsBC,gBAAgBH,gCAAgC;IACxE,SAAS;QACL,OAAOI;QACP,UAAUC;QACV,UAAUC;IACd;AACJ"}
|
|
@@ -3,6 +3,8 @@ import { type FormComponentProps } from "../../../FormComponent/index.js";
|
|
|
3
3
|
type FilePickerLabelProps = Pick<FormComponentProps, "label" | "disabled" | "required" | "hint"> & {
|
|
4
4
|
invalid?: boolean;
|
|
5
5
|
className?: string;
|
|
6
|
+
/** The trigger's id — so the label names the button that picks a file. */
|
|
7
|
+
htmlFor?: string;
|
|
6
8
|
};
|
|
7
|
-
declare const FilePickerLabel: ({ label, hint, required, disabled, invalid, className }: FilePickerLabelProps) => React.JSX.Element | null;
|
|
9
|
+
declare const FilePickerLabel: ({ label, hint, required, disabled, invalid, className, htmlFor }: FilePickerLabelProps) => React.JSX.Element | null;
|
|
8
10
|
export { FilePickerLabel, type FilePickerLabelProps };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FormComponentLabel } from "../../../FormComponent/index.js";
|
|
2
2
|
import * as __rspack_external_react from "react";
|
|
3
|
-
const FilePickerLabel = ({ label, hint, required, disabled, invalid, className })=>{
|
|
3
|
+
const FilePickerLabel = ({ label, hint, required, disabled, invalid, className, htmlFor })=>{
|
|
4
4
|
if (!label) return null;
|
|
5
5
|
return /*#__PURE__*/ __rspack_external_react.createElement(FormComponentLabel, {
|
|
6
|
+
htmlFor: htmlFor,
|
|
6
7
|
text: label,
|
|
7
8
|
hint: hint,
|
|
8
9
|
required: required,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/primitives/components/Label.js","sources":["../../../../src/FilePicker/primitives/components/Label.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { FormComponentLabel, type FormComponentProps } from \"~/FormComponent/index.js\";\n\ntype FilePickerLabelProps = Pick<FormComponentProps, \"label\" | \"disabled\" | \"required\" | \"hint\"> & {\n invalid?: boolean;\n className?: string;\n};\n\nconst FilePickerLabel = ({\n label,\n hint,\n required,\n disabled,\n invalid,\n className\n}: FilePickerLabelProps) => {\n if (!label) {\n return null;\n }\n\n return (\n <FormComponentLabel\n text={label}\n hint={hint}\n required={required}\n disabled={disabled}\n className={className}\n invalid={invalid}\n />\n );\n};\n\nexport { FilePickerLabel, type FilePickerLabelProps };\n"],"names":["FilePickerLabel","label","hint","required","disabled","invalid","className","FormComponentLabel"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/Label.js","sources":["../../../../src/FilePicker/primitives/components/Label.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { FormComponentLabel, type FormComponentProps } from \"~/FormComponent/index.js\";\n\ntype FilePickerLabelProps = Pick<FormComponentProps, \"label\" | \"disabled\" | \"required\" | \"hint\"> & {\n invalid?: boolean;\n className?: string;\n /** The trigger's id — so the label names the button that picks a file. */\n htmlFor?: string;\n};\n\nconst FilePickerLabel = ({\n label,\n hint,\n required,\n disabled,\n invalid,\n className,\n htmlFor\n}: FilePickerLabelProps) => {\n if (!label) {\n return null;\n }\n\n return (\n <FormComponentLabel\n htmlFor={htmlFor}\n text={label}\n hint={hint}\n required={required}\n disabled={disabled}\n className={className}\n invalid={invalid}\n />\n );\n};\n\nexport { FilePickerLabel, type FilePickerLabelProps };\n"],"names":["FilePickerLabel","label","hint","required","disabled","invalid","className","htmlFor","FormComponentLabel"],"mappings":";;AAUA,MAAMA,kBAAkB,CAAC,EACrBC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,OAAO,EACY;IACnB,IAAI,CAACN,OACD,OAAO;IAGX,OAAO,WAAP,GACI,sCAACO,oBAAkBA;QACf,SAASD;QACT,MAAMN;QACN,MAAMC;QACN,UAAUC;QACV,UAAUC;QACV,WAAWE;QACX,SAASD;;AAGrB"}
|