opui-css 5.1.2 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +4 -5
- package/components/AGENTS.md +12 -13
- package/components/Accordion/Accordion.astro +5 -9
- package/components/Accordion/Accordion.vue +38 -0
- package/components/Accordion/types.astro.ts +4 -0
- package/components/Accordion/types.d.vue.ts +15 -0
- package/components/Accordion/types.solid.ts +6 -0
- package/components/Accordion/types.svelte.ts +7 -0
- package/components/Accordion/types.ts +10 -0
- package/components/Anchor/Anchor.astro +1 -7
- package/components/Anchor/Anchor.vue +41 -0
- package/components/Anchor/types.astro.ts +4 -0
- package/components/Anchor/types.d.vue.ts +10 -0
- package/components/Anchor/types.solid.ts +6 -0
- package/components/Anchor/types.svelte.ts +7 -0
- package/components/Anchor/types.ts +9 -0
- package/components/Avatar/Avatar.astro +4 -13
- package/components/Avatar/Avatar.vue +24 -0
- package/components/Avatar/types.astro.ts +10 -0
- package/components/Avatar/types.d.vue.ts +11 -0
- package/components/Avatar/types.solid.ts +11 -0
- package/components/Avatar/types.svelte.ts +12 -0
- package/components/Avatar/types.ts +29 -0
- package/components/Badge/Badge.astro +3 -11
- package/components/Badge/Badge.vue +39 -0
- package/components/Badge/types.astro.ts +4 -0
- package/components/Badge/types.d.vue.ts +10 -0
- package/components/Badge/types.solid.ts +4 -0
- package/components/Badge/types.svelte.ts +4 -0
- package/components/Badge/types.ts +8 -0
- package/components/Button/Button.astro +18 -27
- package/components/Button/Button.vue +27 -0
- package/components/Button/types.astro.ts +6 -0
- package/components/Button/types.d.vue.ts +10 -0
- package/components/Button/types.solid.ts +8 -0
- package/components/Button/types.svelte.ts +6 -0
- package/components/Button/types.ts +16 -0
- package/components/ButtonGroup/ButtonGroup.astro +1 -8
- package/components/ButtonGroup/ButtonGroup.vue +22 -0
- package/components/ButtonGroup/types.astro.ts +4 -0
- package/components/ButtonGroup/types.d.vue.ts +10 -0
- package/components/ButtonGroup/types.solid.ts +4 -0
- package/components/ButtonGroup/types.svelte.ts +4 -0
- package/components/ButtonGroup/types.ts +7 -0
- package/components/Callout/Callout.astro +10 -9
- package/components/Callout/Callout.vue +63 -0
- package/components/Callout/types.astro.ts +4 -0
- package/components/Callout/types.d.vue.ts +10 -0
- package/components/Callout/types.solid.ts +6 -0
- package/components/Callout/types.svelte.ts +7 -0
- package/components/Callout/types.ts +10 -0
- package/components/Card/Card.astro +1 -5
- package/components/Card/Card.vue +28 -0
- package/components/Card/types.astro.ts +4 -0
- package/components/Card/types.d.vue.ts +10 -0
- package/components/Card/types.solid.ts +6 -0
- package/components/Card/types.svelte.ts +7 -0
- package/components/Card/types.ts +11 -0
- package/components/Checkbox/Checkbox.astro +6 -36
- package/components/Checkbox/Checkbox.vue +43 -0
- package/components/Checkbox/CheckboxInput.astro +2 -18
- package/components/Checkbox/CheckboxInput.vue +32 -0
- package/components/Checkbox/types.astro.ts +8 -0
- package/components/Checkbox/types.d.vue.ts +11 -0
- package/components/Checkbox/types.solid.ts +9 -0
- package/components/Checkbox/types.svelte.ts +12 -0
- package/components/Checkbox/types.ts +16 -0
- package/components/Chip/Chip.astro +6 -12
- package/components/Chip/Chip.vue +37 -0
- package/components/Chip/types.astro.ts +9 -0
- package/components/Chip/types.d.vue.ts +10 -0
- package/components/Chip/types.solid.ts +10 -0
- package/components/Chip/types.svelte.ts +14 -0
- package/components/Chip/types.ts +13 -0
- package/components/ClassicSelect/ClassicSelect.astro +5 -28
- package/components/ClassicSelect/ClassicSelect.vue +54 -0
- package/components/ClassicSelect/types.astro.ts +8 -0
- package/components/ClassicSelect/types.d.vue.ts +10 -0
- package/components/ClassicSelect/types.solid.ts +5 -0
- package/components/ClassicSelect/types.svelte.ts +5 -0
- package/components/ClassicSelect/types.ts +15 -0
- package/components/DescriptionList/Description.astro +1 -4
- package/components/DescriptionList/Description.vue +12 -0
- package/components/DescriptionList/DescriptionList.astro +1 -5
- package/components/DescriptionList/DescriptionList.vue +23 -0
- package/components/DescriptionList/Item.astro +1 -4
- package/components/DescriptionList/Item.vue +12 -0
- package/components/DescriptionList/Term.astro +1 -4
- package/components/DescriptionList/Term.vue +12 -0
- package/components/DescriptionList/types.astro.ts +10 -0
- package/components/DescriptionList/types.d.vue.ts +10 -0
- package/components/DescriptionList/types.solid.ts +4 -0
- package/components/DescriptionList/types.svelte.ts +4 -0
- package/components/DescriptionList/types.ts +3 -0
- package/components/Dialog/Dialog.astro +1 -6
- package/components/Dialog/Dialog.vue +35 -0
- package/components/Dialog/types.astro.ts +4 -0
- package/components/Dialog/types.d.vue.ts +10 -0
- package/components/Dialog/types.solid.ts +8 -0
- package/components/Dialog/types.svelte.ts +7 -0
- package/components/Dialog/types.ts +10 -0
- package/components/Divider/Divider.astro +1 -6
- package/components/Divider/Divider.vue +12 -0
- package/components/Divider/types.astro.ts +4 -0
- package/components/Divider/types.d.vue.ts +6 -0
- package/components/Divider/types.solid.ts +4 -0
- package/components/Divider/types.svelte.ts +4 -0
- package/components/Divider/types.ts +3 -0
- package/components/Drawer/Drawer.astro +10 -12
- package/components/Drawer/Drawer.vue +46 -0
- package/components/Drawer/DrawerFooter.astro +1 -4
- package/components/Drawer/DrawerFooter.vue +16 -0
- package/components/Drawer/DrawerHeader.astro +1 -5
- package/components/Drawer/DrawerHeader.vue +36 -0
- package/components/Drawer/types.astro.ts +8 -0
- package/components/Drawer/types.d.vue.ts +31 -0
- package/components/Drawer/types.solid.ts +12 -0
- package/components/Drawer/types.svelte.ts +15 -0
- package/components/Drawer/types.ts +20 -0
- package/components/FieldDescription/FieldDescription.astro +1 -5
- package/components/FieldDescription/FieldDescription.vue +12 -0
- package/components/FieldDescription/types.astro.ts +4 -0
- package/components/FieldDescription/types.d.vue.ts +10 -0
- package/components/FieldDescription/types.solid.ts +5 -0
- package/components/FieldDescription/types.svelte.ts +4 -0
- package/components/FieldDescription/types.ts +1 -0
- package/components/FieldGroup/FieldGroup.astro +1 -8
- package/components/FieldGroup/FieldGroup.vue +25 -0
- package/components/FieldGroup/types.astro.ts +4 -0
- package/components/FieldGroup/types.d.vue.ts +12 -0
- package/components/FieldGroup/types.solid.ts +5 -0
- package/components/FieldGroup/types.svelte.ts +4 -0
- package/components/FieldGroup/types.ts +4 -0
- package/components/FieldLegend/FieldLegend.astro +4 -8
- package/components/FieldLegend/FieldLegend.vue +18 -0
- package/components/FieldLegend/types.astro.ts +6 -0
- package/components/FieldLegend/types.d.vue.ts +11 -0
- package/components/FieldLegend/types.solid.ts +5 -0
- package/components/FieldLegend/types.svelte.ts +6 -0
- package/components/FieldLegend/types.ts +1 -0
- package/components/FieldSet/FieldSet.astro +1 -5
- package/components/FieldSet/FieldSet.vue +18 -0
- package/components/FieldSet/types.astro.ts +6 -0
- package/components/FieldSet/types.d.vue.ts +11 -0
- package/components/FieldSet/types.solid.ts +5 -0
- package/components/FieldSet/types.svelte.ts +8 -0
- package/components/FieldSet/types.ts +5 -0
- package/components/Form/Form.astro +1 -6
- package/components/Form/Form.vue +14 -0
- package/components/Form/types.astro.ts +6 -0
- package/components/Form/types.d.vue.ts +11 -0
- package/components/Form/types.solid.ts +5 -0
- package/components/Form/types.svelte.ts +7 -0
- package/components/Form/types.ts +1 -0
- package/components/IconButton/IconButton.astro +18 -20
- package/components/IconButton/IconButton.vue +24 -0
- package/components/IconButton/types.astro.ts +6 -0
- package/components/IconButton/types.d.vue.ts +10 -0
- package/components/IconButton/types.solid.ts +8 -0
- package/components/IconButton/types.svelte.ts +6 -0
- package/components/IconButton/types.ts +16 -0
- package/components/List/List.astro +1 -8
- package/components/List/List.vue +28 -0
- package/components/List/types.astro.ts +4 -0
- package/components/List/types.d.vue.ts +10 -0
- package/components/List/types.solid.ts +4 -0
- package/components/List/types.svelte.ts +4 -0
- package/components/List/types.ts +7 -0
- package/components/ListItem/ListItem.astro +3 -13
- package/components/ListItem/ListItem.vue +98 -0
- package/components/ListItem/types.astro.ts +10 -0
- package/components/ListItem/types.d.vue.ts +10 -0
- package/components/ListItem/types.solid.ts +12 -0
- package/components/ListItem/types.svelte.ts +14 -0
- package/components/ListItem/types.ts +32 -0
- package/components/Progress/Progress.astro +1 -11
- package/components/Progress/Progress.vue +34 -0
- package/components/Progress/types.astro.ts +4 -0
- package/components/Progress/types.d.vue.ts +10 -0
- package/components/Progress/types.solid.ts +4 -0
- package/components/Progress/types.svelte.ts +4 -0
- package/components/Progress/types.ts +10 -0
- package/components/Radio/Radio.astro +6 -32
- package/components/Radio/Radio.vue +41 -0
- package/components/Radio/RadioInput.astro +3 -20
- package/components/Radio/RadioInput.vue +14 -0
- package/components/Radio/types.astro.ts +6 -0
- package/components/Radio/types.d.vue.ts +11 -0
- package/components/Radio/types.solid.ts +9 -0
- package/components/Radio/types.svelte.ts +12 -0
- package/components/Radio/types.ts +12 -0
- package/components/Range/Range.astro +23 -31
- package/components/Range/Range.vue +85 -0
- package/components/Range/types.astro.ts +6 -0
- package/components/Range/types.d.vue.ts +14 -0
- package/components/Range/types.solid.ts +6 -0
- package/components/Range/types.svelte.ts +9 -0
- package/components/Range/types.ts +25 -0
- package/components/Select/Select.astro +41 -39
- package/components/Select/Select.vue +85 -0
- package/components/Select/types.astro.ts +4 -0
- package/components/Select/types.d.vue.ts +17 -0
- package/components/Select/types.solid.ts +6 -0
- package/components/Select/types.svelte.ts +7 -0
- package/components/Select/types.ts +27 -0
- package/components/Switch/Switch.astro +14 -39
- package/components/Switch/Switch.vue +63 -0
- package/components/Switch/SwitchInput.astro +3 -21
- package/components/Switch/SwitchInput.vue +14 -0
- package/components/Switch/types.astro.ts +5 -0
- package/components/Switch/types.d.vue.ts +13 -0
- package/components/Switch/types.solid.ts +9 -0
- package/components/Switch/types.svelte.ts +9 -0
- package/components/Switch/types.ts +16 -0
- package/components/Table/Body.astro +1 -3
- package/components/Table/Body.vue +5 -0
- package/components/Table/Cell.astro +1 -3
- package/components/Table/Cell.vue +5 -0
- package/components/Table/Column.astro +1 -4
- package/components/Table/Column.vue +19 -0
- package/components/Table/ColumnGroup.astro +1 -3
- package/components/Table/ColumnGroup.vue +5 -0
- package/components/Table/Head.astro +1 -3
- package/components/Table/Head.vue +5 -0
- package/components/Table/HeaderCell.astro +1 -3
- package/components/Table/HeaderCell.vue +5 -0
- package/components/Table/Row.astro +1 -3
- package/components/Table/Row.vue +5 -0
- package/components/Table/Table.astro +1 -5
- package/components/Table/Table.vue +19 -0
- package/components/Table/types.astro.ts +16 -0
- package/components/Table/types.d.vue.ts +10 -0
- package/components/Table/types.solid.ts +8 -0
- package/components/Table/types.svelte.ts +11 -0
- package/components/Table/types.ts +9 -0
- package/components/Tabs/Tabs.astro +1 -5
- package/components/Tabs/Tabs.vue +20 -0
- package/components/Tabs/TabsItem.astro +1 -8
- package/components/Tabs/TabsItem.vue +39 -0
- package/components/Tabs/TabsPanel.astro +1 -6
- package/components/Tabs/TabsPanel.vue +31 -0
- package/components/Tabs/TabsTab.astro +1 -5
- package/components/Tabs/TabsTab.vue +24 -0
- package/components/Tabs/types.astro.ts +11 -0
- package/components/Tabs/types.d.vue.ts +31 -0
- package/components/Tabs/types.solid.ts +12 -0
- package/components/Tabs/types.svelte.ts +10 -0
- package/components/Tabs/types.ts +19 -0
- package/components/TextField/TextField.astro +45 -49
- package/components/TextField/TextField.vue +74 -0
- package/components/TextField/types.astro.ts +17 -0
- package/components/TextField/types.d.vue.ts +20 -0
- package/components/TextField/types.solid.ts +22 -0
- package/components/TextField/types.svelte.ts +22 -0
- package/components/TextField/types.ts +35 -0
- package/components/Textarea/Textarea.astro +50 -38
- package/components/Textarea/Textarea.vue +64 -0
- package/components/Textarea/types.astro.ts +10 -0
- package/components/Textarea/types.d.vue.ts +19 -0
- package/components/Textarea/types.solid.ts +6 -0
- package/components/Textarea/types.svelte.ts +21 -0
- package/components/Textarea/types.ts +33 -0
- package/components/Toast/Toast.vue +48 -0
- package/components/ToggleButton/ToggleButton.astro +1 -11
- package/components/ToggleButton/ToggleButton.vue +41 -0
- package/components/ToggleButton/types.astro.ts +4 -0
- package/components/ToggleButton/types.d.vue.ts +10 -0
- package/components/ToggleButton/types.solid.ts +7 -0
- package/components/ToggleButton/types.svelte.ts +7 -0
- package/components/ToggleButton/types.ts +10 -0
- package/components/ToggleGroup/ToggleGroup.astro +1 -8
- package/components/ToggleGroup/ToggleGroup.vue +36 -0
- package/components/ToggleGroup/types.astro.ts +4 -0
- package/components/ToggleGroup/types.d.vue.ts +15 -0
- package/components/ToggleGroup/types.solid.ts +4 -0
- package/components/ToggleGroup/types.svelte.ts +9 -0
- package/components/ToggleGroup/types.ts +15 -0
- package/components/Tooltip/Tooltip.astro +2 -9
- package/components/Tooltip/Tooltip.vue +22 -0
- package/components/Tooltip/types.astro.ts +4 -0
- package/components/Tooltip/types.d.vue.ts +10 -0
- package/components/Tooltip/types.solid.ts +6 -0
- package/components/Tooltip/types.svelte.ts +7 -0
- package/components/Tooltip/types.ts +11 -0
- package/css/theme.css +0 -1
- package/dist/opui.css +0 -1
- package/dist/opui.css.map +1 -1
- package/package.json +16 -7
- package/vue/index.ts +54 -0
|
@@ -1,27 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
type Props
|
|
3
|
-
[key: string]: any
|
|
4
|
-
class?: string
|
|
5
|
-
disabled?: boolean
|
|
6
|
-
endText?: string
|
|
7
|
-
id?: string
|
|
8
|
-
label?: string
|
|
9
|
-
max?: number | string
|
|
10
|
-
min?: number | string
|
|
11
|
-
name?: string
|
|
12
|
-
spread?: boolean
|
|
13
|
-
startText?: string
|
|
14
|
-
step?: number | string
|
|
15
|
-
value?: number | string
|
|
16
|
-
valueSuffix?: string
|
|
17
|
-
variant?: "filled" | "default" | "tonal"
|
|
18
|
-
} & (
|
|
19
|
-
| { list?: never; options?: never }
|
|
20
|
-
| {
|
|
21
|
-
list: string
|
|
22
|
-
options: (string | number | { value: string | number; label?: string })[]
|
|
23
|
-
}
|
|
24
|
-
)
|
|
2
|
+
import type { RangeProps as Props } from "./types.astro"
|
|
25
3
|
|
|
26
4
|
export const title = "Range"
|
|
27
5
|
|
|
@@ -57,14 +35,24 @@ const labelId = hasLabel ? $id("range-label") : undefined
|
|
|
57
35
|
const startTextId = hasStartText ? $id("range-start") : undefined
|
|
58
36
|
const endTextId = hasEndText ? $id("range-end") : undefined
|
|
59
37
|
|
|
60
|
-
const describedBy =
|
|
38
|
+
const describedBy =
|
|
39
|
+
[startTextId, endTextId].filter(Boolean).join(" ") || undefined
|
|
61
40
|
---
|
|
62
41
|
|
|
63
|
-
<label
|
|
42
|
+
<label
|
|
43
|
+
class:list={[
|
|
44
|
+
"ui-range",
|
|
45
|
+
variant && `ui-${variant}`,
|
|
46
|
+
{ "ui-spread": spread },
|
|
47
|
+
className,
|
|
48
|
+
]}
|
|
49
|
+
>
|
|
64
50
|
{
|
|
65
51
|
hasLabel && (
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
<span class="ui-label" id={labelId}>
|
|
53
|
+
{label}
|
|
54
|
+
<slot />
|
|
55
|
+
</span>
|
|
68
56
|
)
|
|
69
57
|
}
|
|
70
58
|
{
|
|
@@ -77,7 +65,8 @@ const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefi
|
|
|
77
65
|
{
|
|
78
66
|
hasStartText && (
|
|
79
67
|
<span class="ui-start-text" id={startTextId}>
|
|
80
|
-
{startText}
|
|
68
|
+
{startText}
|
|
69
|
+
<slot name="start-text" />
|
|
81
70
|
</span>
|
|
82
71
|
)
|
|
83
72
|
}
|
|
@@ -103,7 +92,7 @@ const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefi
|
|
|
103
92
|
<option value={option.value} label={option.label} />
|
|
104
93
|
) : (
|
|
105
94
|
<option value={option} />
|
|
106
|
-
)
|
|
95
|
+
),
|
|
107
96
|
)}
|
|
108
97
|
<slot name="datalist" />
|
|
109
98
|
</datalist>
|
|
@@ -112,7 +101,8 @@ const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefi
|
|
|
112
101
|
{
|
|
113
102
|
hasEndText && (
|
|
114
103
|
<span class="ui-end-text" id={endTextId}>
|
|
115
|
-
{endText}
|
|
104
|
+
{endText}
|
|
105
|
+
<slot name="end-text" />
|
|
116
106
|
</span>
|
|
117
107
|
)
|
|
118
108
|
}
|
|
@@ -124,7 +114,9 @@ const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefi
|
|
|
124
114
|
// without a value display.
|
|
125
115
|
for (const range of document.querySelectorAll<HTMLElement>(".ui-range")) {
|
|
126
116
|
const input = range.querySelector<HTMLInputElement>('input[type="range"]')
|
|
127
|
-
const output = range.querySelector<HTMLOutputElement>(
|
|
117
|
+
const output = range.querySelector<HTMLOutputElement>(
|
|
118
|
+
":scope > output.ui-value",
|
|
119
|
+
)
|
|
128
120
|
if (!input || !output) continue
|
|
129
121
|
const suffix = output.dataset.suffix ?? ""
|
|
130
122
|
const update = () => {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { RangeProps, Slots } from "./types.d.vue"
|
|
3
|
+
import { useId } from "vue"
|
|
4
|
+
|
|
5
|
+
defineOptions({
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const props = defineProps<RangeProps>()
|
|
10
|
+
defineSlots<Slots>()
|
|
11
|
+
const modelValue = defineModel<number | string>()
|
|
12
|
+
|
|
13
|
+
const inputId = props.id || useId()
|
|
14
|
+
const labelId = useId()
|
|
15
|
+
const startTextId = useId()
|
|
16
|
+
const endTextId = useId()
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<label
|
|
21
|
+
:class="[
|
|
22
|
+
'ui-range',
|
|
23
|
+
props.variant && `ui-${props.variant}`,
|
|
24
|
+
{ 'ui-spread': props.spread },
|
|
25
|
+
props.class,
|
|
26
|
+
]"
|
|
27
|
+
>
|
|
28
|
+
<span v-if="props.label || $slots.default" class="ui-label" :id="labelId">
|
|
29
|
+
<slot>{{ props.label }}</slot>
|
|
30
|
+
</span>
|
|
31
|
+
<output
|
|
32
|
+
v-if="props.valueSuffix !== undefined || $slots.value"
|
|
33
|
+
class="ui-value"
|
|
34
|
+
:for="inputId"
|
|
35
|
+
:data-suffix="props.valueSuffix"
|
|
36
|
+
>
|
|
37
|
+
<slot name="value">{{ modelValue ?? props.value }}</slot>
|
|
38
|
+
</output>
|
|
39
|
+
<span
|
|
40
|
+
v-if="props.startText || $slots['start-text']"
|
|
41
|
+
class="ui-start-text"
|
|
42
|
+
:id="startTextId"
|
|
43
|
+
>
|
|
44
|
+
<slot name="start-text">{{ props.startText }}</slot>
|
|
45
|
+
</span>
|
|
46
|
+
|
|
47
|
+
<input
|
|
48
|
+
:aria-describedby="
|
|
49
|
+
[
|
|
50
|
+
props.startText || $slots['start-text'] ? startTextId : undefined,
|
|
51
|
+
props.endText || $slots['end-text'] ? endTextId : undefined,
|
|
52
|
+
]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join(' ') || undefined
|
|
55
|
+
"
|
|
56
|
+
:aria-labelledby="labelId"
|
|
57
|
+
:id="inputId"
|
|
58
|
+
:list="props.list"
|
|
59
|
+
type="range"
|
|
60
|
+
v-bind="$attrs"
|
|
61
|
+
v-model="modelValue"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<datalist v-if="props.options || $slots.datalist" :id="props.list">
|
|
65
|
+
<template
|
|
66
|
+
v-for="option in props.options"
|
|
67
|
+
:key="typeof option === 'object' ? option.value : option"
|
|
68
|
+
>
|
|
69
|
+
<option
|
|
70
|
+
:value="typeof option === 'object' ? option.value : option"
|
|
71
|
+
:label="typeof option === 'object' ? option.label : undefined"
|
|
72
|
+
/>
|
|
73
|
+
</template>
|
|
74
|
+
<slot name="datalist"></slot>
|
|
75
|
+
</datalist>
|
|
76
|
+
|
|
77
|
+
<span
|
|
78
|
+
v-if="props.endText || $slots['end-text']"
|
|
79
|
+
class="ui-end-text"
|
|
80
|
+
:id="endTextId"
|
|
81
|
+
>
|
|
82
|
+
<slot name="end-text">{{ props.endText }}</slot>
|
|
83
|
+
</span>
|
|
84
|
+
</label>
|
|
85
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes, Slot } from "vue"
|
|
2
|
+
import type { RangeProps as BaseRangeProps } from "./types"
|
|
3
|
+
|
|
4
|
+
export type RangeProps = BaseRangeProps & {
|
|
5
|
+
class?: HTMLAttributes["class"]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Slots = {
|
|
9
|
+
datalist?: Slot
|
|
10
|
+
default?: Slot
|
|
11
|
+
"end-text"?: Slot
|
|
12
|
+
"start-text"?: Slot
|
|
13
|
+
value?: Slot
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Base from "./types"
|
|
2
|
+
import type { SvelteHTMLElements } from "svelte/elements"
|
|
3
|
+
import type { Snippet } from "svelte"
|
|
4
|
+
|
|
5
|
+
type Snippets = Base.RangeSlots<Snippet>
|
|
6
|
+
|
|
7
|
+
export type RangeProps = Omit<Base.RangeProps, keyof Snippets> &
|
|
8
|
+
Snippets &
|
|
9
|
+
SvelteHTMLElements["input"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type RangeProps = {
|
|
2
|
+
[key: string]: any
|
|
3
|
+
endText?: string
|
|
4
|
+
id?: string
|
|
5
|
+
label?: string
|
|
6
|
+
spread?: boolean
|
|
7
|
+
startText?: string
|
|
8
|
+
value?: number | string
|
|
9
|
+
valueSuffix?: string
|
|
10
|
+
variant?: "filled" | "default" | "tonal"
|
|
11
|
+
} & (
|
|
12
|
+
| { list?: never; options?: never }
|
|
13
|
+
| {
|
|
14
|
+
list: string
|
|
15
|
+
options: (string | number | { value: string | number; label?: string })[]
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
export type RangeSlots<S> = {
|
|
20
|
+
datalist?: S
|
|
21
|
+
endText?: string | S
|
|
22
|
+
startText?: string | S
|
|
23
|
+
valueSuffix?: string | S
|
|
24
|
+
valueText?: S
|
|
25
|
+
}
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
type
|
|
3
|
-
text: string
|
|
4
|
-
value: any
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
[key: string]: any
|
|
9
|
-
class?: string
|
|
10
|
-
description?: string
|
|
11
|
-
disabled?: boolean
|
|
12
|
-
error?: boolean
|
|
13
|
-
dense?: boolean
|
|
14
|
-
id?: string
|
|
15
|
-
items?: Item[]
|
|
16
|
-
label?: string
|
|
17
|
-
name?: string
|
|
18
|
-
spread?: boolean
|
|
19
|
-
required?: boolean
|
|
20
|
-
size?: "small"
|
|
21
|
-
endText?: string
|
|
22
|
-
value?: any
|
|
23
|
-
variant?: "outlined" | "filled"
|
|
24
|
-
}
|
|
2
|
+
import type { Props } from "./types.astro"
|
|
25
3
|
|
|
26
4
|
export const title = "Select"
|
|
27
5
|
|
|
28
6
|
const {
|
|
29
7
|
class: className,
|
|
30
8
|
description,
|
|
31
|
-
disabled,
|
|
32
9
|
error,
|
|
33
10
|
dense,
|
|
34
11
|
id,
|
|
@@ -36,10 +13,8 @@ const {
|
|
|
36
13
|
label,
|
|
37
14
|
name,
|
|
38
15
|
spread,
|
|
39
|
-
required,
|
|
40
16
|
size,
|
|
41
17
|
endText,
|
|
42
|
-
value,
|
|
43
18
|
variant = "outlined",
|
|
44
19
|
...rest
|
|
45
20
|
} = Astro.props
|
|
@@ -64,24 +39,25 @@ const labelId = $id("select-label")
|
|
|
64
39
|
>
|
|
65
40
|
{
|
|
66
41
|
(label || Astro.slots.has("label")) && (
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
<span class="ui-label" id={labelId}>
|
|
43
|
+
{label}
|
|
44
|
+
<slot name="label" />
|
|
45
|
+
</span>
|
|
69
46
|
)
|
|
70
47
|
}
|
|
71
48
|
{
|
|
72
49
|
(description || Astro.slots.has("description")) && (
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
<span class="ui-start-text">
|
|
51
|
+
{description}
|
|
52
|
+
<slot name="description" />
|
|
53
|
+
</span>
|
|
75
54
|
)
|
|
76
55
|
}
|
|
77
56
|
<span class="ui-field">
|
|
78
57
|
<select
|
|
79
58
|
aria-labelledby={label ? labelId : undefined}
|
|
80
|
-
disabled={disabled}
|
|
81
59
|
id={selectId}
|
|
82
60
|
name={fieldName}
|
|
83
|
-
required={required}
|
|
84
|
-
value={value}
|
|
85
61
|
{...rest}
|
|
86
62
|
>
|
|
87
63
|
<button>
|
|
@@ -92,15 +68,41 @@ const labelId = $id("select-label")
|
|
|
92
68
|
<slot />
|
|
93
69
|
</div>
|
|
94
70
|
</select>
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
{
|
|
72
|
+
Astro.slots.has("prefix") && (
|
|
73
|
+
<span class="ui-prefix">
|
|
74
|
+
<slot name="prefix" />
|
|
75
|
+
</span>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
{
|
|
79
|
+
Astro.slots.has("suffix") && (
|
|
80
|
+
<span class="ui-suffix">
|
|
81
|
+
<slot name="suffix" />
|
|
82
|
+
</span>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
Astro.slots.has("header") && (
|
|
87
|
+
<span class="ui-header">
|
|
88
|
+
<slot name="header" />
|
|
89
|
+
</span>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
{
|
|
93
|
+
Astro.slots.has("footer") && (
|
|
94
|
+
<span class="ui-footer">
|
|
95
|
+
<slot name="footer" />
|
|
96
|
+
</span>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
99
|
</span>
|
|
100
100
|
{
|
|
101
101
|
(endText || Astro.slots.has("end-text")) && (
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
<span id={$id("end-text")} class="ui-end-text">
|
|
103
|
+
{endText}
|
|
104
|
+
<slot name="end-text" />
|
|
105
|
+
</span>
|
|
104
106
|
)
|
|
105
107
|
}
|
|
106
108
|
</label>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useId } from "vue"
|
|
3
|
+
import type { Props, Slots } from "./types.d.vue"
|
|
4
|
+
|
|
5
|
+
defineOptions({
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
10
|
+
items: () => [],
|
|
11
|
+
variant: "outlined",
|
|
12
|
+
})
|
|
13
|
+
defineSlots<Slots>()
|
|
14
|
+
const modelValue = defineModel<string | number | (string | number)[]>()
|
|
15
|
+
|
|
16
|
+
const selectId = props.id || useId()
|
|
17
|
+
const labelId = useId()
|
|
18
|
+
const endTextId = useId()
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<label
|
|
23
|
+
:class="[
|
|
24
|
+
'ui-select',
|
|
25
|
+
props.size && `ui-${props.size}`,
|
|
26
|
+
{
|
|
27
|
+
'ui-filled': props.variant === 'filled',
|
|
28
|
+
'ui-spread': props.spread,
|
|
29
|
+
},
|
|
30
|
+
props.class,
|
|
31
|
+
]"
|
|
32
|
+
:data-invalid="props.error || undefined"
|
|
33
|
+
>
|
|
34
|
+
<span v-if="props.label || $slots.label" class="ui-label" :id="labelId">
|
|
35
|
+
<slot name="label">{{ props.label }}</slot>
|
|
36
|
+
</span>
|
|
37
|
+
|
|
38
|
+
<span v-if="props.description || $slots.description" class="ui-start-text">
|
|
39
|
+
<slot name="description">{{ props.description }}</slot>
|
|
40
|
+
</span>
|
|
41
|
+
|
|
42
|
+
<span class="ui-field">
|
|
43
|
+
<select
|
|
44
|
+
:aria-labelledby="props.label ? labelId : undefined"
|
|
45
|
+
:id="selectId"
|
|
46
|
+
v-bind="$attrs"
|
|
47
|
+
v-model="modelValue"
|
|
48
|
+
>
|
|
49
|
+
<button v-pre>
|
|
50
|
+
<selectedcontent></selectedcontent>
|
|
51
|
+
</button>
|
|
52
|
+
<div :class="['ui-list', { 'ui-dense': props.dense }]">
|
|
53
|
+
<option
|
|
54
|
+
v-for="item in props.items"
|
|
55
|
+
:key="item.value"
|
|
56
|
+
:value="item.value"
|
|
57
|
+
>
|
|
58
|
+
{{ item.text }}
|
|
59
|
+
</option>
|
|
60
|
+
<slot></slot>
|
|
61
|
+
</div>
|
|
62
|
+
</select>
|
|
63
|
+
<span class="ui-prefix" v-if="$slots.prefix"
|
|
64
|
+
><slot name="prefix"></slot
|
|
65
|
+
></span>
|
|
66
|
+
<span class="ui-suffix" v-if="$slots.suffix"
|
|
67
|
+
><slot name="suffix"></slot
|
|
68
|
+
></span>
|
|
69
|
+
<span class="ui-header" v-if="$slots.header"
|
|
70
|
+
><slot name="header"></slot
|
|
71
|
+
></span>
|
|
72
|
+
<span class="ui-footer" v-if="$slots.footer"
|
|
73
|
+
><slot name="footer"></slot
|
|
74
|
+
></span>
|
|
75
|
+
</span>
|
|
76
|
+
|
|
77
|
+
<span
|
|
78
|
+
v-if="props.endText || $slots['end-text']"
|
|
79
|
+
:id="endTextId"
|
|
80
|
+
class="ui-end-text"
|
|
81
|
+
>
|
|
82
|
+
<slot name="end-text">{{ props.endText }}</slot>
|
|
83
|
+
</span>
|
|
84
|
+
</label>
|
|
85
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HTMLAttributes, Slot } from "vue"
|
|
2
|
+
import type { Props as BaseProps } from "./types"
|
|
3
|
+
|
|
4
|
+
export type Props = BaseProps & {
|
|
5
|
+
class?: HTMLAttributes["class"]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Slots = {
|
|
9
|
+
default?: Slot
|
|
10
|
+
description?: Slot
|
|
11
|
+
"end-text"?: Slot
|
|
12
|
+
footer?: Slot
|
|
13
|
+
header?: Slot
|
|
14
|
+
label?: Slot
|
|
15
|
+
prefix?: Slot
|
|
16
|
+
suffix?: Slot
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as Base from "./types"
|
|
2
|
+
import type { SvelteHTMLElements } from "svelte/elements"
|
|
3
|
+
import type { Snippet } from "svelte"
|
|
4
|
+
|
|
5
|
+
export type Props = Omit<Base.Props, keyof Base.Slots<Snippet>> &
|
|
6
|
+
Base.Slots<Snippet> &
|
|
7
|
+
Omit<SvelteHTMLElements["select"], "prefix" | "size">
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type Props = {
|
|
2
|
+
error?: boolean
|
|
3
|
+
dense?: boolean
|
|
4
|
+
description?: string
|
|
5
|
+
items?: Item[]
|
|
6
|
+
label?: string
|
|
7
|
+
spread?: boolean
|
|
8
|
+
size?: "small"
|
|
9
|
+
endText?: string
|
|
10
|
+
variant?: "outlined" | "filled"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type Item = {
|
|
14
|
+
text: string
|
|
15
|
+
value: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type Slots<S> = {
|
|
19
|
+
children?: S
|
|
20
|
+
description?: string | S
|
|
21
|
+
endText?: string | S
|
|
22
|
+
footer?: string | S
|
|
23
|
+
header?: string | S
|
|
24
|
+
label?: string | S
|
|
25
|
+
prefix?: string | S
|
|
26
|
+
suffix?: string | S
|
|
27
|
+
}
|
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
import SwitchInput from "./SwitchInput.astro"
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
[key: string]: any
|
|
6
|
-
checked?: boolean
|
|
7
|
-
class?: string
|
|
8
|
-
disabled?: boolean
|
|
9
|
-
error?: boolean
|
|
10
|
-
hideLabel?: boolean
|
|
11
|
-
id?: string
|
|
12
|
-
name?: string
|
|
13
|
-
required?: boolean
|
|
14
|
-
small?: boolean
|
|
15
|
-
spread?: boolean
|
|
16
|
-
stack?: boolean
|
|
17
|
-
value?: string
|
|
18
|
-
}
|
|
3
|
+
import type { SwitchProps as Props } from "./types.astro"
|
|
19
4
|
|
|
20
5
|
export const title = "Switch"
|
|
21
6
|
|
|
22
7
|
const {
|
|
23
|
-
checked,
|
|
24
8
|
class: className,
|
|
25
|
-
disabled,
|
|
26
9
|
error,
|
|
27
10
|
hideLabel,
|
|
28
|
-
id,
|
|
29
11
|
name,
|
|
30
|
-
required,
|
|
31
12
|
small,
|
|
32
13
|
spread,
|
|
33
14
|
stack,
|
|
34
|
-
value,
|
|
35
15
|
...rest
|
|
36
16
|
} = Astro.props
|
|
37
17
|
|
|
@@ -47,7 +27,7 @@ if (
|
|
|
47
27
|
!Astro.props["aria-labelledby"]
|
|
48
28
|
) {
|
|
49
29
|
console.warn(
|
|
50
|
-
"[OPUI Switch] Missing accessible name. Provide a default slot, `aria-label`, or `aria-labelledby`."
|
|
30
|
+
"[OPUI Switch] Missing accessible name. Provide a default slot, `aria-label`, or `aria-labelledby`.",
|
|
51
31
|
)
|
|
52
32
|
}
|
|
53
33
|
---
|
|
@@ -78,24 +58,19 @@ if (
|
|
|
78
58
|
</span>
|
|
79
59
|
)
|
|
80
60
|
}
|
|
81
|
-
<SwitchInput
|
|
82
|
-
aria-describedby={endTextId}
|
|
83
|
-
{checked}
|
|
84
|
-
{disabled}
|
|
85
|
-
{id}
|
|
86
|
-
name={finalName}
|
|
87
|
-
{required}
|
|
88
|
-
{value}
|
|
89
|
-
{...rest}
|
|
90
|
-
/>
|
|
61
|
+
<SwitchInput aria-describedby={endTextId} name={finalName} {...rest} />
|
|
91
62
|
{
|
|
92
63
|
Astro.slots.has("default") && (
|
|
93
|
-
|
|
64
|
+
<span class:list={[hideLabel ? "ui-sr-only" : "ui-label"]}>
|
|
65
|
+
<slot />
|
|
66
|
+
</span>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
{
|
|
70
|
+
Astro.slots.has("end-text") && (
|
|
71
|
+
<span id={endTextId} class="ui-end-text">
|
|
72
|
+
<slot name="end-text" />
|
|
73
|
+
</span>
|
|
74
|
+
)
|
|
94
75
|
}
|
|
95
|
-
{
|
|
96
|
-
Astro.slots.has("end-text") && (
|
|
97
|
-
<!-- prettier-ignore -->
|
|
98
|
-
<span id={endTextId} class="ui-end-text"><slot name="end-text" /></span>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
76
|
</label>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SwitchInput from "./SwitchInput.vue"
|
|
3
|
+
import type { Slots, SwitchProps } from "./types.d.vue"
|
|
4
|
+
import { useId } from "vue"
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const props = defineProps<SwitchProps>()
|
|
11
|
+
defineSlots<Slots>()
|
|
12
|
+
const modelValue = defineModel<boolean | (string | number)[]>()
|
|
13
|
+
|
|
14
|
+
const endTextId = useId()
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<label
|
|
19
|
+
:class="[
|
|
20
|
+
'ui-switch',
|
|
21
|
+
{
|
|
22
|
+
'ui-small': props.small,
|
|
23
|
+
'ui-stack': props.stack,
|
|
24
|
+
'ui-spread': props.spread,
|
|
25
|
+
},
|
|
26
|
+
props.class,
|
|
27
|
+
]"
|
|
28
|
+
:data-invalid="props.error || undefined"
|
|
29
|
+
>
|
|
30
|
+
<span
|
|
31
|
+
v-if="$slots['icon-unchecked']"
|
|
32
|
+
class="ui-icon-unchecked"
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
>
|
|
35
|
+
<slot name="icon-unchecked"></slot>
|
|
36
|
+
</span>
|
|
37
|
+
|
|
38
|
+
<span
|
|
39
|
+
v-if="$slots['icon-checked']"
|
|
40
|
+
class="ui-icon-checked"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
>
|
|
43
|
+
<slot name="icon-checked"></slot>
|
|
44
|
+
</span>
|
|
45
|
+
|
|
46
|
+
<SwitchInput
|
|
47
|
+
v-bind="$attrs"
|
|
48
|
+
v-model="modelValue"
|
|
49
|
+
:aria-describedby="endTextId"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<span
|
|
53
|
+
v-if="$slots.default"
|
|
54
|
+
:class="[props.hideLabel ? 'ui-sr-only' : 'ui-label']"
|
|
55
|
+
>
|
|
56
|
+
<slot></slot>
|
|
57
|
+
</span>
|
|
58
|
+
|
|
59
|
+
<span v-if="$slots['end-text']" :id="endTextId" class="ui-end-text">
|
|
60
|
+
<slot name="end-text"></slot>
|
|
61
|
+
</span>
|
|
62
|
+
</label>
|
|
63
|
+
</template>
|