@noxlovette/material 0.5.1 → 0.6.1
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/bin/material-claude-skill.js +31 -0
- package/claude-skill/material-design/SKILL.md +68 -0
- package/claude-skill/material-design/references/accessibility-checklist.md +29 -0
- package/claude-skill/material-design/references/component-patterns.md +55 -0
- package/claude-skill/material-design/references/motion-guide.md +163 -0
- package/claude-skill/material-design/references/tokens-and-styles.md +68 -0
- package/dist/animation/Shapes.stories.svelte +10 -6
- package/dist/animation/TransitionPatterns.stories.svelte +30 -20
- package/dist/animation/containerTransform.d.ts +4 -2
- package/dist/animation/containerTransform.js +4 -2
- package/dist/animation/enterExit.js +5 -2
- package/dist/animation/skeleton.d.ts +1 -1
- package/dist/animation/skeleton.js +1 -1
- package/dist/components/badge/Badge.mdx +70 -0
- package/dist/components/badge/Badge.stories.svelte +38 -20
- package/dist/components/badge/Badge.svelte +12 -5
- package/dist/components/badge/theme.d.ts +30 -7
- package/dist/components/badge/theme.js +25 -5
- package/dist/components/badge/types.d.ts +18 -4
- package/dist/components/buttons/Button.mdx +85 -0
- package/dist/components/buttons/Button.stories.svelte +62 -27
- package/dist/components/buttons/Button.svelte +29 -25
- package/dist/components/buttons/Button.svelte.d.ts +11 -9
- package/dist/components/buttons/ButtonIcon.mdx +52 -0
- package/dist/components/buttons/ButtonIcon.stories.svelte +72 -48
- package/dist/components/buttons/ButtonIcon.svelte +58 -36
- package/dist/components/buttons/ButtonIcon.svelte.d.ts +9 -7
- package/dist/components/buttons/FAB.mdx +84 -0
- package/dist/components/buttons/FAB.stories.svelte +103 -24
- package/dist/components/buttons/FAB.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/FAB.svelte +353 -29
- package/dist/components/buttons/FAB.svelte.d.ts +11 -6
- package/dist/components/buttons/FABMenu.svelte +27 -8
- package/dist/components/buttons/FABMenu.svelte.d.ts +7 -3
- package/dist/components/buttons/FABMenuItem.svelte +20 -16
- package/dist/components/buttons/FABMenuItem.svelte.d.ts +3 -3
- package/dist/components/buttons/Toggle.stories.svelte +31 -23
- package/dist/components/buttons/Toggle.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/Toggle.svelte +28 -25
- package/dist/components/buttons/Toggle.svelte.d.ts +5 -5
- package/dist/components/buttons/button-group/ButtonGroup.mdx +39 -0
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte +62 -43
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/button-group/ButtonGroup.svelte +102 -8
- package/dist/components/buttons/button-group/ButtonGroup.svelte.d.ts +6 -7
- package/dist/components/buttons/button-group/theme.d.ts +46 -16
- package/dist/components/buttons/button-group/theme.js +14 -9
- package/dist/components/buttons/button-group/types.d.ts +13 -7
- package/dist/components/buttons/connected/ConnectedButtonGroup.mdx +43 -0
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte +56 -74
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte.d.ts +2 -17
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte +16 -4
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte.d.ts +4 -4
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte +35 -8
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte.d.ts +2 -3
- package/dist/components/buttons/connected/theme.d.ts +34 -19
- package/dist/components/buttons/connected/theme.js +33 -10
- package/dist/components/buttons/connected/types.d.ts +36 -9
- package/dist/components/buttons/shapeMorph.d.ts +26 -0
- package/dist/components/buttons/shapeMorph.js +142 -0
- package/dist/components/buttons/split-button/SplitButton.mdx +48 -0
- package/dist/components/buttons/split-button/SplitButton.stories.svelte +9 -14
- package/dist/components/buttons/split-button/SplitButton.svelte +66 -49
- package/dist/components/buttons/split-button/SplitButton.svelte.d.ts +6 -11
- package/dist/components/buttons/split-button/theme.d.ts +111 -18
- package/dist/components/buttons/split-button/theme.js +75 -17
- package/dist/components/buttons/split-button/types.d.ts +24 -18
- package/dist/components/buttons/theme.d.ts +423 -231
- package/dist/components/buttons/theme.js +287 -381
- package/dist/components/buttons/types.d.ts +130 -125
- package/dist/components/cards/Card.mdx +44 -0
- package/dist/components/cards/Card.stories.svelte +11 -11
- package/dist/components/cards/theme.js +6 -6
- package/dist/components/chips/Chip.mdx +68 -0
- package/dist/components/chips/Chip.stories.svelte +4 -4
- package/dist/components/chips/theme.d.ts +1 -1
- package/dist/components/chips/theme.js +4 -4
- package/dist/components/containers/action-rail/ActionRail.stories.svelte +1 -0
- package/dist/components/containers/action-rail/theme.d.ts +1 -1
- package/dist/components/containers/action-rail/theme.js +2 -2
- package/dist/components/containers/app/theme.d.ts +1 -1
- package/dist/components/containers/app/theme.js +1 -1
- package/dist/components/containers/bottom-sheet/BottomSheet.mdx +64 -0
- package/dist/components/containers/bottom-sheet/BottomSheet.stories.svelte +108 -12
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte +179 -109
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte.d.ts +10 -5
- package/dist/components/containers/bottom-sheet/index.d.ts +1 -0
- package/dist/components/containers/bottom-sheet/index.js +1 -0
- package/dist/components/containers/bottom-sheet/theme.d.ts +45 -0
- package/dist/components/containers/bottom-sheet/theme.js +42 -0
- package/dist/components/containers/bottom-sheet/types.d.ts +37 -5
- package/dist/components/containers/carousel/Carousel.mdx +80 -0
- package/dist/components/containers/carousel/Carousel.stories.svelte +131 -0
- package/dist/components/containers/carousel/Carousel.stories.svelte.d.ts +4 -0
- package/dist/components/containers/carousel/Carousel.svelte +194 -0
- package/dist/components/containers/carousel/Carousel.svelte.d.ts +25 -0
- package/dist/components/containers/carousel/index.d.ts +3 -0
- package/dist/components/containers/{stack → carousel}/index.js +1 -2
- package/dist/components/containers/carousel/keylines.d.ts +32 -0
- package/dist/components/containers/carousel/keylines.js +88 -0
- package/dist/components/containers/carousel/theme.d.ts +162 -0
- package/dist/components/containers/carousel/theme.js +67 -0
- package/dist/components/containers/carousel/types.d.ts +52 -0
- package/dist/components/containers/context-menu/ContextMenu.stories.svelte +1 -0
- package/dist/components/containers/context-menu/ContextMenu.svelte +2 -2
- package/dist/components/containers/context-menu/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/containers/context-menu/theme.d.ts +1 -1
- package/dist/components/containers/context-menu/theme.js +11 -11
- package/dist/components/containers/dialogue/Dialogue.mdx +65 -0
- package/dist/components/containers/dialogue/Dialogue.stories.svelte +4 -4
- package/dist/components/containers/dialogue/Dialogue.svelte +2 -2
- package/dist/components/containers/dialogue/theme.d.ts +1 -1
- package/dist/components/containers/dialogue/theme.js +4 -4
- package/dist/components/containers/dialogue/types.d.ts +1 -1
- package/dist/components/containers/divider/Divider.stories.svelte +2 -1
- package/dist/components/containers/divider/Divider.svelte +2 -2
- package/dist/components/containers/divider/theme.d.ts +7 -7
- package/dist/components/containers/divider/theme.js +3 -3
- package/dist/components/containers/index.d.ts +1 -1
- package/dist/components/containers/index.js +1 -1
- package/dist/components/containers/link-preview/theme.d.ts +1 -1
- package/dist/components/containers/link-preview/theme.js +3 -3
- package/dist/components/containers/list/List.svelte +18 -0
- package/dist/components/containers/list/List.svelte.d.ts +4 -0
- package/dist/components/containers/list/ListItem.mdx +100 -0
- package/dist/components/containers/list/ListItem.stories.svelte +177 -42
- package/dist/components/containers/list/ListItem.stories.svelte.d.ts +2 -17
- package/dist/components/containers/list/ListItem.svelte +92 -37
- package/dist/components/containers/list/ListItem.svelte.d.ts +1 -1
- package/dist/components/containers/list/context.d.ts +6 -0
- package/dist/components/containers/list/context.js +4 -0
- package/dist/components/containers/list/index.d.ts +1 -0
- package/dist/components/containers/list/index.js +1 -0
- package/dist/components/containers/list/theme.d.ts +487 -12
- package/dist/components/containers/list/theme.js +141 -14
- package/dist/components/containers/list/types.d.ts +39 -5
- package/dist/components/containers/menu/Menu.mdx +52 -0
- package/dist/components/containers/menu/Menu.stories.svelte +14 -14
- package/dist/components/containers/menu/Menu.svelte +2 -2
- package/dist/components/containers/menu/MenuGroup.svelte +1 -1
- package/dist/components/containers/menu/MenuGroup.svelte.d.ts +1 -1
- package/dist/components/containers/menu/MenuSub.svelte +1 -1
- package/dist/components/containers/menu/menu-item/MenuItem.svelte +1 -1
- package/dist/components/containers/menu/theme.d.ts +1 -1
- package/dist/components/containers/menu/theme.js +9 -9
- package/dist/components/containers/pane/DraggablePane.stories.svelte +4 -3
- package/dist/components/containers/pane/DraggablePane.svelte +2 -2
- package/dist/components/containers/pane/Pane.stories.svelte +11 -10
- package/dist/components/containers/pane/Pane.svelte +24 -2
- package/dist/components/containers/pane/PaneGrid.stories.svelte +19 -18
- package/dist/components/containers/pane/PaneGrid.svelte +3 -2
- package/dist/components/containers/pane/PaneGrid.svelte.d.ts +2 -1
- package/dist/components/containers/pane/PaneHandle.svelte +48 -2
- package/dist/components/containers/pane/PaneHandle.svelte.d.ts +4 -0
- package/dist/components/containers/pane/resizeStore.svelte.d.ts +10 -1
- package/dist/components/containers/pane/resizeStore.svelte.js +13 -2
- package/dist/components/containers/pane/theme.d.ts +1 -1
- package/dist/components/containers/pane/theme.js +131 -47
- package/dist/components/containers/pane/types.d.ts +3 -2
- package/dist/components/containers/popover/Popover.mdx +45 -0
- package/dist/components/containers/popover/Popover.stories.svelte +1 -1
- package/dist/components/containers/popover/Popover.svelte +1 -1
- package/dist/components/containers/popover/theme.d.ts +1 -1
- package/dist/components/containers/popover/theme.js +4 -4
- package/dist/components/containers/scroll-area/theme.js +3 -3
- package/dist/components/containers/side-sheet/SideSheet.mdx +71 -0
- package/dist/components/containers/side-sheet/SideSheet.stories.svelte +113 -17
- package/dist/components/containers/side-sheet/SideSheet.svelte +113 -66
- package/dist/components/containers/side-sheet/SideSheet.svelte.d.ts +8 -7
- package/dist/components/containers/side-sheet/index.d.ts +1 -0
- package/dist/components/containers/side-sheet/index.js +1 -0
- package/dist/components/containers/side-sheet/theme.d.ts +108 -0
- package/dist/components/containers/side-sheet/theme.js +72 -0
- package/dist/components/containers/side-sheet/types.d.ts +35 -7
- package/dist/components/date/DateField.stories.svelte +4 -3
- package/dist/components/date/DateField.svelte +11 -2
- package/dist/components/date/DateRangeField.stories.svelte +4 -3
- package/dist/components/date/DateRangeField.svelte +12 -3
- package/dist/components/date/theme.d.ts +8 -8
- package/dist/components/date/theme.js +32 -32
- package/dist/components/forms/checkbox/Checkbox.mdx +35 -0
- package/dist/components/forms/checkbox/Checkbox.stories.svelte +2 -2
- package/dist/components/forms/checkbox/Checkbox.svelte +1 -1
- package/dist/components/forms/checkbox/theme.d.ts +1 -1
- package/dist/components/forms/checkbox/theme.js +4 -4
- package/dist/components/forms/command/Command.stories.svelte +1 -0
- package/dist/components/forms/command/theme.d.ts +1 -1
- package/dist/components/forms/command/theme.js +10 -10
- package/dist/components/forms/pin/theme.d.ts +1 -1
- package/dist/components/forms/pin/theme.js +5 -5
- package/dist/components/forms/radio-group/RadioGroup.svelte +1 -1
- package/dist/components/forms/radio-group/theme.d.ts +1 -1
- package/dist/components/forms/radio-group/theme.js +6 -6
- package/dist/components/forms/search/Search.mdx +38 -0
- package/dist/components/forms/search/Search.stories.svelte +19 -9
- package/dist/components/forms/search/Search.svelte +40 -17
- package/dist/components/forms/search/Search.svelte.d.ts +2 -2
- package/dist/components/forms/search/theme.d.ts +46 -13
- package/dist/components/forms/search/theme.js +14 -9
- package/dist/components/forms/search/types.d.ts +18 -12
- package/dist/components/forms/select/Select.mdx +53 -0
- package/dist/components/forms/select/Select.stories.svelte +4 -4
- package/dist/components/forms/select/Select.svelte +12 -4
- package/dist/components/forms/select/SelectItem.svelte +1 -1
- package/dist/components/forms/select/theme.d.ts +1 -1
- package/dist/components/forms/select/theme.js +14 -14
- package/dist/components/forms/slider/Slider.mdx +85 -0
- package/dist/components/forms/slider/Slider.stories.svelte +7 -7
- package/dist/components/forms/slider/Slider.svelte +46 -28
- package/dist/components/forms/slider/theme.d.ts +15 -1
- package/dist/components/forms/slider/theme.js +29 -18
- package/dist/components/forms/slider/types.d.ts +3 -2
- package/dist/components/forms/switch/Switch.mdx +38 -0
- package/dist/components/forms/switch/Switch.stories.svelte +3 -3
- package/dist/components/forms/switch/theme.d.ts +1 -1
- package/dist/components/forms/switch/theme.js +7 -7
- package/dist/components/forms/textfield/Textfield.mdx +53 -0
- package/dist/components/forms/textfield/Textfield.stories.svelte +6 -6
- package/dist/components/forms/textfield/Textfield.svelte +1 -0
- package/dist/components/forms/textfield/theme.d.ts +1 -1
- package/dist/components/forms/textfield/theme.js +20 -20
- package/dist/components/forms/toggle-group/theme.d.ts +1 -1
- package/dist/components/forms/toggle-group/theme.js +3 -3
- package/dist/components/forms/tooltip/Tooltip.stories.svelte +1 -0
- package/dist/components/forms/tooltip/theme.d.ts +1 -1
- package/dist/components/forms/tooltip/theme.js +4 -4
- package/dist/components/misc/Avatar.stories.svelte +5 -4
- package/dist/components/misc/ThemeSettings.svelte +9 -9
- package/dist/components/misc/ThemeSwitcher.svelte +3 -3
- package/dist/components/misc/theme.js +5 -5
- package/dist/components/nav/appbar/AppBar.mdx +71 -0
- package/dist/components/nav/appbar/AppBar.stories.svelte +93 -3
- package/dist/components/nav/appbar/AppBar.stories.svelte.d.ts +2 -17
- package/dist/components/nav/appbar/AppBar.svelte +90 -37
- package/dist/components/nav/appbar/AppBar.svelte.d.ts +9 -2
- package/dist/components/nav/appbar/theme.d.ts +86 -19
- package/dist/components/nav/appbar/theme.js +160 -24
- package/dist/components/nav/appbar/types.d.ts +46 -9
- package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte +1 -0
- package/dist/components/nav/breadcrumb/theme.d.ts +1 -1
- package/dist/components/nav/breadcrumb/theme.js +6 -6
- package/dist/components/nav/navbar/Navbar.mdx +38 -0
- package/dist/components/nav/navbar/Navbar.svelte +1 -1
- package/dist/components/nav/navbar/NavbarItem.svelte +12 -9
- package/dist/components/nav/navbar/theme.d.ts +3 -3
- package/dist/components/nav/navbar/theme.js +7 -7
- package/dist/components/nav/rail/Rail.mdx +73 -0
- package/dist/components/nav/rail/Rail.stories.svelte +3 -7
- package/dist/components/nav/rail/Rail.svelte +5 -2
- package/dist/components/nav/rail/RailItem.svelte +12 -9
- package/dist/components/nav/rail/theme.d.ts +1 -1
- package/dist/components/nav/rail/theme.js +14 -14
- package/dist/components/nav/rail/types.d.ts +8 -1
- package/dist/components/nav/tabs/Tabs.mdx +62 -0
- package/dist/components/nav/tabs/Tabs.stories.svelte +1 -1
- package/dist/components/nav/tabs/theme.d.ts +1 -1
- package/dist/components/nav/tabs/theme.js +5 -5
- package/dist/components/pill/Pill.mdx +32 -0
- package/dist/components/pill/Pill.stories.svelte +1 -1
- package/dist/components/pill/theme.d.ts +2 -2
- package/dist/components/pill/theme.js +2 -2
- package/dist/components/progress/LinearProgress.svelte +2 -2
- package/dist/components/progress/Progress.mdx +50 -0
- package/dist/components/progress/Progress.stories.svelte +6 -6
- package/dist/components/snackbar/Snackbar.mdx +52 -0
- package/dist/components/snackbar/Snackbar.stories.svelte +5 -5
- package/dist/components/snackbar/Snackbar.svelte +1 -1
- package/dist/components/snackbar/theme.d.ts +4 -4
- package/dist/components/snackbar/theme.js +5 -5
- package/dist/components/table/Table.stories.svelte +1 -0
- package/dist/components/table/TableHeader.svelte +1 -1
- package/dist/components/table/theme.d.ts +1 -1
- package/dist/components/table/theme.js +4 -4
- package/dist/components/time/TimeField.stories.svelte +3 -2
- package/dist/components/time/TimeField.svelte +2 -2
- package/dist/components/time/TimepickerInput.svelte +1 -1
- package/dist/components/time/theme.d.ts +1 -1
- package/dist/components/time/theme.js +6 -6
- package/dist/components/toolbar/Toolbar.stories.svelte +1 -0
- package/dist/components/toolbar/Toolbar.svelte +1 -1
- package/dist/components/toolbar/Toolbar.svelte.d.ts +1 -1
- package/dist/components/toolbar/theme.d.ts +1 -1
- package/dist/components/toolbar/theme.js +15 -15
- package/dist/components/typography/Typography.mdx +67 -0
- package/dist/components/typography/body/Body.stories.svelte +2 -1
- package/dist/components/typography/body/theme.d.ts +16 -13
- package/dist/components/typography/body/theme.js +20 -5
- package/dist/components/typography/body/types.d.ts +2 -1
- package/dist/components/typography/display/Display.stories.svelte +2 -1
- package/dist/components/typography/display/theme.d.ts +16 -13
- package/dist/components/typography/display/theme.js +20 -5
- package/dist/components/typography/display/types.d.ts +2 -1
- package/dist/components/typography/headline/Headline.stories.svelte +2 -1
- package/dist/components/typography/headline/theme.d.ts +16 -13
- package/dist/components/typography/headline/theme.js +20 -5
- package/dist/components/typography/headline/types.d.ts +2 -1
- package/dist/components/typography/kbd/Kbd.stories.svelte +2 -1
- package/dist/components/typography/kbd/theme.d.ts +5 -5
- package/dist/components/typography/kbd/theme.js +3 -3
- package/dist/components/typography/label/Label.stories.svelte +2 -1
- package/dist/components/typography/label/theme.d.ts +15 -12
- package/dist/components/typography/label/theme.js +20 -5
- package/dist/components/typography/label/types.d.ts +2 -1
- package/dist/components/typography/title/Title.stories.svelte +2 -1
- package/dist/components/typography/title/theme.d.ts +16 -13
- package/dist/components/typography/title/theme.js +20 -5
- package/dist/components/typography/title/types.d.ts +2 -1
- package/dist/index.css +2 -0
- package/dist/styles/component.css +78 -175
- package/dist/styles/elevation.css +9 -0
- package/dist/styles/layers.css +33 -0
- package/dist/styles/spacing.css +29 -0
- package/dist/styles/typescale.css +635 -20
- package/dist/utils/Layer.svelte +1 -1
- package/dist/utils/icon/Icon.svelte +8 -6
- package/dist/utils/icon/theme.d.ts +1 -1
- package/dist/utils/icon/theme.js +1 -1
- package/dist/utils/tv.d.ts +6 -0
- package/dist/utils/tv.js +12 -0
- package/package.json +19 -15
- package/dist/components/containers/stack/HStack.svelte +0 -23
- package/dist/components/containers/stack/HStack.svelte.d.ts +0 -5
- package/dist/components/containers/stack/VStack.svelte +0 -23
- package/dist/components/containers/stack/VStack.svelte.d.ts +0 -5
- package/dist/components/containers/stack/index.d.ts +0 -4
- package/dist/components/containers/stack/theme.d.ts +0 -66
- package/dist/components/containers/stack/theme.js +0 -26
- package/dist/components/containers/stack/types.d.ts +0 -12
- /package/dist/components/containers/{stack → carousel}/types.js +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { tv } from '
|
|
1
|
+
import { tv } from '../../../utils/tv.js';
|
|
2
2
|
export const command = tv({
|
|
3
3
|
slots: {
|
|
4
4
|
base: 'flex h-full w-full flex-col overflow-hidden rounded-2xl bg-md-sys-color-surface-container-high text-md-sys-color-on-surface shadow-elevation-3 ring-1 ring-md-sys-color-outline/20',
|
|
5
|
-
inputWrapper: 'flex items-center border-b border-md-sys-color-outline-variant px-
|
|
6
|
-
inputIcon: 'mr-
|
|
7
|
-
input: 'flex h-
|
|
8
|
-
list: 'max-h-[300px] overflow-y-auto overflow-x-hidden p-
|
|
9
|
-
empty: 'py-
|
|
10
|
-
group: 'overflow-hidden p-
|
|
11
|
-
separator: '-mx-
|
|
12
|
-
item: 'relative flex cursor-default select-none items-center rounded-lg px-
|
|
13
|
-
itemIcon: 'mr-
|
|
5
|
+
inputWrapper: 'flex items-center border-b border-md-sys-color-outline-variant px-spacing-200',
|
|
6
|
+
inputIcon: 'mr-spacing-150 h-spacing-250 w-spacing-250 shrink-0 text-md-sys-color-on-surface-variant',
|
|
7
|
+
input: 'flex h-spacing-600 w-full rounded-md bg-transparent py-spacing-150 md-sys-typescale-body-large outline-none placeholder:text-md-sys-color-on-surface-variant disabled:cursor-not-allowed disabled:opacity-50',
|
|
8
|
+
list: 'max-h-[300px] overflow-y-auto overflow-x-hidden p-spacing-100 scrollbar-thin scrollbar-thumb-md-sys-color-outline-variant scrollbar-track-transparent',
|
|
9
|
+
empty: 'py-spacing-300 text-center md-sys-typescale-body-medium text-md-sys-color-on-surface-variant',
|
|
10
|
+
group: 'overflow-hidden p-spacing-50 text-md-sys-color-on-surface-variant [&_[data-command-group-heading]]:px-spacing-150 [&_[data-command-group-heading]]:py-spacing-100 [&_[data-command-group-heading]]:md-sys-typescale-label-medium [&_[data-command-group-heading]]:text-md-sys-color-on-surface-variant',
|
|
11
|
+
separator: '-mx-spacing-50 h-px bg-md-sys-color-outline-variant',
|
|
12
|
+
item: 'relative flex cursor-default select-none items-center rounded-lg px-spacing-150 py-spacing-150 md-sys-typescale-body-medium outline-none data-[selected=true]:bg-md-sys-color-secondary-container data-[selected=true]:text-md-sys-color-on-secondary-container data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50 transition-colors md-sys-motion-fast-effects',
|
|
13
|
+
itemIcon: 'mr-spacing-150 h-spacing-250 w-spacing-250 shrink-0'
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { tv } from '
|
|
1
|
+
import { tv } from '../../../utils/tv.js';
|
|
2
2
|
export const pinInput = tv({
|
|
3
3
|
slots: {
|
|
4
|
-
root: 'flex flex-col gap-
|
|
4
|
+
root: 'flex flex-col gap-spacing-100',
|
|
5
5
|
label: 'md-sys-typescale-label-large text-md-sys-color-on-surface-variant',
|
|
6
|
-
container: 'flex items-center gap-
|
|
6
|
+
container: 'flex items-center gap-spacing-100',
|
|
7
7
|
cell: `
|
|
8
|
-
relative flex h-
|
|
8
|
+
relative flex h-spacing-700 w-spacing-600 items-center justify-center
|
|
9
9
|
bg-md-sys-color-surface-container-highest rounded-t-xs
|
|
10
10
|
md-sys-typescale-headline-small text-md-sys-color-on-surface
|
|
11
11
|
transition-colors md-sys-motion-fast-effects
|
|
12
|
-
after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-md-sys-color-on-surface-variant
|
|
12
|
+
after:absolute after:bottom-spacing-0 after:left-spacing-0 after:right-spacing-0 after:h-px after:bg-md-sys-color-on-surface-variant
|
|
13
13
|
after:transition-[height,background-color] after:md-sys-motion-fast-spatial
|
|
14
14
|
data-[focus]:after:bg-md-sys-color-primary data-[focus]:after:h-[2px]
|
|
15
15
|
data-[placeholder]:text-md-sys-color-on-surface-variant/38
|
|
@@ -49,7 +49,7 @@ Radio buttons let users select one option from a set.
|
|
|
49
49
|
<div class={itemCls.outerRing()}></div>
|
|
50
50
|
<div class={itemCls.innerDot()}></div>
|
|
51
51
|
</div>
|
|
52
|
-
<div class="flex flex-col
|
|
52
|
+
<div class="gap-spacing-25 flex flex-col text-left">
|
|
53
53
|
<span class={itemCls.label()}>{item.label}</span>
|
|
54
54
|
{#if item.supportingText}
|
|
55
55
|
<span class={itemCls.supporting()}>{item.supportingText}</span>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { tv } from '
|
|
1
|
+
import { tv } from '../../../utils/tv.js';
|
|
2
2
|
export const radioGroup = tv({
|
|
3
3
|
slots: {
|
|
4
4
|
root: 'flex',
|
|
5
|
-
item: 'inline-flex min-h-
|
|
5
|
+
item: 'inline-flex min-h-spacing-500 cursor-pointer select-none items-center gap-spacing-150 text-md-sys-color-on-surface',
|
|
6
6
|
indicator: 'relative inline-flex size-[20px] shrink-0',
|
|
7
7
|
control: 'relative layer-container absolute -inset-[10px] rounded-full text-md-sys-color-on-surface-variant state-layer before:rounded-full',
|
|
8
|
-
outerRing: 'absolute inset-0 rounded-full border-2 border-md-sys-color-outline transition-colors md-sys-motion-fast-effects',
|
|
9
|
-
innerDot: 'absolute inset-0 m-auto size-
|
|
8
|
+
outerRing: 'absolute inset-spacing-0 rounded-full border-2 border-md-sys-color-outline transition-colors md-sys-motion-fast-effects',
|
|
9
|
+
innerDot: 'absolute inset-spacing-0 m-auto size-spacing-125 scale-0 rounded-full bg-md-sys-color-on-primary-container transition-transform md-sys-motion-fast-spatial',
|
|
10
10
|
label: 'md-sys-typescale-body-large text-md-sys-color-on-surface',
|
|
11
11
|
supporting: 'md-sys-typescale-body-medium text-md-sys-color-on-surface-variant'
|
|
12
12
|
},
|
|
13
13
|
variants: {
|
|
14
14
|
orientation: {
|
|
15
|
-
vertical: { root: 'flex-col gap-
|
|
16
|
-
horizontal: { root: 'flex-row flex-wrap gap-
|
|
15
|
+
vertical: { root: 'flex-col gap-spacing-50' },
|
|
16
|
+
horizontal: { root: 'flex-row flex-wrap gap-spacing-300' }
|
|
17
17
|
},
|
|
18
18
|
checked: {
|
|
19
19
|
true: {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as SearchStories from './Search.stories.svelte';
|
|
3
|
+
|
|
4
|
+
<Meta of={SearchStories} />
|
|
5
|
+
|
|
6
|
+
<Title />
|
|
7
|
+
|
|
8
|
+
<Subtitle>The search bar lets users enter a query to find information in an app.</Subtitle>
|
|
9
|
+
|
|
10
|
+
[M3 spec](https://m3.material.io/components/search/specs) ·
|
|
11
|
+
`import { Search } from '@noxlovette/material';`
|
|
12
|
+
|
|
13
|
+
<Canvas of={SearchStories.Playground} />
|
|
14
|
+
|
|
15
|
+
<Controls of={SearchStories.Playground} />
|
|
16
|
+
|
|
17
|
+
## Search bar, not search view
|
|
18
|
+
|
|
19
|
+
This is M3's search bar: a 56dp, fully rounded `surface-container-high` field with a leading
|
|
20
|
+
search icon. It's a different thing from the full-screen search view, and from a filled text
|
|
21
|
+
field. Once there's a value, a clear button appears at the end. Other native `<input>` attributes
|
|
22
|
+
pass straight through to the input.
|
|
23
|
+
|
|
24
|
+
```svelte
|
|
25
|
+
<Search placeholder="Search" bind:value={query} />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
<Canvas of={SearchStories.WithActions} />
|
|
29
|
+
|
|
30
|
+
For a search field inside a top app bar, use `AppBar`'s `search` prop instead.
|
|
31
|
+
|
|
32
|
+
## Accessibility
|
|
33
|
+
|
|
34
|
+
- **Label.** The `type="search"` input sits inside a `<label>` with its own id, so the whole bar
|
|
35
|
+
is a target and several bars can share a page.
|
|
36
|
+
- **Clear button.** A 48dp `type="button"` labelled by `clearLabel` (default "Clear search"). It
|
|
37
|
+
never submits a form and returns focus to the input.
|
|
38
|
+
- **Focus.** Keyboard focus draws the M3 focus indicator around the bar.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import Search from './Search.svelte';
|
|
4
|
+
import ButtonIcon from '../../buttons/ButtonIcon.svelte';
|
|
4
5
|
|
|
5
6
|
const { Story } = defineMeta({
|
|
6
7
|
title: 'Forms/Search',
|
|
@@ -18,24 +19,33 @@
|
|
|
18
19
|
|
|
19
20
|
<Story name="Playground">
|
|
20
21
|
{#snippet template(args)}
|
|
21
|
-
<div class="max-w-md
|
|
22
|
+
<div class="p-spacing-300 max-w-md">
|
|
22
23
|
<Search {...args} />
|
|
23
24
|
</div>
|
|
24
25
|
{/snippet}
|
|
25
26
|
</Story>
|
|
26
27
|
|
|
27
28
|
<Story name="With Value" asChild>
|
|
28
|
-
<div class="max-w-md
|
|
29
|
+
<div class="p-spacing-300 max-w-md">
|
|
29
30
|
<Search value="Material Design" />
|
|
30
31
|
</div>
|
|
31
32
|
</Story>
|
|
32
33
|
|
|
33
|
-
<Story name="
|
|
34
|
-
<div class="max-w-md
|
|
35
|
-
<Search
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
<Story name="With actions" asChild>
|
|
35
|
+
<div class="gap-spacing-200 p-spacing-300 flex max-w-md flex-col">
|
|
36
|
+
<Search>
|
|
37
|
+
{#snippet leading()}
|
|
38
|
+
<ButtonIcon variant="standard" iconProps={{ name: 'menu' }} aria-label="Menu" />
|
|
39
|
+
{/snippet}
|
|
40
|
+
{#snippet trailing()}
|
|
41
|
+
<ButtonIcon variant="standard" iconProps={{ name: 'mic' }} aria-label="Voice search" />
|
|
42
|
+
<ButtonIcon
|
|
43
|
+
variant="standard"
|
|
44
|
+
iconProps={{ name: 'account_circle' }}
|
|
45
|
+
aria-label="Account"
|
|
46
|
+
/>
|
|
47
|
+
{/snippet}
|
|
48
|
+
</Search>
|
|
49
|
+
<Search value="query" leadingIconProps={null} placeholder="No leading icon" />
|
|
40
50
|
</div>
|
|
41
51
|
</Story>
|
|
@@ -1,52 +1,75 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
Material 3 Search Bar.
|
|
3
|
+
Material 3 Search Bar (contained, M3 Expressive).
|
|
4
4
|
|
|
5
5
|
Search bars allow users to enter a query to find specific information within an app.
|
|
6
6
|
|
|
7
|
-
@see https://m3.material.io/components/search/
|
|
7
|
+
@see https://m3.material.io/components/search/specs
|
|
8
8
|
-->
|
|
9
9
|
<script lang="ts">
|
|
10
10
|
import { search } from './theme.js';
|
|
11
11
|
import clsx from 'clsx';
|
|
12
12
|
import type { SearchProps } from './types.js';
|
|
13
13
|
import { Icon } from '../../../utils/index.js';
|
|
14
|
+
import ButtonIcon from '../../buttons/ButtonIcon.svelte';
|
|
15
|
+
|
|
16
|
+
const uid = $props.id();
|
|
14
17
|
|
|
15
18
|
let {
|
|
16
|
-
|
|
17
|
-
placeholder = 'Поиск',
|
|
19
|
+
placeholder = 'Search',
|
|
18
20
|
value = $bindable(),
|
|
19
21
|
elementRef = $bindable(),
|
|
22
|
+
leading,
|
|
23
|
+
trailing,
|
|
20
24
|
trailingIconProps = { name: 'close' },
|
|
21
25
|
leadingIconProps = { name: 'search' },
|
|
26
|
+
clearLabel = 'Clear search',
|
|
22
27
|
class: className,
|
|
28
|
+
id = uid,
|
|
23
29
|
trailingClick = () => {
|
|
24
30
|
value = '';
|
|
31
|
+
elementRef?.focus();
|
|
25
32
|
},
|
|
26
33
|
...restProps
|
|
27
34
|
}: SearchProps = $props();
|
|
28
35
|
|
|
29
|
-
const
|
|
36
|
+
const showClear = $derived(!!trailingIconProps && !!value);
|
|
37
|
+
|
|
38
|
+
const s = $derived(
|
|
39
|
+
search({
|
|
40
|
+
hasLeading: !!leading || !!leadingIconProps,
|
|
41
|
+
hasTrailing: !!trailing || showClear
|
|
42
|
+
})
|
|
43
|
+
);
|
|
30
44
|
</script>
|
|
31
45
|
|
|
32
|
-
<label for=
|
|
33
|
-
{#if
|
|
34
|
-
<
|
|
46
|
+
<label for={id} class={s.base({ class: clsx(className) })}>
|
|
47
|
+
{#if leading}
|
|
48
|
+
<span class={s.leading()}>{@render leading()}</span>
|
|
49
|
+
{:else if leadingIconProps}
|
|
50
|
+
<span class={s.leadingIcon()} aria-hidden="true"><Icon {...leadingIconProps} /></span>
|
|
35
51
|
{/if}
|
|
36
52
|
<input
|
|
37
|
-
id="search"
|
|
38
53
|
{...restProps}
|
|
54
|
+
{id}
|
|
39
55
|
{placeholder}
|
|
40
56
|
bind:this={elementRef}
|
|
41
57
|
bind:value
|
|
42
|
-
type="
|
|
43
|
-
class={input()}
|
|
44
|
-
oncancel={() => (value = undefined)}
|
|
58
|
+
type="search"
|
|
59
|
+
class={s.input()}
|
|
45
60
|
/>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
{#if showClear || trailing}
|
|
62
|
+
<span class={s.trailing()}>
|
|
63
|
+
{#if showClear}
|
|
64
|
+
<ButtonIcon
|
|
65
|
+
variant="standard"
|
|
66
|
+
type="button"
|
|
67
|
+
iconProps={trailingIconProps!}
|
|
68
|
+
aria-label={clearLabel}
|
|
69
|
+
onclick={trailingClick}
|
|
70
|
+
/>
|
|
71
|
+
{/if}
|
|
72
|
+
{@render trailing?.()}
|
|
73
|
+
</span>
|
|
51
74
|
{/if}
|
|
52
75
|
</label>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SearchProps } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Material 3 Search Bar.
|
|
3
|
+
* Material 3 Search Bar (contained, M3 Expressive).
|
|
4
4
|
*
|
|
5
5
|
* Search bars allow users to enter a query to find specific information within an app.
|
|
6
6
|
*
|
|
7
|
-
* @see https://m3.material.io/components/search/
|
|
7
|
+
* @see https://m3.material.io/components/search/specs
|
|
8
8
|
*/
|
|
9
9
|
declare const Search: import("svelte").Component<SearchProps, {}, "value" | "elementRef">;
|
|
10
10
|
type Search = ReturnType<typeof Search>;
|
|
@@ -1,33 +1,66 @@
|
|
|
1
|
-
import { type VariantProps } from '
|
|
1
|
+
import { type VariantProps } from '../../../utils/tv.js';
|
|
2
2
|
export type SearchVariants = VariantProps<typeof search>;
|
|
3
|
+
/**
|
|
4
|
+
* M3 Expressive contained search bar (https://m3.material.io/components/search/specs):
|
|
5
|
+
* 56dp, circular, surface-container-high, flat. 48dp leading/trailing targets at a 4dp inset,
|
|
6
|
+
* 4dp between the leading element and the label, 0 between trailing actions; 16dp at an edge
|
|
7
|
+
* with no action. Hover 8% / pressed 10% on-surface; focus 3dp secondary outline, 2dp offset.
|
|
8
|
+
*/
|
|
3
9
|
export declare const search: import("tailwind-variants").TVReturnType<{
|
|
4
|
-
|
|
5
|
-
true: "
|
|
6
|
-
false:
|
|
10
|
+
hasLeading: {
|
|
11
|
+
true: "";
|
|
12
|
+
false: {
|
|
13
|
+
input: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
hasTrailing: {
|
|
17
|
+
true: "";
|
|
18
|
+
false: {
|
|
19
|
+
input: string;
|
|
20
|
+
};
|
|
7
21
|
};
|
|
8
22
|
}, {
|
|
9
23
|
base: string;
|
|
24
|
+
leading: string;
|
|
10
25
|
leadingIcon: string;
|
|
11
|
-
trailingIcon: string;
|
|
12
26
|
input: string;
|
|
27
|
+
trailing: string;
|
|
13
28
|
}, undefined, {
|
|
14
|
-
|
|
15
|
-
true: "
|
|
16
|
-
false:
|
|
29
|
+
hasLeading: {
|
|
30
|
+
true: "";
|
|
31
|
+
false: {
|
|
32
|
+
input: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
hasTrailing: {
|
|
36
|
+
true: "";
|
|
37
|
+
false: {
|
|
38
|
+
input: string;
|
|
39
|
+
};
|
|
17
40
|
};
|
|
18
41
|
}, {
|
|
19
42
|
base: string;
|
|
43
|
+
leading: string;
|
|
20
44
|
leadingIcon: string;
|
|
21
|
-
trailingIcon: string;
|
|
22
45
|
input: string;
|
|
46
|
+
trailing: string;
|
|
23
47
|
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
24
|
-
|
|
25
|
-
true: "
|
|
26
|
-
false:
|
|
48
|
+
hasLeading: {
|
|
49
|
+
true: "";
|
|
50
|
+
false: {
|
|
51
|
+
input: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
hasTrailing: {
|
|
55
|
+
true: "";
|
|
56
|
+
false: {
|
|
57
|
+
input: string;
|
|
58
|
+
};
|
|
27
59
|
};
|
|
28
60
|
}, {
|
|
29
61
|
base: string;
|
|
62
|
+
leading: string;
|
|
30
63
|
leadingIcon: string;
|
|
31
|
-
trailingIcon: string;
|
|
32
64
|
input: string;
|
|
65
|
+
trailing: string;
|
|
33
66
|
}>>;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { tv } from '
|
|
1
|
+
import { tv } from '../../../utils/tv.js';
|
|
2
|
+
/**
|
|
3
|
+
* M3 Expressive contained search bar (https://m3.material.io/components/search/specs):
|
|
4
|
+
* 56dp, circular, surface-container-high, flat. 48dp leading/trailing targets at a 4dp inset,
|
|
5
|
+
* 4dp between the leading element and the label, 0 between trailing actions; 16dp at an edge
|
|
6
|
+
* with no action. Hover 8% / pressed 10% on-surface; focus 3dp secondary outline, 2dp offset.
|
|
7
|
+
*/
|
|
2
8
|
export const search = tv({
|
|
3
9
|
slots: {
|
|
4
|
-
base: '
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
input: '
|
|
10
|
+
base: 'state-layer relative flex h-spacing-700 w-full max-w-[720px] grow cursor-text items-center rounded-full bg-md-sys-color-surface-container-high ps-spacing-50 pe-spacing-50 before:rounded-full hover:before:bg-md-sys-color-on-surface/8 active:before:bg-md-sys-color-on-surface/10 has-[input:focus-visible]:outline-3 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-md-sys-color-secondary',
|
|
11
|
+
leading: 'text-md-sys-color-on-surface relative flex shrink-0 items-center',
|
|
12
|
+
leadingIcon: 'text-md-sys-color-on-surface grid size-spacing-600 shrink-0 place-items-center',
|
|
13
|
+
input: 'md-sys-typescale-body-large text-md-sys-color-on-surface placeholder:text-md-sys-color-on-surface-variant relative ms-spacing-50 me-spacing-50 w-full min-w-spacing-0 bg-transparent outline-none [&::-webkit-search-cancel-button]:hidden',
|
|
14
|
+
trailing: 'text-md-sys-color-on-surface-variant relative flex shrink-0 items-center'
|
|
8
15
|
},
|
|
9
16
|
variants: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
false: ''
|
|
13
|
-
}
|
|
17
|
+
hasLeading: { true: '', false: { input: 'ms-spacing-150' } },
|
|
18
|
+
hasTrailing: { true: '', false: { input: 'me-spacing-150' } }
|
|
14
19
|
}
|
|
15
20
|
});
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import type { IconProps } from '../../../utils/index.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
-
import type { SearchVariants } from './theme.js';
|
|
5
4
|
/**
|
|
6
5
|
* Props for the Search component.
|
|
7
6
|
*/
|
|
8
|
-
export interface SearchProps extends
|
|
9
|
-
/**
|
|
10
|
-
* The content of the search bar, typically used for custom layouts.
|
|
11
|
-
*/
|
|
12
|
-
children?: Snippet;
|
|
7
|
+
export interface SearchProps extends Omit<HTMLInputAttributes, 'size'> {
|
|
13
8
|
/**
|
|
14
9
|
* The current value of the search input.
|
|
15
10
|
*/
|
|
@@ -19,16 +14,27 @@ export interface SearchProps extends SearchVariants, Omit<HTMLInputAttributes, '
|
|
|
19
14
|
*/
|
|
20
15
|
elementRef?: HTMLInputElement;
|
|
21
16
|
/**
|
|
22
|
-
*
|
|
23
|
-
|
|
17
|
+
* A leading action, e.g. a menu or back icon button. Replaces the leading icon.
|
|
18
|
+
*/
|
|
19
|
+
leading?: Snippet;
|
|
20
|
+
/**
|
|
21
|
+
* Trailing actions and/or an avatar, e.g. a mic icon button. Rendered after the clear button.
|
|
22
|
+
*/
|
|
23
|
+
trailing?: Snippet;
|
|
24
|
+
/**
|
|
25
|
+
* Called by the clear button. Defaults to clearing the value and refocusing the input.
|
|
24
26
|
*/
|
|
25
27
|
trailingClick?: () => void;
|
|
26
28
|
/**
|
|
27
|
-
* Props for the leading icon (
|
|
29
|
+
* Props for the leading icon (a search icon by default); `null` removes it.
|
|
30
|
+
*/
|
|
31
|
+
leadingIconProps?: IconProps | null;
|
|
32
|
+
/**
|
|
33
|
+
* Props for the clear button's icon, shown while there is a value; `null` removes the button.
|
|
28
34
|
*/
|
|
29
|
-
|
|
35
|
+
trailingIconProps?: IconProps | null;
|
|
30
36
|
/**
|
|
31
|
-
*
|
|
37
|
+
* Accessible label for the clear button.
|
|
32
38
|
*/
|
|
33
|
-
|
|
39
|
+
clearLabel?: string;
|
|
34
40
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as SelectStories from './Select.stories.svelte';
|
|
3
|
+
|
|
4
|
+
<Meta of={SelectStories} />
|
|
5
|
+
|
|
6
|
+
<Title />
|
|
7
|
+
|
|
8
|
+
<Subtitle>Select lets users choose one option from a list.</Subtitle>
|
|
9
|
+
|
|
10
|
+
[M3 spec (menus)](https://m3.material.io/components/menus/specs) ·
|
|
11
|
+
`import { Select } from '@noxlovette/material';`
|
|
12
|
+
|
|
13
|
+
<Canvas of={SelectStories.Playground} />
|
|
14
|
+
|
|
15
|
+
<Controls of={SelectStories.Playground} />
|
|
16
|
+
|
|
17
|
+
## Options
|
|
18
|
+
|
|
19
|
+
M3 specifies dropdown selection as part of menus, so `Select` pairs a text-field-style trigger
|
|
20
|
+
with a menu panel. The panel is built entirely from the `options` array; it takes no children.
|
|
21
|
+
|
|
22
|
+
Each entry is either an item (bits-ui's `Select.ItemProps`: `value`, `label`, `disabled`…) or a
|
|
23
|
+
group, `{ type: 'group', heading?, items }`, which renders a labelled section:
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import { Select, type SelectOption } from '@noxlovette/material';
|
|
28
|
+
|
|
29
|
+
let fruit = $state<string | undefined>();
|
|
30
|
+
const options: SelectOption[] = [
|
|
31
|
+
{ value: 'apple', label: 'Apple' },
|
|
32
|
+
{ value: 'banana', label: 'Banana' }
|
|
33
|
+
];
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<Select type="single" placeholder="Choose a fruit" {options} bind:value={fruit} />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<Canvas of={SelectStories.GroupedOptions} />
|
|
40
|
+
|
|
41
|
+
<Canvas of={SelectStories.States} />
|
|
42
|
+
|
|
43
|
+
## Styled primitives
|
|
44
|
+
|
|
45
|
+
`SelectItem`, `SelectGroup`, `SelectLabel` and `SelectSeparator` carry the same styling. Use them
|
|
46
|
+
only when building your own dropdown directly on bits-ui's `Select.Root`; `Select` itself doesn't
|
|
47
|
+
accept them.
|
|
48
|
+
|
|
49
|
+
## Accessibility
|
|
50
|
+
|
|
51
|
+
- **Keyboard.** Arrow keys move through options, Enter and Space select, and Escape closes.
|
|
52
|
+
- **Selection** shows a check icon as well as a color.
|
|
53
|
+
- **Disabled options** are skipped by keyboard navigation.
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
|
|
58
58
|
<Story name="Playground">
|
|
59
59
|
{#snippet template(args)}
|
|
60
|
-
<div class="max-w-sm
|
|
60
|
+
<div class="p-spacing-300 max-w-sm">
|
|
61
61
|
<Select {...args} />
|
|
62
62
|
</div>
|
|
63
63
|
{/snippet}
|
|
64
64
|
</Story>
|
|
65
65
|
|
|
66
66
|
<Story name="Grouped Options" asChild>
|
|
67
|
-
<div class="max-w-sm
|
|
67
|
+
<div class="p-spacing-300 max-w-sm">
|
|
68
68
|
<Select type="single" placeholder="Choose a fruit" options={groupedOptions} />
|
|
69
69
|
</div>
|
|
70
70
|
</Story>
|
|
71
71
|
|
|
72
72
|
<Story name="With Leading Icon" asChild>
|
|
73
|
-
<div class="max-w-sm
|
|
73
|
+
<div class="p-spacing-300 max-w-sm">
|
|
74
74
|
<Select
|
|
75
75
|
type="single"
|
|
76
76
|
placeholder="Choose a fruit"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
</Story>
|
|
82
82
|
|
|
83
83
|
<Story name="States" asChild>
|
|
84
|
-
<div class="flex max-w-sm flex-col
|
|
84
|
+
<div class="gap-spacing-300 p-spacing-300 flex max-w-sm flex-col">
|
|
85
85
|
<Select type="single" placeholder="Default" options={fruitOptions} />
|
|
86
86
|
<Select type="single" placeholder="Error" options={fruitOptions} error value="apple" />
|
|
87
87
|
<Select type="single" placeholder="Disabled" options={fruitOptions} disabled />
|
|
@@ -65,13 +65,13 @@ Powered by bits-ui for accessibility and behavior.
|
|
|
65
65
|
|
|
66
66
|
<Select.Portal disabled={portalDisabled}>
|
|
67
67
|
<Select.Content
|
|
68
|
-
class={cls.content({ class: clsx('z-
|
|
68
|
+
class={cls.content({ class: clsx('z-layer-popup', contentProps?.class) })}
|
|
69
69
|
sideOffset={4}
|
|
70
70
|
align="start"
|
|
71
71
|
{...contentProps}
|
|
72
72
|
>
|
|
73
73
|
{#snippet child({ wrapperProps, props, open })}
|
|
74
|
-
<div {...wrapperProps} class={clsx('z-
|
|
74
|
+
<div {...wrapperProps} class={clsx('z-layer-popup', wrapperProps.class as any)}>
|
|
75
75
|
<div
|
|
76
76
|
{...props}
|
|
77
77
|
class={clsx('relative flex flex-col outline-none', props.class as any)}
|
|
@@ -94,7 +94,11 @@ Powered by bits-ui for accessibility and behavior.
|
|
|
94
94
|
{#snippet children({ selected })}
|
|
95
95
|
<span class="flex-1 truncate">{innerItem.label}</span>
|
|
96
96
|
{#if selected}
|
|
97
|
-
<Icon
|
|
97
|
+
<Icon
|
|
98
|
+
aria-hidden="true"
|
|
99
|
+
name="check"
|
|
100
|
+
class="size-spacing-250 shrink-0"
|
|
101
|
+
/>
|
|
98
102
|
{/if}
|
|
99
103
|
{/snippet}
|
|
100
104
|
</Select.Item>
|
|
@@ -106,7 +110,11 @@ Powered by bits-ui for accessibility and behavior.
|
|
|
106
110
|
{#snippet children({ selected })}
|
|
107
111
|
<span class="flex-1 truncate">{item.label}</span>
|
|
108
112
|
{#if selected}
|
|
109
|
-
<Icon
|
|
113
|
+
<Icon
|
|
114
|
+
aria-hidden="true"
|
|
115
|
+
name="check"
|
|
116
|
+
class="size-spacing-250 shrink-0"
|
|
117
|
+
/>
|
|
110
118
|
{/if}
|
|
111
119
|
{/snippet}
|
|
112
120
|
</Select.Item>
|