@webiny/admin-ui 6.6.0-alpha.0 → 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/Accordion/components/AccordionContent.js +4 -1
- package/Accordion/components/AccordionContent.js.map +1 -1
- package/Accordion/components/AccordionItem.d.ts +1 -0
- package/Accordion/components/AccordionItem.js.map +1 -1
- package/Accordion/components/AccordionItemDragHandle.d.ts +2 -1
- package/Accordion/components/AccordionItemDragHandle.js +2 -1
- package/Accordion/components/AccordionItemDragHandle.js.map +1 -1
- package/Accordion/components/AccordionTrigger.js +4 -2
- package/Accordion/components/AccordionTrigger.js.map +1 -1
- 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/BetaBadge/BetaBadge.d.ts +6 -0
- package/BetaBadge/BetaBadge.js +7 -0
- package/BetaBadge/BetaBadge.js.map +1 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +54 -0
- package/Breadcrumbs/Breadcrumbs.js +66 -0
- package/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/Breadcrumbs/Breadcrumbs.stories.d.ts +9 -0
- package/Breadcrumbs/Breadcrumbs.stories.js +71 -0
- package/Breadcrumbs/Breadcrumbs.stories.js.map +1 -0
- package/Breadcrumbs/index.d.ts +1 -0
- package/Breadcrumbs/index.js +1 -0
- 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/Calendar/calendarClassNames.js +1 -1
- package/Calendar/calendarClassNames.js.map +1 -1
- 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/CodeEditor/CodeEditorPrimitive.js +3 -1
- package/CodeEditor/CodeEditorPrimitive.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 +42 -7
- package/DataTable/DataTable.js +122 -26
- 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/DataTable/components/ColumnsVisibility.d.ts +5 -4
- package/DataTable/components/ColumnsVisibility.js +7 -3
- package/DataTable/components/ColumnsVisibility.js.map +1 -1
- 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 +27 -18
- 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/DatePickerTrigger.js +1 -1
- package/DatePicker/primitives/components/DatePickerTrigger.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 +17 -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/DropdownMenu/components/DropdownMenuItem.d.ts +5 -0
- package/DropdownMenu/components/DropdownMenuItem.js +3 -2
- package/DropdownMenu/components/DropdownMenuItem.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.d.ts +12 -12
- 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 +13 -13
- 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/ImagePreview/ImagePreview.d.ts +13 -2
- package/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.js +15 -6
- package/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.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.d.ts +6 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js +54 -12
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.d.ts +11 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js +8 -61
- 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/ImageEditor/AspectRatioPreview.d.ts +16 -0
- package/ImageEditor/AspectRatioPreview.js +26 -0
- package/ImageEditor/AspectRatioPreview.js.map +1 -0
- package/ImageEditor/CropHotspotEditor.d.ts +22 -0
- package/ImageEditor/CropHotspotEditor.js +402 -0
- package/ImageEditor/CropHotspotEditor.js.map +1 -0
- package/ImageEditor/ImageEditor.d.ts +18 -0
- package/ImageEditor/ImageEditor.js +151 -0
- package/ImageEditor/ImageEditor.js.map +1 -0
- package/ImageEditor/ImageEditor.stories.d.ts +6 -0
- package/ImageEditor/ImageEditor.stories.js +42 -0
- package/ImageEditor/ImageEditor.stories.js.map +1 -0
- package/ImageEditor/MetaFields.d.ts +12 -0
- package/ImageEditor/MetaFields.js +20 -0
- package/ImageEditor/MetaFields.js.map +1 -0
- package/ImageEditor/SectionLabel.d.ts +8 -0
- package/ImageEditor/SectionLabel.js +7 -0
- package/ImageEditor/SectionLabel.js.map +1 -0
- package/ImageEditor/geometry.d.ts +46 -0
- package/ImageEditor/geometry.js +126 -0
- package/ImageEditor/geometry.js.map +1 -0
- package/ImageEditor/index.d.ts +3 -0
- package/ImageEditor/index.js +3 -0
- package/ImageEditor/types.d.ts +52 -0
- package/ImageEditor/types.js +35 -0
- package/ImageEditor/types.js.map +1 -0
- 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/Markdown/Markdown.d.ts +47 -0
- package/Markdown/Markdown.js +17 -0
- package/Markdown/Markdown.js.map +1 -0
- package/Markdown/index.d.ts +1 -0
- package/Markdown/index.js +1 -0
- 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/MultiFilePicker/MultiFilePicker.d.ts +12 -12
- package/MultiFilePicker/primitives/MultiFilePickerPrimitive.d.ts +12 -12
- 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/Toast/useToast.stories.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 +2 -0
- package/exports/admin/ui.js +2 -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 +7 -0
- package/index.js +7 -0
- package/package.json +31 -29
- package/theme.css +43 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
4
|
+
import { AdminUiContext } from "../AdminUiProvider/AdminUiProvider.js";
|
|
5
|
+
import { Select } from "../Select/index.js";
|
|
6
|
+
import { MultiSelect } from "../MultiSelect/index.js";
|
|
7
|
+
import { RadioGroup } from "../RadioGroup/index.js";
|
|
8
|
+
import { CheckboxGroup } from "../CheckboxGroup/index.js";
|
|
9
|
+
import { Slider } from "../Slider/index.js";
|
|
10
|
+
import { RangeSlider } from "../RangeSlider/index.js";
|
|
11
|
+
import { DatePicker } from "../DatePicker/index.js";
|
|
12
|
+
import { ToggleGroup } from "../ToggleGroup/index.js";
|
|
13
|
+
import { SegmentedControl } from "../SegmentedControl/index.js";
|
|
14
|
+
import { IconPicker } from "../IconPicker/index.js";
|
|
15
|
+
import { ColorPicker } from "../ColorPicker/index.js";
|
|
16
|
+
import { FilePicker } from "../FilePicker/index.js";
|
|
17
|
+
vi.mock("@webiny/icons/add.svg", ()=>({
|
|
18
|
+
ReactComponent: ()=>null
|
|
19
|
+
}));
|
|
20
|
+
vi.mock("@webiny/icons/calendar_month.svg", ()=>({
|
|
21
|
+
ReactComponent: ()=>null
|
|
22
|
+
}));
|
|
23
|
+
vi.mock("@webiny/icons/check.svg", ()=>({
|
|
24
|
+
ReactComponent: ()=>null
|
|
25
|
+
}));
|
|
26
|
+
vi.mock("@webiny/icons/chevron_left.svg", ()=>({
|
|
27
|
+
ReactComponent: ()=>null
|
|
28
|
+
}));
|
|
29
|
+
vi.mock("@webiny/icons/chevron_right.svg", ()=>({
|
|
30
|
+
ReactComponent: ()=>null
|
|
31
|
+
}));
|
|
32
|
+
vi.mock("@webiny/icons/close.svg", ()=>({
|
|
33
|
+
ReactComponent: ()=>null
|
|
34
|
+
}));
|
|
35
|
+
vi.mock("@webiny/icons/content_copy.svg", ()=>({
|
|
36
|
+
ReactComponent: ()=>null
|
|
37
|
+
}));
|
|
38
|
+
vi.mock("@webiny/icons/delete.svg", ()=>({
|
|
39
|
+
ReactComponent: ()=>null
|
|
40
|
+
}));
|
|
41
|
+
vi.mock("@webiny/icons/edit.svg", ()=>({
|
|
42
|
+
ReactComponent: ()=>null
|
|
43
|
+
}));
|
|
44
|
+
vi.mock("@webiny/icons/file_upload.svg", ()=>({
|
|
45
|
+
ReactComponent: ()=>null
|
|
46
|
+
}));
|
|
47
|
+
vi.mock("@webiny/icons/format_align_center.svg", ()=>({
|
|
48
|
+
ReactComponent: ()=>null
|
|
49
|
+
}));
|
|
50
|
+
vi.mock("@webiny/icons/format_align_left.svg", ()=>({
|
|
51
|
+
ReactComponent: ()=>null
|
|
52
|
+
}));
|
|
53
|
+
vi.mock("@webiny/icons/format_align_right.svg", ()=>({
|
|
54
|
+
ReactComponent: ()=>null
|
|
55
|
+
}));
|
|
56
|
+
vi.mock("@webiny/icons/format_bold.svg", ()=>({
|
|
57
|
+
ReactComponent: ()=>null
|
|
58
|
+
}));
|
|
59
|
+
vi.mock("@webiny/icons/format_italic.svg", ()=>({
|
|
60
|
+
ReactComponent: ()=>null
|
|
61
|
+
}));
|
|
62
|
+
vi.mock("@webiny/icons/format_underlined.svg", ()=>({
|
|
63
|
+
ReactComponent: ()=>null
|
|
64
|
+
}));
|
|
65
|
+
vi.mock("@webiny/icons/image.svg", ()=>({
|
|
66
|
+
ReactComponent: ()=>null
|
|
67
|
+
}));
|
|
68
|
+
vi.mock("@webiny/icons/info.svg", ()=>({
|
|
69
|
+
ReactComponent: ()=>null
|
|
70
|
+
}));
|
|
71
|
+
vi.mock("@webiny/icons/keyboard_arrow_down.svg", ()=>({
|
|
72
|
+
ReactComponent: ()=>null
|
|
73
|
+
}));
|
|
74
|
+
vi.mock("@webiny/icons/keyboard_arrow_up.svg", ()=>({
|
|
75
|
+
ReactComponent: ()=>null
|
|
76
|
+
}));
|
|
77
|
+
vi.mock("@webiny/icons/notifications.svg", ()=>({
|
|
78
|
+
ReactComponent: ()=>null
|
|
79
|
+
}));
|
|
80
|
+
vi.mock("@webiny/icons/person.svg", ()=>({
|
|
81
|
+
ReactComponent: ()=>null
|
|
82
|
+
}));
|
|
83
|
+
vi.mock("@webiny/icons/schedule.svg", ()=>({
|
|
84
|
+
ReactComponent: ()=>null
|
|
85
|
+
}));
|
|
86
|
+
vi.mock("@webiny/icons/search.svg", ()=>({
|
|
87
|
+
ReactComponent: ()=>null
|
|
88
|
+
}));
|
|
89
|
+
vi.mock("@webiny/icons/settings.svg", ()=>({
|
|
90
|
+
ReactComponent: ()=>null
|
|
91
|
+
}));
|
|
92
|
+
const context = {
|
|
93
|
+
compileMarkdown: (markdown)=>markdown
|
|
94
|
+
};
|
|
95
|
+
const renderIn = (ui)=>render(/*#__PURE__*/ react.createElement(AdminUiContext.Provider, {
|
|
96
|
+
value: context
|
|
97
|
+
}, ui));
|
|
98
|
+
beforeAll(()=>{
|
|
99
|
+
globalThis.ResizeObserver ??= class {
|
|
100
|
+
observe() {}
|
|
101
|
+
unobserve() {}
|
|
102
|
+
disconnect() {}
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
afterEach(cleanup);
|
|
106
|
+
const options = [
|
|
107
|
+
{
|
|
108
|
+
label: "Main layout",
|
|
109
|
+
value: "main"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: "Landing",
|
|
113
|
+
value: "landing"
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
describe("form component labels name their controls", ()=>{
|
|
117
|
+
it("Select — the combobox trigger, whatever value it shows", ()=>{
|
|
118
|
+
renderIn(/*#__PURE__*/ react.createElement(Select, {
|
|
119
|
+
label: "Layout",
|
|
120
|
+
value: "main",
|
|
121
|
+
options: options
|
|
122
|
+
}));
|
|
123
|
+
const control = screen.getByLabelText("Layout");
|
|
124
|
+
expect(control.getAttribute("role")).toBe("combobox");
|
|
125
|
+
expect(screen.getByRole("combobox", {
|
|
126
|
+
name: "Layout"
|
|
127
|
+
})).toBe(control);
|
|
128
|
+
});
|
|
129
|
+
it("Select — a caller's id is kept", ()=>{
|
|
130
|
+
renderIn(/*#__PURE__*/ react.createElement(Select, {
|
|
131
|
+
id: "layout-select",
|
|
132
|
+
label: "Layout",
|
|
133
|
+
options: options
|
|
134
|
+
}));
|
|
135
|
+
expect(screen.getByLabelText("Layout").id).toBe("layout-select");
|
|
136
|
+
});
|
|
137
|
+
it("MultiSelect — the trigger button", ()=>{
|
|
138
|
+
renderIn(/*#__PURE__*/ react.createElement(MultiSelect, {
|
|
139
|
+
label: "Languages",
|
|
140
|
+
options: options,
|
|
141
|
+
value: [
|
|
142
|
+
"main"
|
|
143
|
+
]
|
|
144
|
+
}));
|
|
145
|
+
expect(screen.getByLabelText("Languages").tagName).toBe("BUTTON");
|
|
146
|
+
});
|
|
147
|
+
it("RadioGroup — the radiogroup", ()=>{
|
|
148
|
+
renderIn(/*#__PURE__*/ react.createElement(RadioGroup, {
|
|
149
|
+
label: "Page type",
|
|
150
|
+
items: options,
|
|
151
|
+
value: "main"
|
|
152
|
+
}));
|
|
153
|
+
expect(screen.getByRole("radiogroup", {
|
|
154
|
+
name: "Page type"
|
|
155
|
+
})).toBeTruthy();
|
|
156
|
+
});
|
|
157
|
+
it("CheckboxGroup — the group", ()=>{
|
|
158
|
+
renderIn(/*#__PURE__*/ react.createElement(CheckboxGroup, {
|
|
159
|
+
label: "Channels",
|
|
160
|
+
items: options,
|
|
161
|
+
value: [
|
|
162
|
+
"main"
|
|
163
|
+
]
|
|
164
|
+
}));
|
|
165
|
+
expect(screen.getByRole("group", {
|
|
166
|
+
name: "Channels"
|
|
167
|
+
})).toBeTruthy();
|
|
168
|
+
});
|
|
169
|
+
it("Slider — the thumb, with the label on top or at the side", ()=>{
|
|
170
|
+
renderIn(/*#__PURE__*/ react.createElement(Slider, {
|
|
171
|
+
label: "Opacity",
|
|
172
|
+
value: 20,
|
|
173
|
+
min: 0,
|
|
174
|
+
max: 100,
|
|
175
|
+
onValueChange: ()=>{}
|
|
176
|
+
}));
|
|
177
|
+
expect(screen.getByRole("slider", {
|
|
178
|
+
name: /^Opacity/
|
|
179
|
+
})).toBeTruthy();
|
|
180
|
+
cleanup();
|
|
181
|
+
renderIn(/*#__PURE__*/ react.createElement(Slider, {
|
|
182
|
+
label: "Opacity",
|
|
183
|
+
labelPosition: "side",
|
|
184
|
+
value: 20,
|
|
185
|
+
onValueChange: ()=>{},
|
|
186
|
+
min: 0,
|
|
187
|
+
max: 100
|
|
188
|
+
}));
|
|
189
|
+
expect(screen.getByRole("slider", {
|
|
190
|
+
name: "Opacity"
|
|
191
|
+
})).toBeTruthy();
|
|
192
|
+
});
|
|
193
|
+
it("RangeSlider — both thumbs", ()=>{
|
|
194
|
+
renderIn(/*#__PURE__*/ react.createElement(RangeSlider, {
|
|
195
|
+
label: "Price",
|
|
196
|
+
values: [
|
|
197
|
+
10,
|
|
198
|
+
90
|
|
199
|
+
],
|
|
200
|
+
min: 0,
|
|
201
|
+
max: 100,
|
|
202
|
+
onValuesChange: ()=>{}
|
|
203
|
+
}));
|
|
204
|
+
expect(screen.getAllByRole("slider", {
|
|
205
|
+
name: "Price"
|
|
206
|
+
})).toHaveLength(2);
|
|
207
|
+
});
|
|
208
|
+
it("DatePicker — the trigger, for a date and for a time", ()=>{
|
|
209
|
+
renderIn(/*#__PURE__*/ react.createElement(DatePicker, {
|
|
210
|
+
label: "Publish on",
|
|
211
|
+
type: "date"
|
|
212
|
+
}));
|
|
213
|
+
expect(screen.getByRole("button", {
|
|
214
|
+
name: "Publish on"
|
|
215
|
+
})).toBeTruthy();
|
|
216
|
+
cleanup();
|
|
217
|
+
renderIn(/*#__PURE__*/ react.createElement(DatePicker, {
|
|
218
|
+
label: "Starts at",
|
|
219
|
+
type: "time"
|
|
220
|
+
}));
|
|
221
|
+
expect(screen.getByLabelText("Starts at").tagName).toBe("INPUT");
|
|
222
|
+
});
|
|
223
|
+
it("ToggleGroup and SegmentedControl — the group", ()=>{
|
|
224
|
+
renderIn(/*#__PURE__*/ react.createElement(ToggleGroup, {
|
|
225
|
+
label: "Format",
|
|
226
|
+
items: options,
|
|
227
|
+
type: "single",
|
|
228
|
+
value: "main"
|
|
229
|
+
}));
|
|
230
|
+
expect(screen.getByRole("radiogroup", {
|
|
231
|
+
name: "Format"
|
|
232
|
+
})).toBeTruthy();
|
|
233
|
+
cleanup();
|
|
234
|
+
renderIn(/*#__PURE__*/ react.createElement(ToggleGroup, {
|
|
235
|
+
label: "Styles",
|
|
236
|
+
items: options,
|
|
237
|
+
type: "multiple",
|
|
238
|
+
value: [
|
|
239
|
+
"main"
|
|
240
|
+
]
|
|
241
|
+
}));
|
|
242
|
+
expect(screen.getByLabelText("Styles").querySelectorAll("button")).toHaveLength(2);
|
|
243
|
+
cleanup();
|
|
244
|
+
renderIn(/*#__PURE__*/ react.createElement(SegmentedControl, {
|
|
245
|
+
label: "View",
|
|
246
|
+
items: options,
|
|
247
|
+
value: "main"
|
|
248
|
+
}));
|
|
249
|
+
expect(screen.getByRole("radiogroup", {
|
|
250
|
+
name: "View"
|
|
251
|
+
})).toBeTruthy();
|
|
252
|
+
});
|
|
253
|
+
it("IconPicker, ColorPicker and FilePicker — their triggers", ()=>{
|
|
254
|
+
renderIn(/*#__PURE__*/ react.createElement(IconPicker, {
|
|
255
|
+
label: "Icon",
|
|
256
|
+
icons: []
|
|
257
|
+
}));
|
|
258
|
+
expect(screen.getByLabelText("Icon").tagName).toBe("BUTTON");
|
|
259
|
+
cleanup();
|
|
260
|
+
renderIn(/*#__PURE__*/ react.createElement(ColorPicker, {
|
|
261
|
+
label: "Colour"
|
|
262
|
+
}));
|
|
263
|
+
expect(screen.getByRole("button", {
|
|
264
|
+
name: "Colour"
|
|
265
|
+
})).toBeTruthy();
|
|
266
|
+
cleanup();
|
|
267
|
+
renderIn(/*#__PURE__*/ react.createElement(FilePicker, {
|
|
268
|
+
label: "Image",
|
|
269
|
+
type: "compact",
|
|
270
|
+
onSelectItem: ()=>{}
|
|
271
|
+
}));
|
|
272
|
+
expect(screen.getByLabelText("Image").tagName).toBe("BUTTON");
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=labels.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormComponent/labels.test.js","sources":["../../src/FormComponent/labels.test.tsx"],"sourcesContent":["// @vitest-environment jsdom\n/**\n * A form component's visible label names its control: `getByLabelText` (and any\n * label-based lookup — assistive tech, a scripted UI check) finds the element\n * that takes focus, not a wrapper and not the value it currently shows.\n */\nimport React from \"react\";\nimport { afterEach, beforeAll, describe, expect, it, vi } from \"vitest\";\nimport { cleanup, render, screen } from \"@testing-library/react\";\nimport { AdminUiContext, type AdminUiContextValue } from \"~/AdminUiProvider/AdminUiProvider.js\";\nimport { Select } from \"~/Select/index.js\";\nimport { MultiSelect } from \"~/MultiSelect/index.js\";\nimport { RadioGroup } from \"~/RadioGroup/index.js\";\nimport { CheckboxGroup } from \"~/CheckboxGroup/index.js\";\nimport { Slider } from \"~/Slider/index.js\";\nimport { RangeSlider } from \"~/RangeSlider/index.js\";\nimport { DatePicker } from \"~/DatePicker/index.js\";\nimport { ToggleGroup } from \"~/ToggleGroup/index.js\";\nimport { SegmentedControl } from \"~/SegmentedControl/index.js\";\nimport { IconPicker } from \"~/IconPicker/index.js\";\nimport { ColorPicker } from \"~/ColorPicker/index.js\";\nimport { FilePicker } from \"~/FilePicker/index.js\";\n\n/* No SVG transform in the test runner: the icons these controls render become empty components. */\nvi.mock(\"@webiny/icons/add.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/calendar_month.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/check.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/chevron_left.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/chevron_right.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/close.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/content_copy.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/delete.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/edit.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/file_upload.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_align_center.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_align_left.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_align_right.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_bold.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_italic.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/format_underlined.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/image.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/info.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/keyboard_arrow_down.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/keyboard_arrow_up.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/notifications.svg\", () => ({\n ReactComponent: () => null\n}));\nvi.mock(\"@webiny/icons/person.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/schedule.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/search.svg\", () => ({ ReactComponent: () => null }));\nvi.mock(\"@webiny/icons/settings.svg\", () => ({ ReactComponent: () => null }));\n\nconst context = {\n compileMarkdown: (markdown: React.ReactNode) => markdown\n} as unknown as AdminUiContextValue;\n\nconst renderIn = (ui: React.ReactElement) =>\n render(<AdminUiContext.Provider value={context}>{ui}</AdminUiContext.Provider>);\n\nbeforeAll(() => {\n /* Radix measures its parts; jsdom has no ResizeObserver. */\n globalThis.ResizeObserver ??= class {\n observe() {}\n unobserve() {}\n disconnect() {}\n } as unknown as typeof ResizeObserver;\n});\n\nafterEach(cleanup);\n\nconst options = [\n { label: \"Main layout\", value: \"main\" },\n { label: \"Landing\", value: \"landing\" }\n];\n\ndescribe(\"form component labels name their controls\", () => {\n it(\"Select — the combobox trigger, whatever value it shows\", () => {\n renderIn(<Select label={\"Layout\"} value={\"main\"} options={options} />);\n const control = screen.getByLabelText(\"Layout\");\n expect(control.getAttribute(\"role\")).toBe(\"combobox\");\n expect(screen.getByRole(\"combobox\", { name: \"Layout\" })).toBe(control);\n });\n\n it(\"Select — a caller's id is kept\", () => {\n renderIn(<Select id={\"layout-select\"} label={\"Layout\"} options={options} />);\n expect(screen.getByLabelText(\"Layout\").id).toBe(\"layout-select\");\n });\n\n it(\"MultiSelect — the trigger button\", () => {\n renderIn(<MultiSelect label={\"Languages\"} options={options} value={[\"main\"]} />);\n expect(screen.getByLabelText(\"Languages\").tagName).toBe(\"BUTTON\");\n });\n\n it(\"RadioGroup — the radiogroup\", () => {\n renderIn(<RadioGroup label={\"Page type\"} items={options} value={\"main\"} />);\n expect(screen.getByRole(\"radiogroup\", { name: \"Page type\" })).toBeTruthy();\n });\n\n it(\"CheckboxGroup — the group\", () => {\n renderIn(<CheckboxGroup label={\"Channels\"} items={options} value={[\"main\"]} />);\n expect(screen.getByRole(\"group\", { name: \"Channels\" })).toBeTruthy();\n });\n\n it(\"Slider — the thumb, with the label on top or at the side\", () => {\n renderIn(\n <Slider label={\"Opacity\"} value={20} min={0} max={100} onValueChange={() => {}} />\n );\n /* On top, the label carries the current value too: `Opacity 20`. */\n expect(screen.getByRole(\"slider\", { name: /^Opacity/ })).toBeTruthy();\n cleanup();\n renderIn(\n <Slider\n label={\"Opacity\"}\n labelPosition={\"side\"}\n value={20}\n onValueChange={() => {}}\n min={0}\n max={100}\n />\n );\n expect(screen.getByRole(\"slider\", { name: \"Opacity\" })).toBeTruthy();\n });\n\n it(\"RangeSlider — both thumbs\", () => {\n renderIn(\n <RangeSlider\n label={\"Price\"}\n values={[10, 90]}\n min={0}\n max={100}\n onValuesChange={() => {}}\n />\n );\n expect(screen.getAllByRole(\"slider\", { name: \"Price\" })).toHaveLength(2);\n });\n\n it(\"DatePicker — the trigger, for a date and for a time\", () => {\n renderIn(<DatePicker label={\"Publish on\"} type={\"date\"} />);\n expect(screen.getByRole(\"button\", { name: \"Publish on\" })).toBeTruthy();\n cleanup();\n renderIn(<DatePicker label={\"Starts at\"} type={\"time\"} />);\n expect(screen.getByLabelText(\"Starts at\").tagName).toBe(\"INPUT\");\n });\n\n it(\"ToggleGroup and SegmentedControl — the group\", () => {\n /* Radix renders a single-choice toggle group as a radiogroup; a multiple one has no group role, but its root is still named. */\n renderIn(<ToggleGroup label={\"Format\"} items={options} type={\"single\"} value={\"main\"} />);\n expect(screen.getByRole(\"radiogroup\", { name: \"Format\" })).toBeTruthy();\n cleanup();\n renderIn(\n <ToggleGroup label={\"Styles\"} items={options} type={\"multiple\"} value={[\"main\"]} />\n );\n expect(screen.getByLabelText(\"Styles\").querySelectorAll(\"button\")).toHaveLength(2);\n cleanup();\n renderIn(<SegmentedControl label={\"View\"} items={options} value={\"main\"} />);\n expect(screen.getByRole(\"radiogroup\", { name: \"View\" })).toBeTruthy();\n });\n\n it(\"IconPicker, ColorPicker and FilePicker — their triggers\", () => {\n renderIn(<IconPicker label={\"Icon\"} icons={[]} />);\n expect(screen.getByLabelText(\"Icon\").tagName).toBe(\"BUTTON\");\n cleanup();\n renderIn(<ColorPicker label={\"Colour\"} />);\n expect(screen.getByRole(\"button\", { name: \"Colour\" })).toBeTruthy();\n cleanup();\n renderIn(<FilePicker label={\"Image\"} type={\"compact\"} onSelectItem={() => {}} />);\n expect(screen.getByLabelText(\"Image\").tagName).toBe(\"BUTTON\");\n });\n});\n"],"names":["vi","context","markdown","renderIn","ui","render","AdminUiContext","beforeAll","globalThis","afterEach","cleanup","options","describe","it","Select","control","screen","expect","MultiSelect","RadioGroup","CheckboxGroup","Slider","RangeSlider","DatePicker","ToggleGroup","SegmentedControl","IconPicker","ColorPicker","FilePicker"],"mappings":"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"}
|
package/Icon/Icon.d.ts
CHANGED
|
@@ -28,4 +28,9 @@ declare const Icon: typeof IconBase & {
|
|
|
28
28
|
displayName: string;
|
|
29
29
|
}>) => (props: unknown) => React.JSX.Element;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* An icon element whose size a parent can set through `React.cloneElement`. React 19 types an
|
|
33
|
+
* element's props as `unknown` unless they are given, so components that resize an icon take this.
|
|
34
|
+
*/
|
|
35
|
+
type IconElement = React.ReactElement<Partial<IconProps>>;
|
|
36
|
+
export { Icon, type IconProps, type IconElement };
|
package/Icon/Icon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon/Icon.js","sources":["../../src/Icon/Icon.tsx"],"sourcesContent":["import React from \"react\";\nimport { AccessibleIcon } from \"radix-ui\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\n\nconst iconVariants = cva(\"shrink-0\", {\n variants: {\n size: {\n xs: \"size-sm-extra\",\n sm: \"size-md\",\n md: \"size-md-plus\",\n lg: \"size-lg\"\n },\n color: {\n inherit: \"fill-inherit text-inherit\",\n accent: \"fill-accent-default text-accent-default\",\n \"neutral-light\": \"fill-neutral-strong text-neutral-strong\",\n \"neutral-strong\": \"fill-neutral-xstrong text-neutral-xstrong\",\n \"neutral-strong-transparent\": \"fill-neutral-xstrong/30 text-neutral-xstrong/30\",\n \"neutral-base\": \"fill-neutral-base text-neutral-base\",\n \"neutral-negative\": \"fill-neutral-base/50 text-neutral-base/50\"\n }\n },\n defaultVariants: {\n size: \"md\",\n color: \"inherit\"\n }\n});\n\ninterface IconProps\n extends\n Omit<React.HTMLAttributes<HTMLOrSVGElement>, \"color\">,\n VariantProps<typeof iconVariants> {\n label: string;\n icon: React.ReactNode;\n}\n\nconst IconBase = (props: IconProps) => {\n const { label, icon, color, size, className, ...rest } = props;\n return (\n <AccessibleIcon.Root label={label}>\n {/* @ts-expect-error */}\n {React.cloneElement(icon, {\n ...rest,\n className: cn(iconVariants({ color, size }), className)\n })}\n </AccessibleIcon.Root>\n );\n};\n\nconst Icon = makeDecoratable(\"Icon\", IconBase);\n\nexport { Icon, type IconProps };\n"],"names":["iconVariants","cva","IconBase","props","label","icon","color","size","className","rest","AccessibleIcon","React","cn","Icon","makeDecoratable"],"mappings":";;;AAIA,MAAMA,eAAeC,IAAI,YAAY;IACjC,UAAU;QACN,MAAM;YACF,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;QACR;QACA,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,kBAAkB;YAClB,8BAA8B;YAC9B,gBAAgB;YAChB,oBAAoB;QACxB;IACJ;IACA,iBAAiB;QACb,MAAM;QACN,OAAO;IACX;AACJ;AAUA,MAAMC,WAAW,CAACC;IACd,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGC,MAAM,GAAGN;IACzD,OAAO,WAAP,GACI,oBAACO,eAAe,IAAI;QAAC,OAAON;qBAEvBO,MAAAA,YAAkB,CAACN,MAAM;QACtB,GAAGI,IAAI;QACP,WAAWG,GAAGZ,aAAa;YAAEM;YAAOC;QAAK,IAAIC;IACjD;AAGZ;AAEA,MAAMK,OAAOC,gBAAgB,QAAQZ"}
|
|
1
|
+
{"version":3,"file":"Icon/Icon.js","sources":["../../src/Icon/Icon.tsx"],"sourcesContent":["import React from \"react\";\nimport { AccessibleIcon } from \"radix-ui\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\n\nconst iconVariants = cva(\"shrink-0\", {\n variants: {\n size: {\n xs: \"size-sm-extra\",\n sm: \"size-md\",\n md: \"size-md-plus\",\n lg: \"size-lg\"\n },\n color: {\n inherit: \"fill-inherit text-inherit\",\n accent: \"fill-accent-default text-accent-default\",\n \"neutral-light\": \"fill-neutral-strong text-neutral-strong\",\n \"neutral-strong\": \"fill-neutral-xstrong text-neutral-xstrong\",\n \"neutral-strong-transparent\": \"fill-neutral-xstrong/30 text-neutral-xstrong/30\",\n \"neutral-base\": \"fill-neutral-base text-neutral-base\",\n \"neutral-negative\": \"fill-neutral-base/50 text-neutral-base/50\"\n }\n },\n defaultVariants: {\n size: \"md\",\n color: \"inherit\"\n }\n});\n\ninterface IconProps\n extends\n Omit<React.HTMLAttributes<HTMLOrSVGElement>, \"color\">,\n VariantProps<typeof iconVariants> {\n label: string;\n icon: React.ReactNode;\n}\n\nconst IconBase = (props: IconProps) => {\n const { label, icon, color, size, className, ...rest } = props;\n return (\n <AccessibleIcon.Root label={label}>\n {/* @ts-expect-error */}\n {React.cloneElement(icon, {\n ...rest,\n className: cn(iconVariants({ color, size }), className)\n })}\n </AccessibleIcon.Root>\n );\n};\n\nconst Icon = makeDecoratable(\"Icon\", IconBase);\n\n/**\n * An icon element whose size a parent can set through `React.cloneElement`. React 19 types an\n * element's props as `unknown` unless they are given, so components that resize an icon take this.\n */\ntype IconElement = React.ReactElement<Partial<IconProps>>;\n\nexport { Icon, type IconProps, type IconElement };\n"],"names":["iconVariants","cva","IconBase","props","label","icon","color","size","className","rest","AccessibleIcon","React","cn","Icon","makeDecoratable"],"mappings":";;;AAIA,MAAMA,eAAeC,IAAI,YAAY;IACjC,UAAU;QACN,MAAM;YACF,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;QACR;QACA,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,kBAAkB;YAClB,8BAA8B;YAC9B,gBAAgB;YAChB,oBAAoB;QACxB;IACJ;IACA,iBAAiB;QACb,MAAM;QACN,OAAO;IACX;AACJ;AAUA,MAAMC,WAAW,CAACC;IACd,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGC,MAAM,GAAGN;IACzD,OAAO,WAAP,GACI,oBAACO,eAAe,IAAI;QAAC,OAAON;qBAEvBO,MAAAA,YAAkB,CAACN,MAAM;QACtB,GAAGI,IAAI;QACP,WAAWG,GAAGZ,aAAa;YAAEM;YAAOC;QAAK,IAAIC;IACjD;AAGZ;AAEA,MAAMK,OAAOC,gBAAgB,QAAQZ"}
|
package/IconPicker/IconPicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import react, { useMemo } from "react";
|
|
2
|
-
import { makeDecoratable } from "../utils.js";
|
|
2
|
+
import { generateId, makeDecoratable } from "../utils.js";
|
|
3
3
|
import { IconPickerPrimitive } from "./primitives/index.js";
|
|
4
4
|
import { FormComponentDescription, FormComponentErrorMessage, FormComponentLabel, FormComponentNote } from "../FormComponent/index.js";
|
|
5
5
|
const DecoratableIconPicker = ({ label, description, note, hint, required, disabled, validation, ...props })=>{
|
|
@@ -7,9 +7,13 @@ const DecoratableIconPicker = ({ label, description, note, hint, required, disab
|
|
|
7
7
|
const invalid = useMemo(()=>false === validationIsValid, [
|
|
8
8
|
validationIsValid
|
|
9
9
|
]);
|
|
10
|
+
const id = useMemo(()=>generateId(props.id), [
|
|
11
|
+
props.id
|
|
12
|
+
]);
|
|
10
13
|
return /*#__PURE__*/ react.createElement("div", {
|
|
11
14
|
className: "w-full"
|
|
12
15
|
}, /*#__PURE__*/ react.createElement(FormComponentLabel, {
|
|
16
|
+
htmlFor: id,
|
|
13
17
|
text: label,
|
|
14
18
|
hint: hint,
|
|
15
19
|
required: required,
|
|
@@ -19,6 +23,7 @@ const DecoratableIconPicker = ({ label, description, note, hint, required, disab
|
|
|
19
23
|
text: description,
|
|
20
24
|
disabled: disabled
|
|
21
25
|
}), /*#__PURE__*/ react.createElement(IconPickerPrimitive, {
|
|
26
|
+
id: id,
|
|
22
27
|
...props,
|
|
23
28
|
disabled: disabled,
|
|
24
29
|
invalid: invalid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPicker/IconPicker.js","sources":["../../src/IconPicker/IconPicker.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport type { IconPickerPrimitiveProps } from \"./primitives/index.js\";\nimport { IconPickerPrimitive } from \"./primitives/index.js\";\nimport type { FormComponentProps } from \"~/FormComponent/index.js\";\nimport {\n FormComponentDescription,\n FormComponentErrorMessage,\n FormComponentLabel,\n FormComponentNote\n} from \"~/FormComponent/index.js\";\n\ntype IconPickerProps = IconPickerPrimitiveProps & FormComponentProps;\n\nconst DecoratableIconPicker = ({\n label,\n description,\n note,\n hint,\n required,\n disabled,\n validation,\n ...props\n}: IconPickerProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n\n return (\n <div className={\"w-full\"}>\n <FormComponentLabel\n text={label}\n hint={hint}\n required={required}\n disabled={disabled}\n invalid={invalid}\n />\n <FormComponentDescription text={description} disabled={disabled} />\n <IconPickerPrimitive {...props} disabled={disabled} invalid={invalid} />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={disabled}\n />\n <FormComponentNote text={note} disabled={disabled} />\n </div>\n );\n};\nconst IconPicker = makeDecoratable(\"IconPicker\", DecoratableIconPicker);\n\nexport { IconPicker, type IconPickerProps };\n"],"names":["DecoratableIconPicker","label","description","note","hint","required","disabled","validation","props","validationIsValid","validationMessage","invalid","useMemo","FormComponentLabel","FormComponentDescription","IconPickerPrimitive","FormComponentErrorMessage","FormComponentNote","IconPicker","makeDecoratable"],"mappings":";;;;AAcA,MAAMA,wBAAwB,CAAC,EAC3BC,KAAK,EACLC,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACV,GAAGC,OACW;IACd,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGH,cAAc,CAAC;IAClF,MAAMI,UAAUC,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,
|
|
1
|
+
{"version":3,"file":"IconPicker/IconPicker.js","sources":["../../src/IconPicker/IconPicker.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { makeDecoratable, generateId } from \"~/utils.js\";\nimport type { IconPickerPrimitiveProps } from \"./primitives/index.js\";\nimport { IconPickerPrimitive } from \"./primitives/index.js\";\nimport type { FormComponentProps } from \"~/FormComponent/index.js\";\nimport {\n FormComponentDescription,\n FormComponentErrorMessage,\n FormComponentLabel,\n FormComponentNote\n} from \"~/FormComponent/index.js\";\n\ntype IconPickerProps = IconPickerPrimitiveProps & FormComponentProps;\n\nconst DecoratableIconPicker = ({\n label,\n description,\n note,\n hint,\n required,\n disabled,\n validation,\n ...props\n}: IconPickerProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n /* The label names the control, so `getByLabelText` / `{ label }` find it. */\n const id = useMemo(() => generateId(props.id), [props.id]);\n\n return (\n <div className={\"w-full\"}>\n <FormComponentLabel\n htmlFor={id}\n text={label}\n hint={hint}\n required={required}\n disabled={disabled}\n invalid={invalid}\n />\n <FormComponentDescription text={description} disabled={disabled} />\n <IconPickerPrimitive id={id} {...props} disabled={disabled} invalid={invalid} />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={disabled}\n />\n <FormComponentNote text={note} disabled={disabled} />\n </div>\n );\n};\nconst IconPicker = makeDecoratable(\"IconPicker\", DecoratableIconPicker);\n\nexport { IconPicker, type IconPickerProps };\n"],"names":["DecoratableIconPicker","label","description","note","hint","required","disabled","validation","props","validationIsValid","validationMessage","invalid","useMemo","id","generateId","FormComponentLabel","FormComponentDescription","IconPickerPrimitive","FormComponentErrorMessage","FormComponentNote","IconPicker","makeDecoratable"],"mappings":";;;;AAcA,MAAMA,wBAAwB,CAAC,EAC3BC,KAAK,EACLC,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACV,GAAGC,OACW;IACd,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGH,cAAc,CAAC;IAClF,MAAMI,UAAUC,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,MAAMI,KAAKD,QAAQ,IAAME,WAAWN,MAAM,EAAE,GAAG;QAACA,MAAM,EAAE;KAAC;IAEzD,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACO,oBAAkBA;QACf,SAASF;QACT,MAAMZ;QACN,MAAMG;QACN,UAAUC;QACV,UAAUC;QACV,SAASK;sBAEb,oBAACK,0BAAwBA;QAAC,MAAMd;QAAa,UAAUI;sBACvD,oBAACW,qBAAmBA;QAAC,IAAIJ;QAAK,GAAGL,KAAK;QAAE,UAAUF;QAAU,SAASK;sBACrE,oBAACO,2BAAyBA;QACtB,MAAMR;QACN,SAASC;QACT,UAAUL;sBAEd,oBAACa,mBAAiBA;QAAC,MAAMhB;QAAM,UAAUG;;AAGrD;AACA,MAAMc,aAAaC,gBAAgB,cAAcrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPicker/domains/IconPickerIcon.js","sources":["../../../src/IconPicker/domains/IconPickerIcon.tsx"],"sourcesContent":["import type { IconPickerIconDto } from \"./IconPickerIconDto.js\";\n\nexport class IconPickerIcon {\n private readonly _prefix: string;\n private readonly _name: string;\n\n protected constructor(data: { prefix: string; name: string }) {\n this._prefix = data.prefix;\n this._name = data.name;\n }\n\n static create(data: IconPickerIconDto) {\n return new IconPickerIcon({\n prefix: data.prefix,\n name: data.name\n });\n }\n\n static createFromString(value?: string) {\n if (typeof value === \"string\" && value.includes(\"/\")) {\n const values = value.split(\"/\");\n return new IconPickerIcon({\n prefix: values[0],\n name: values[1]\n });\n } else {\n return new IconPickerIcon({\n prefix: \"fas\",\n name: \"star\"\n });\n }\n }\n\n get prefix() {\n return this._prefix;\n }\n\n get name() {\n return this._name;\n }\n}\n"],"names":["IconPickerIcon","data","value","values"],"mappings":"AAEO,MAAMA;IAIT,YAAsBC,IAAsC,CAAE;QAC1D,IAAI,CAAC,OAAO,GAAGA,KAAK,MAAM;QAC1B,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;IAC1B;IAEA,OAAO,OAAOA,IAAuB,EAAE;QACnC,OAAO,IAAID,eAAe;YACtB,QAAQC,KAAK,MAAM;YACnB,MAAMA,KAAK,IAAI;QACnB;IACJ;IAEA,OAAO,iBAAiBC,KAAc,EAAE;QACpC,KAAI,CAAiB,YAAjB,OAAOA,SAAsBA,MAAM,QAAQ,CAAC,IAAG,GAO/C,OAAO,IAAIF,eAAe;YACtB,QAAQ;YACR,MAAM;QACV;
|
|
1
|
+
{"version":3,"file":"IconPicker/domains/IconPickerIcon.js","sources":["../../../src/IconPicker/domains/IconPickerIcon.tsx"],"sourcesContent":["import type { IconPickerIconDto } from \"./IconPickerIconDto.js\";\n\nexport class IconPickerIcon {\n private readonly _prefix: string;\n private readonly _name: string;\n\n protected constructor(data: { prefix: string; name: string }) {\n this._prefix = data.prefix;\n this._name = data.name;\n }\n\n static create(data: IconPickerIconDto) {\n return new IconPickerIcon({\n prefix: data.prefix,\n name: data.name\n });\n }\n\n static createFromString(value?: string) {\n if (typeof value === \"string\" && value.includes(\"/\")) {\n const values = value.split(\"/\");\n return new IconPickerIcon({\n prefix: values[0],\n name: values[1]\n });\n } else {\n return new IconPickerIcon({\n prefix: \"fas\",\n name: \"star\"\n });\n }\n }\n\n get prefix() {\n return this._prefix;\n }\n\n get name() {\n return this._name;\n }\n}\n"],"names":["IconPickerIcon","data","value","values"],"mappings":"AAEO,MAAMA;IAIT,YAAsBC,IAAsC,CAAE;QAC1D,IAAI,CAAC,OAAO,GAAGA,KAAK,MAAM;QAC1B,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;IAC1B;IAEA,OAAO,OAAOA,IAAuB,EAAE;QACnC,OAAO,IAAID,eAAe;YACtB,QAAQC,KAAK,MAAM;YACnB,MAAMA,KAAK,IAAI;QACnB;IACJ;IAEA,OAAO,iBAAiBC,KAAc,EAAE;QACpC,KAAI,CAAiB,YAAjB,OAAOA,SAAsBA,MAAM,QAAQ,CAAC,IAAG,GAO/C,OAAO,IAAIF,eAAe;YACtB,QAAQ;YACR,MAAM;QACV;aAVkD;YAClD,MAAMG,SAASD,MAAM,KAAK,CAAC;YAC3B,OAAO,IAAIF,eAAe;gBACtB,QAAQG,MAAM,CAAC,EAAE;gBACjB,MAAMA,MAAM,CAAC,EAAE;YACnB;QACJ;IAMJ;IAEA,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK;IACrB;AACJ"}
|
|
@@ -7,6 +7,8 @@ declare const iconPickerVariants: (props?: ({
|
|
|
7
7
|
disabled?: boolean | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
interface IconPickerPrimitiveProps extends VariantProps<typeof iconPickerVariants> {
|
|
10
|
+
/** The trigger's id — what a `<label htmlFor>` points at. */
|
|
11
|
+
id?: string;
|
|
10
12
|
/**
|
|
11
13
|
* Indicates if the field is disabled.
|
|
12
14
|
*/
|
|
@@ -35,6 +35,7 @@ const IconPickerPrimitive = (props)=>{
|
|
|
35
35
|
}, /*#__PURE__*/ react.createElement(PopoverPrimitive.Trigger, {
|
|
36
36
|
asChild: true
|
|
37
37
|
}, /*#__PURE__*/ react.createElement("button", {
|
|
38
|
+
id: props.id,
|
|
38
39
|
"data-disabled": props.disabled,
|
|
39
40
|
className: cn(inputVariants({
|
|
40
41
|
size: props.size,
|
|
@@ -49,8 +50,7 @@ const IconPickerPrimitive = (props)=>{
|
|
|
49
50
|
size: props.size
|
|
50
51
|
}))), /*#__PURE__*/ react.createElement(PopoverPrimitive.Content, {
|
|
51
52
|
align: "start",
|
|
52
|
-
className: "min-w-96"
|
|
53
|
-
onWheel: (e)=>e.stopPropagation()
|
|
53
|
+
className: "min-w-96"
|
|
54
54
|
}, /*#__PURE__*/ react.createElement(IconPickerInput, {
|
|
55
55
|
value: vm.searchQuery,
|
|
56
56
|
onChange: searchIcon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPicker/primitives/IconPickerPrimitive.js","sources":["../../../src/IconPicker/primitives/IconPickerPrimitive.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { inputVariants } from \"~/Input/index.js\";\nimport { PopoverPrimitive } from \"~/Popover/index.js\";\nimport { cn, cva, type VariantProps } from \"~/utils.js\";\nimport { IconPickerGrid, IconPickerInput, IconPickerTrigger } from \"./components/index.js\";\nimport type { IconPickerIconDto } from \"../domains/index.js\";\nimport { useIconPicker } from \"./useIconPicker.js\";\n\nconst iconPickerVariants = cva(\"cursor-pointer text-neutral-strong\", {\n variants: {\n size: {\n md: \"w-16\",\n lg: \"w-16\",\n xl: \"w-20\"\n },\n disabled: {\n true: \"pointer-events-none\"\n }\n },\n defaultVariants: {\n size: \"lg\"\n }\n});\n\ninterface IconPickerPrimitiveProps extends VariantProps<typeof iconPickerVariants> {\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Callback triggered when the value changes.\n */\n onChange?: (value: string) => void;\n /**\n * List of icons to be displayed in the icon picker.\n */\n icons: IconPickerIconDto[];\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Optional selected icon.\n */\n value?: string;\n /**\n * Variant of the input field.\n * Refer to `InputPrimitiveProps[\"variant\"]` for possible values.\n */\n variant?: InputPrimitiveProps[\"variant\"];\n}\n\nconst IconPickerPrimitive = (props: IconPickerPrimitiveProps) => {\n const { vm, setListOpenState, searchIcon, setSelectedIcon } = useIconPicker(props);\n // TODO figure out a better way to type this ref, without using `as unknown as`\n const inputRef = useRef<HTMLInputElement>(null as unknown as HTMLInputElement);\n\n useEffect(() => {\n setTimeout(() => {\n if (vm.open && inputRef.current) {\n inputRef.current.focus();\n }\n }, 50);\n }, [vm.open]);\n\n return (\n <PopoverPrimitive open={vm.open} onOpenChange={setListOpenState}>\n <PopoverPrimitive.Trigger asChild>\n <button\n data-disabled={props.disabled}\n className={cn(\n inputVariants({\n size: props.size,\n variant: props.variant,\n invalid: props.invalid\n }),\n iconPickerVariants({ size: props.size, disabled: props.disabled })\n )}\n >\n <IconPickerTrigger value={props.value} size={props.size} />\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content
|
|
1
|
+
{"version":3,"file":"IconPicker/primitives/IconPickerPrimitive.js","sources":["../../../src/IconPicker/primitives/IconPickerPrimitive.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { inputVariants } from \"~/Input/index.js\";\nimport { PopoverPrimitive } from \"~/Popover/index.js\";\nimport { cn, cva, type VariantProps } from \"~/utils.js\";\nimport { IconPickerGrid, IconPickerInput, IconPickerTrigger } from \"./components/index.js\";\nimport type { IconPickerIconDto } from \"../domains/index.js\";\nimport { useIconPicker } from \"./useIconPicker.js\";\n\nconst iconPickerVariants = cva(\"cursor-pointer text-neutral-strong\", {\n variants: {\n size: {\n md: \"w-16\",\n lg: \"w-16\",\n xl: \"w-20\"\n },\n disabled: {\n true: \"pointer-events-none\"\n }\n },\n defaultVariants: {\n size: \"lg\"\n }\n});\n\ninterface IconPickerPrimitiveProps extends VariantProps<typeof iconPickerVariants> {\n /** The trigger's id — what a `<label htmlFor>` points at. */\n id?: string;\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Callback triggered when the value changes.\n */\n onChange?: (value: string) => void;\n /**\n * List of icons to be displayed in the icon picker.\n */\n icons: IconPickerIconDto[];\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Optional selected icon.\n */\n value?: string;\n /**\n * Variant of the input field.\n * Refer to `InputPrimitiveProps[\"variant\"]` for possible values.\n */\n variant?: InputPrimitiveProps[\"variant\"];\n}\n\nconst IconPickerPrimitive = (props: IconPickerPrimitiveProps) => {\n const { vm, setListOpenState, searchIcon, setSelectedIcon } = useIconPicker(props);\n // TODO figure out a better way to type this ref, without using `as unknown as`\n const inputRef = useRef<HTMLInputElement>(null as unknown as HTMLInputElement);\n\n useEffect(() => {\n setTimeout(() => {\n if (vm.open && inputRef.current) {\n inputRef.current.focus();\n }\n }, 50);\n }, [vm.open]);\n\n return (\n <PopoverPrimitive open={vm.open} onOpenChange={setListOpenState}>\n <PopoverPrimitive.Trigger asChild>\n <button\n id={props.id}\n data-disabled={props.disabled}\n className={cn(\n inputVariants({\n size: props.size,\n variant: props.variant,\n invalid: props.invalid\n }),\n iconPickerVariants({ size: props.size, disabled: props.disabled })\n )}\n >\n <IconPickerTrigger value={props.value} size={props.size} />\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content align={\"start\"} className={\"min-w-96\"}>\n <IconPickerInput value={vm.searchQuery} onChange={searchIcon} inputRef={inputRef} />\n <IconPickerGrid\n icons={vm.icons}\n iconsLength={vm.iconsLength}\n onIconSelect={setSelectedIcon}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive>\n );\n};\n\nexport { IconPickerPrimitive, type IconPickerPrimitiveProps };\n"],"names":["iconPickerVariants","cva","IconPickerPrimitive","props","vm","setListOpenState","searchIcon","setSelectedIcon","useIconPicker","inputRef","useRef","useEffect","setTimeout","PopoverPrimitive","cn","inputVariants","IconPickerTrigger","IconPickerInput","IconPickerGrid"],"mappings":";;;;;;AASA,MAAMA,qBAAqBC,IAAI,sCAAsC;IACjE,UAAU;QACN,MAAM;YACF,IAAI;YACJ,IAAI;YACJ,IAAI;QACR;QACA,UAAU;YACN,MAAM;QACV;IACJ;IACA,iBAAiB;QACb,MAAM;IACV;AACJ;AAiCA,MAAMC,sBAAsB,CAACC;IACzB,MAAM,EAAEC,EAAE,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,eAAe,EAAE,GAAGC,cAAcL;IAE5E,MAAMM,WAAWC,OAAyB;IAE1CC,UAAU;QACNC,WAAW;YACP,IAAIR,GAAG,IAAI,IAAIK,SAAS,OAAO,EAC3BA,SAAS,OAAO,CAAC,KAAK;QAE9B,GAAG;IACP,GAAG;QAACL,GAAG,IAAI;KAAC;IAEZ,OAAO,WAAP,GACI,oBAACS,kBAAgBA;QAAC,MAAMT,GAAG,IAAI;QAAE,cAAcC;qBAC3C,oBAACQ,iBAAiB,OAAO;QAAC;qBACtB,oBAAC;QACG,IAAIV,MAAM,EAAE;QACZ,iBAAeA,MAAM,QAAQ;QAC7B,WAAWW,GACPC,cAAc;YACV,MAAMZ,MAAM,IAAI;YAChB,SAASA,MAAM,OAAO;YACtB,SAASA,MAAM,OAAO;QAC1B,IACAH,mBAAmB;YAAE,MAAMG,MAAM,IAAI;YAAE,UAAUA,MAAM,QAAQ;QAAC;qBAGpE,oBAACa,mBAAiBA;QAAC,OAAOb,MAAM,KAAK;QAAE,MAAMA,MAAM,IAAI;wBAG/D,oBAACU,iBAAiB,OAAO;QAAC,OAAO;QAAS,WAAW;qBACjD,oBAACI,iBAAeA;QAAC,OAAOb,GAAG,WAAW;QAAE,UAAUE;QAAY,UAAUG;sBACxE,oBAACS,gBAAcA;QACX,OAAOd,GAAG,KAAK;QACf,aAAaA,GAAG,WAAW;QAC3B,cAAcG;;AAKlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPicker/primitives/components/IconPickerGrid.js","sources":["../../../../src/IconPicker/primitives/components/IconPickerGrid.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"IconPicker/primitives/components/IconPickerGrid.js","sources":["../../../../src/IconPicker/primitives/components/IconPickerGrid.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type { CellRendererParams } from \"react-virtualized\";\nimport { Grid } from \"react-virtualized\";\nimport { Text } from \"~/Text/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { IconPickerFontAwesome } from \"../../domains/index.js\";\nimport { IconPickerIconFormatter } from \"../../domains/index.js\";\nimport { IconPickerIcon } from \"./IconPickerIcon.js\";\n\nconst COLUMN_COUNT = 5;\nconst GRID_WIDTH = 424;\nconst GRID_HEIGHT = 270;\nconst COLUMN_WIDTH = 80;\nconst ROW_HEIGHT = 80;\n\ninterface IconPickerGridProps {\n icons: IconPickerFontAwesome[];\n iconsLength: number;\n onIconSelect: (value: string) => void;\n}\n\nconst IconPickerGrid = (props: IconPickerGridProps) => {\n const renderCell = useCallback(() => {\n return function renderCell({\n columnIndex,\n key,\n rowIndex,\n style\n }: CellRendererParams): React.ReactElement | null {\n const item = props.icons[rowIndex * COLUMN_COUNT + columnIndex];\n if (!item) {\n return null;\n }\n\n return (\n <div\n key={key}\n style={style}\n className={cn([\n \"flex flex-col justify-center items-center gap-sm\",\n \"text-neutral-strong\",\n \"hover:bg-neutral-dimmed hover:text-neutral-strong\",\n \"px-xs-plus box-border rounded-xs cursor-pointer overflow-hidden\",\n \"transition-colors duration-400 ease-out\"\n ])}\n onClick={() => {\n if (props.onIconSelect) {\n props.onIconSelect(IconPickerIconFormatter.formatStringValue(item));\n }\n }}\n >\n <IconPickerIcon name={item.name} prefix={item.prefix} className={\"size-lg\"} />\n <Text\n as={\"div\"}\n size={\"sm\"}\n className={\"w-full truncate text-center text-neutral-muted\"}\n >\n {item.name}\n </Text>\n </div>\n );\n };\n }, [props.icons]);\n\n return (\n <div>\n {props.iconsLength === 0 ? (\n <div className={`px-sm-extra py-md text-neutral-strong`}>\n <Text>{\"No results found.\"}</Text>\n </div>\n ) : (\n <Grid\n className={\"px-sm-extra py-xs-plus outline-none\"}\n cellRenderer={renderCell()}\n columnCount={COLUMN_COUNT}\n columnWidth={COLUMN_WIDTH}\n rowHeight={ROW_HEIGHT}\n width={GRID_WIDTH}\n height={GRID_HEIGHT}\n rowCount={Math.ceil(props.iconsLength / COLUMN_COUNT)}\n />\n )}\n </div>\n );\n};\n\nexport { IconPickerGrid, type IconPickerGridProps };\n"],"names":["COLUMN_COUNT","GRID_WIDTH","GRID_HEIGHT","COLUMN_WIDTH","ROW_HEIGHT","IconPickerGrid","props","renderCell","useCallback","columnIndex","key","rowIndex","style","item","cn","IconPickerIconFormatter","IconPickerIcon","Text","Grid","Math"],"mappings":";;;;;;AASA,MAAMA,eAAe;AACrB,MAAMC,aAAa;AACnB,MAAMC,cAAc;AACpB,MAAMC,eAAe;AACrB,MAAMC,aAAa;AAQnB,MAAMC,iBAAiB,CAACC;IACpB,MAAMC,aAAaC,YAAY,IACpB,SAAoB,EACvBC,WAAW,EACXC,GAAG,EACHC,QAAQ,EACRC,KAAK,EACY;YACjB,MAAMC,OAAOP,MAAM,KAAK,CAACK,WAAWX,eAAeS,YAAY;YAC/D,IAAI,CAACI,MACD,OAAO;YAGX,OAAO,WAAP,GACI,oBAAC;gBACG,KAAKH;gBACL,OAAOE;gBACP,WAAWE,GAAG;oBACV;oBACA;oBACA;oBACA;oBACA;iBACH;gBACD,SAAS;oBACL,IAAIR,MAAM,YAAY,EAClBA,MAAM,YAAY,CAACS,wBAAwB,iBAAiB,CAACF;gBAErE;6BAEA,oBAACG,gBAAcA;gBAAC,MAAMH,KAAK,IAAI;gBAAE,QAAQA,KAAK,MAAM;gBAAE,WAAW;8BACjE,oBAACI,MAAIA;gBACD,IAAI;gBACJ,MAAM;gBACN,WAAW;eAEVJ,KAAK,IAAI;QAI1B,GACD;QAACP,MAAM,KAAK;KAAC;IAEhB,OAAO,WAAP,GACI,oBAAC,aACIA,AAAsB,MAAtBA,MAAM,WAAW,GAAS,WAAJ,GACnB,oBAAC;QAAI,WAAW;qBACZ,oBAACW,MAAIA,MAAE,sCAGX,oBAACC,MAAIA;QACD,WAAW;QACX,cAAcX;QACd,aAAaP;QACb,aAAaG;QACb,WAAWC;QACX,OAAOH;QACP,QAAQC;QACR,UAAUiB,KAAK,IAAI,CAACb,MAAM,WAAW,GAAGN;;AAK5D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ImageEditorAspectRatio, ImageEditorCrop, ImageEditorHotspot } from "./types.js";
|
|
3
|
+
interface AspectRatioPreviewProps {
|
|
4
|
+
src: string;
|
|
5
|
+
imageWidth: number;
|
|
6
|
+
imageHeight: number;
|
|
7
|
+
crop: ImageEditorCrop | undefined;
|
|
8
|
+
hotspot: ImageEditorHotspot | undefined;
|
|
9
|
+
aspectRatio: ImageEditorAspectRatio;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A single live preview showing how the current crop + hotspot renders at one
|
|
13
|
+
* target aspect ratio. Uses the shared preview geometry so it matches the site.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AspectRatioPreview: ({ src, imageWidth, imageHeight, crop, hotspot, aspectRatio }: AspectRatioPreviewProps) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { getPreviewStyles } from "./geometry.js";
|
|
3
|
+
const PREVIEW_HEIGHT = 120;
|
|
4
|
+
const AspectRatioPreview = ({ src, imageWidth, imageHeight, crop, hotspot, aspectRatio })=>{
|
|
5
|
+
const styles = getPreviewStyles(imageWidth, imageHeight, crop, hotspot, aspectRatio.ratio);
|
|
6
|
+
const width = Math.round(PREVIEW_HEIGHT * aspectRatio.ratio);
|
|
7
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
8
|
+
className: "flex flex-col items-center gap-xs"
|
|
9
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
10
|
+
className: "relative overflow-hidden rounded-sm border border-neutral-dimmed bg-neutral-light",
|
|
11
|
+
style: {
|
|
12
|
+
width: `${width}px`,
|
|
13
|
+
height: `${PREVIEW_HEIGHT}px`
|
|
14
|
+
}
|
|
15
|
+
}, /*#__PURE__*/ react.createElement("img", {
|
|
16
|
+
src: src,
|
|
17
|
+
alt: "",
|
|
18
|
+
style: styles.image,
|
|
19
|
+
draggable: false
|
|
20
|
+
})), /*#__PURE__*/ react.createElement("span", {
|
|
21
|
+
className: "text-sm text-neutral-strong"
|
|
22
|
+
}, aspectRatio.label));
|
|
23
|
+
};
|
|
24
|
+
export { AspectRatioPreview };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=AspectRatioPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageEditor/AspectRatioPreview.js","sources":["../../src/ImageEditor/AspectRatioPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { getPreviewStyles } from \"./geometry.js\";\nimport type { ImageEditorAspectRatio, ImageEditorCrop, ImageEditorHotspot } from \"./types.js\";\n\ninterface AspectRatioPreviewProps {\n src: string;\n imageWidth: number;\n imageHeight: number;\n crop: ImageEditorCrop | undefined;\n hotspot: ImageEditorHotspot | undefined;\n aspectRatio: ImageEditorAspectRatio;\n}\n\n// Fixed preview height (px). Each thumbnail keeps this height regardless of how\n// many are shown; the width is derived from the aspect ratio.\nconst PREVIEW_HEIGHT = 120;\n\n/**\n * A single live preview showing how the current crop + hotspot renders at one\n * target aspect ratio. Uses the shared preview geometry so it matches the site.\n */\nexport const AspectRatioPreview = ({\n src,\n imageWidth,\n imageHeight,\n crop,\n hotspot,\n aspectRatio\n}: AspectRatioPreviewProps) => {\n const styles = getPreviewStyles(imageWidth, imageHeight, crop, hotspot, aspectRatio.ratio);\n const width = Math.round(PREVIEW_HEIGHT * aspectRatio.ratio);\n\n return (\n <div className={\"flex flex-col items-center gap-xs\"}>\n <div\n className={\n \"relative overflow-hidden rounded-sm border border-neutral-dimmed bg-neutral-light\"\n }\n style={{ width: `${width}px`, height: `${PREVIEW_HEIGHT}px` }}\n >\n <img src={src} alt={\"\"} style={styles.image} draggable={false} />\n </div>\n <span className={\"text-sm text-neutral-strong\"}>{aspectRatio.label}</span>\n </div>\n );\n};\n"],"names":["PREVIEW_HEIGHT","AspectRatioPreview","src","imageWidth","imageHeight","crop","hotspot","aspectRatio","styles","getPreviewStyles","width","Math"],"mappings":";;AAeA,MAAMA,iBAAiB;AAMhB,MAAMC,qBAAqB,CAAC,EAC/BC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,OAAO,EACPC,WAAW,EACW;IACtB,MAAMC,SAASC,iBAAiBN,YAAYC,aAAaC,MAAMC,SAASC,YAAY,KAAK;IACzF,MAAMG,QAAQC,KAAK,KAAK,CAACX,iBAAiBO,YAAY,KAAK;IAE3D,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QACG,WACI;QAEJ,OAAO;YAAE,OAAO,GAAGG,MAAM,EAAE,CAAC;YAAE,QAAQ,GAAGV,eAAe,EAAE,CAAC;QAAC;qBAE5D,oBAAC;QAAI,KAAKE;QAAK,KAAK;QAAI,OAAOM,OAAO,KAAK;QAAE,WAAW;uBAE5D,oBAAC;QAAK,WAAW;OAAgCD,YAAY,KAAK;AAG9E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ImageEditorCrop, ImageEditorHotspot, ImageEditorImage } from "./types.js";
|
|
3
|
+
interface CropHotspotEditorProps {
|
|
4
|
+
image: ImageEditorImage;
|
|
5
|
+
crop: ImageEditorCrop | undefined;
|
|
6
|
+
hotspot: ImageEditorHotspot | undefined;
|
|
7
|
+
/** Currently selected crop shape id ("free" or a preset id). Controlled by the parent. */
|
|
8
|
+
aspectId: string;
|
|
9
|
+
onChangeAspect: (id: string) => void;
|
|
10
|
+
onChangeCrop: (crop: ImageEditorCrop) => void;
|
|
11
|
+
onChangeHotspot: (hotspot: ImageEditorHotspot) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const FREE = "free";
|
|
14
|
+
/**
|
|
15
|
+
* Infer which crop-shape preset a saved crop corresponds to, by comparing the
|
|
16
|
+
* crop's on-screen (pixel) aspect ratio against the presets. The crop stores only
|
|
17
|
+
* edge insets — not the shape used to draw it — so on reopen we recover the shape
|
|
18
|
+
* here; a crop drawn with a preset matches it closely, while a free crop won't.
|
|
19
|
+
*/
|
|
20
|
+
export declare const inferAspectId: (crop: ImageEditorCrop | undefined, width: number, height: number) => string;
|
|
21
|
+
export declare const CropHotspotEditor: ({ image, crop, hotspot, aspectId, onChangeAspect, onChangeCrop, onChangeHotspot }: CropHotspotEditorProps) => React.JSX.Element;
|
|
22
|
+
export {};
|