opui-css 4.1.0 → 5.0.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/CHANGELOG.md +282 -247
- package/LICENSE +21 -21
- package/MIGRATING.md +127 -105
- package/README.md +87 -87
- package/astro/index.ts +46 -46
- package/components/AGENTS.md +248 -247
- package/components/Accordion/Accordion.astro +42 -42
- package/components/Anchor/Anchor.astro +51 -51
- package/components/Avatar/Avatar.astro +38 -44
- package/components/Badge/Badge.astro +59 -54
- package/components/Button/Button.astro +45 -45
- package/components/ButtonGroup/ButtonGroup.astro +29 -29
- package/components/Callout/Callout.astro +75 -75
- package/components/Card/Card.astro +36 -36
- package/components/Checkbox/Checkbox.astro +76 -76
- package/components/Checkbox/CheckboxInput.astro +32 -32
- package/components/Chip/Chip.astro +37 -37
- package/components/ClassicSelect/ClassicSelect.astro +83 -83
- package/components/DescriptionList/Description.astro +12 -12
- package/components/DescriptionList/DescriptionList.astro +22 -22
- package/components/DescriptionList/Item.astro +12 -12
- package/components/DescriptionList/Term.astro +12 -12
- package/components/DescriptionList/index.ts +12 -12
- package/components/Dialog/Dialog.astro +41 -41
- package/components/Divider/Divider.astro +17 -14
- package/components/Drawer/Drawer.astro +49 -49
- package/components/Drawer/DrawerFooter.astro +14 -14
- package/components/Drawer/DrawerHeader.astro +31 -31
- package/components/FieldDescription/FieldDescription.astro +13 -13
- package/components/FieldGroup/FieldGroup.astro +31 -31
- package/components/FieldLegend/FieldLegend.astro +15 -15
- package/components/FieldSet/FieldSet.astro +15 -15
- package/components/Form/Form.astro +15 -15
- package/components/IconButton/IconButton.astro +26 -26
- package/components/List/List.astro +36 -36
- package/components/ListItem/ListItem.astro +118 -118
- package/components/Progress/Progress.astro +41 -40
- package/components/Radio/Radio.astro +70 -70
- package/components/Radio/RadioInput.astro +24 -24
- package/components/Range/Range.astro +136 -136
- package/components/Select/Select.astro +106 -106
- package/components/Switch/Switch.astro +101 -101
- package/components/Switch/SwitchInput.astro +25 -25
- package/components/Table/Body.astro +13 -13
- package/components/Table/Cell.astro +13 -13
- package/components/Table/Column.astro +15 -15
- package/components/Table/ColumnGroup.astro +13 -13
- package/components/Table/Head.astro +13 -13
- package/components/Table/HeaderCell.astro +13 -13
- package/components/Table/Row.astro +13 -13
- package/components/Table/Table.astro +18 -15
- package/components/Table/index.ts +20 -20
- package/components/Tabs/Tabs.astro +28 -28
- package/components/Tabs/TabsItem.astro +47 -47
- package/components/Tabs/TabsPanel.astro +21 -21
- package/components/Tabs/TabsTab.astro +19 -19
- package/components/Tabs/index.ts +14 -14
- package/components/TextField/TextField.astro +128 -128
- package/components/Textarea/Textarea.astro +106 -106
- package/components/Toast/Toast.astro +42 -42
- package/components/ToggleButton/ToggleButton.astro +53 -53
- package/components/ToggleGroup/ToggleGroup.astro +49 -49
- package/components/Tooltip/Tooltip.astro +30 -30
- package/core/normalize.css +194 -194
- package/core/palette.css +59 -59
- package/core/utils.css +71 -71
- package/css/components/accordion.css +174 -174
- package/css/components/anchor.css +27 -27
- package/css/components/avatar.css +65 -65
- package/css/components/badge.css +107 -107
- package/css/components/button-group.css +179 -179
- package/css/components/button.css +215 -215
- package/css/components/callout.css +109 -109
- package/css/components/card.css +117 -117
- package/css/components/checkbox.css +205 -205
- package/css/components/chip.css +87 -87
- package/css/components/description-list.css +80 -77
- package/css/components/dialog.css +68 -68
- package/css/components/divider.css +20 -20
- package/css/components/drawer.css +171 -171
- package/css/components/form.css +146 -146
- package/css/components/icon-button.css +139 -139
- package/css/components/link.css +21 -21
- package/css/components/list.css +345 -345
- package/css/components/progress.css +102 -97
- package/css/components/radio.css +172 -172
- package/css/components/range.css +337 -337
- package/css/components/select.css +169 -169
- package/css/components/spinner.css +37 -37
- package/css/components/switch.css +268 -268
- package/css/components/table.css +179 -179
- package/css/components/tabs.css +83 -77
- package/css/components/text-field.css +450 -450
- package/css/components/text-input.css +64 -64
- package/css/components/textarea.css +24 -24
- package/css/components/toast.css +161 -161
- package/css/components/toggle-button.css +87 -87
- package/css/components/toggle-group.css +56 -56
- package/css/components/tooltip.css +67 -67
- package/css/components/typography.css +585 -585
- package/css/components.css +41 -41
- package/css/imports.css +16 -16
- package/css/js/checkbox.js +21 -21
- package/css/js/toast.js +94 -94
- package/css/theme.css +132 -132
- package/dist/op.css +65 -65
- package/dist/op.css.map +1 -1
- package/dist/opui.components.css +5159 -5145
- package/dist/opui.components.css.map +1 -1
- package/dist/opui.css +5668 -5654
- package/dist/opui.css.map +1 -1
- package/env.d.ts +14 -14
- package/open-props.css +9 -9
- package/package.json +81 -81
|
@@ -1,136 +1,136 @@
|
|
|
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
|
-
)
|
|
25
|
-
|
|
26
|
-
export const title = "Range"
|
|
27
|
-
|
|
28
|
-
const {
|
|
29
|
-
class: className,
|
|
30
|
-
disabled,
|
|
31
|
-
endText,
|
|
32
|
-
id,
|
|
33
|
-
label,
|
|
34
|
-
list,
|
|
35
|
-
max,
|
|
36
|
-
min,
|
|
37
|
-
name,
|
|
38
|
-
options,
|
|
39
|
-
spread,
|
|
40
|
-
startText,
|
|
41
|
-
step,
|
|
42
|
-
value,
|
|
43
|
-
valueSuffix,
|
|
44
|
-
variant,
|
|
45
|
-
...rest
|
|
46
|
-
} = Astro.props
|
|
47
|
-
|
|
48
|
-
const { $id } = Astro.locals
|
|
49
|
-
|
|
50
|
-
const hasLabel = !!label || Astro.slots.has("default")
|
|
51
|
-
const hasStartText = !!startText || Astro.slots.has("start-text")
|
|
52
|
-
const hasEndText = !!endText || Astro.slots.has("end-text")
|
|
53
|
-
const hasValue = valueSuffix !== undefined || Astro.slots.has("value")
|
|
54
|
-
|
|
55
|
-
const inputId = id || $id("range")
|
|
56
|
-
const labelId = hasLabel ? $id("range-label") : undefined
|
|
57
|
-
const startTextId = hasStartText ? $id("range-start") : undefined
|
|
58
|
-
const endTextId = hasEndText ? $id("range-end") : undefined
|
|
59
|
-
|
|
60
|
-
const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefined
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
<label class:list={["range", variant
|
|
64
|
-
{
|
|
65
|
-
hasLabel && (
|
|
66
|
-
<!-- prettier-ignore -->
|
|
67
|
-
<span class="label" id={labelId}>{label}<slot /></span>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
{
|
|
71
|
-
hasValue && (
|
|
72
|
-
<output class="value" for={inputId} data-suffix={valueSuffix}>
|
|
73
|
-
<slot name="value">{value}</slot>
|
|
74
|
-
</output>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
{
|
|
78
|
-
hasStartText && (
|
|
79
|
-
<span class="start-text" id={startTextId}>
|
|
80
|
-
{startText}<slot name="start-text" />
|
|
81
|
-
</span>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
<input
|
|
85
|
-
aria-describedby={describedBy}
|
|
86
|
-
aria-labelledby={labelId}
|
|
87
|
-
disabled={disabled}
|
|
88
|
-
id={inputId}
|
|
89
|
-
list={list}
|
|
90
|
-
max={max}
|
|
91
|
-
min={min}
|
|
92
|
-
name={name}
|
|
93
|
-
step={step}
|
|
94
|
-
type="range"
|
|
95
|
-
value={value}
|
|
96
|
-
{...rest}
|
|
97
|
-
/>
|
|
98
|
-
{
|
|
99
|
-
(options || Astro.slots.has("datalist")) && (
|
|
100
|
-
<datalist id={list}>
|
|
101
|
-
{options?.map((option) =>
|
|
102
|
-
typeof option === "object" ? (
|
|
103
|
-
<option value={option.value} label={option.label} />
|
|
104
|
-
) : (
|
|
105
|
-
<option value={option} />
|
|
106
|
-
)
|
|
107
|
-
)}
|
|
108
|
-
<slot name="datalist" />
|
|
109
|
-
</datalist>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
{
|
|
113
|
-
hasEndText && (
|
|
114
|
-
<span class="end-text" id={endTextId}>
|
|
115
|
-
{endText}<slot name="end-text" />
|
|
116
|
-
</span>
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
</label>
|
|
120
|
-
|
|
121
|
-
<script>
|
|
122
|
-
// Mirror the slider's current value into its associated <output> on every
|
|
123
|
-
// input event. Idempotent: each .range is wired once, and ignores ranges
|
|
124
|
-
// without a value display.
|
|
125
|
-
for (const range of document.querySelectorAll<HTMLElement>(".range")) {
|
|
126
|
-
const input = range.querySelector<HTMLInputElement>('input[type="range"]')
|
|
127
|
-
const output = range.querySelector<HTMLOutputElement>(":scope > output.value")
|
|
128
|
-
if (!input || !output) continue
|
|
129
|
-
const suffix = output.dataset.suffix ?? ""
|
|
130
|
-
const update = () => {
|
|
131
|
-
output.textContent = `${input.value}${suffix}`
|
|
132
|
-
}
|
|
133
|
-
input.addEventListener("input", update)
|
|
134
|
-
update()
|
|
135
|
-
}
|
|
136
|
-
</script>
|
|
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
|
+
)
|
|
25
|
+
|
|
26
|
+
export const title = "Range"
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
class: className,
|
|
30
|
+
disabled,
|
|
31
|
+
endText,
|
|
32
|
+
id,
|
|
33
|
+
label,
|
|
34
|
+
list,
|
|
35
|
+
max,
|
|
36
|
+
min,
|
|
37
|
+
name,
|
|
38
|
+
options,
|
|
39
|
+
spread,
|
|
40
|
+
startText,
|
|
41
|
+
step,
|
|
42
|
+
value,
|
|
43
|
+
valueSuffix,
|
|
44
|
+
variant,
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props
|
|
47
|
+
|
|
48
|
+
const { $id } = Astro.locals
|
|
49
|
+
|
|
50
|
+
const hasLabel = !!label || Astro.slots.has("default")
|
|
51
|
+
const hasStartText = !!startText || Astro.slots.has("start-text")
|
|
52
|
+
const hasEndText = !!endText || Astro.slots.has("end-text")
|
|
53
|
+
const hasValue = valueSuffix !== undefined || Astro.slots.has("value")
|
|
54
|
+
|
|
55
|
+
const inputId = id || $id("range")
|
|
56
|
+
const labelId = hasLabel ? $id("range-label") : undefined
|
|
57
|
+
const startTextId = hasStartText ? $id("range-start") : undefined
|
|
58
|
+
const endTextId = hasEndText ? $id("range-end") : undefined
|
|
59
|
+
|
|
60
|
+
const describedBy = [startTextId, endTextId].filter(Boolean).join(" ") || undefined
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
<label class:list={["ui-range", variant && `ui-${variant}`, { "ui-spread": spread }, className]}>
|
|
64
|
+
{
|
|
65
|
+
hasLabel && (
|
|
66
|
+
<!-- prettier-ignore -->
|
|
67
|
+
<span class="ui-label" id={labelId}>{label}<slot /></span>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
hasValue && (
|
|
72
|
+
<output class="ui-value" for={inputId} data-suffix={valueSuffix}>
|
|
73
|
+
<slot name="value">{value}</slot>
|
|
74
|
+
</output>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
{
|
|
78
|
+
hasStartText && (
|
|
79
|
+
<span class="ui-start-text" id={startTextId}>
|
|
80
|
+
{startText}<slot name="start-text" />
|
|
81
|
+
</span>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
<input
|
|
85
|
+
aria-describedby={describedBy}
|
|
86
|
+
aria-labelledby={labelId}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
id={inputId}
|
|
89
|
+
list={list}
|
|
90
|
+
max={max}
|
|
91
|
+
min={min}
|
|
92
|
+
name={name}
|
|
93
|
+
step={step}
|
|
94
|
+
type="range"
|
|
95
|
+
value={value}
|
|
96
|
+
{...rest}
|
|
97
|
+
/>
|
|
98
|
+
{
|
|
99
|
+
(options || Astro.slots.has("datalist")) && (
|
|
100
|
+
<datalist id={list}>
|
|
101
|
+
{options?.map((option) =>
|
|
102
|
+
typeof option === "object" ? (
|
|
103
|
+
<option value={option.value} label={option.label} />
|
|
104
|
+
) : (
|
|
105
|
+
<option value={option} />
|
|
106
|
+
)
|
|
107
|
+
)}
|
|
108
|
+
<slot name="datalist" />
|
|
109
|
+
</datalist>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
{
|
|
113
|
+
hasEndText && (
|
|
114
|
+
<span class="ui-end-text" id={endTextId}>
|
|
115
|
+
{endText}<slot name="end-text" />
|
|
116
|
+
</span>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
</label>
|
|
120
|
+
|
|
121
|
+
<script>
|
|
122
|
+
// Mirror the slider's current value into its associated <output> on every
|
|
123
|
+
// input event. Idempotent: each .ui-range is wired once, and ignores ranges
|
|
124
|
+
// without a value display.
|
|
125
|
+
for (const range of document.querySelectorAll<HTMLElement>(".ui-range")) {
|
|
126
|
+
const input = range.querySelector<HTMLInputElement>('input[type="range"]')
|
|
127
|
+
const output = range.querySelector<HTMLOutputElement>(":scope > output.ui-value")
|
|
128
|
+
if (!input || !output) continue
|
|
129
|
+
const suffix = output.dataset.suffix ?? ""
|
|
130
|
+
const update = () => {
|
|
131
|
+
output.textContent = `${input.value}${suffix}`
|
|
132
|
+
}
|
|
133
|
+
input.addEventListener("input", update)
|
|
134
|
+
update()
|
|
135
|
+
}
|
|
136
|
+
</script>
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
---
|
|
2
|
-
type Item = {
|
|
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
|
-
critical?: 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
|
-
}
|
|
25
|
-
|
|
26
|
-
export const title = "Select"
|
|
27
|
-
|
|
28
|
-
const {
|
|
29
|
-
class: className,
|
|
30
|
-
description,
|
|
31
|
-
disabled,
|
|
32
|
-
critical,
|
|
33
|
-
dense,
|
|
34
|
-
id,
|
|
35
|
-
items = [],
|
|
36
|
-
label,
|
|
37
|
-
name,
|
|
38
|
-
spread,
|
|
39
|
-
required,
|
|
40
|
-
size,
|
|
41
|
-
endText,
|
|
42
|
-
value,
|
|
43
|
-
variant = "outlined",
|
|
44
|
-
...rest
|
|
45
|
-
} = Astro.props
|
|
46
|
-
|
|
47
|
-
const { $id, currentFieldName } = Astro.locals
|
|
48
|
-
const selectId = id || $id("select")
|
|
49
|
-
const fieldName = name || currentFieldName
|
|
50
|
-
const labelId = $id("select-label")
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
<label
|
|
54
|
-
class:list={[
|
|
55
|
-
"select",
|
|
56
|
-
size
|
|
57
|
-
{
|
|
58
|
-
filled: variant === "filled",
|
|
59
|
-
spread,
|
|
60
|
-
},
|
|
61
|
-
className,
|
|
62
|
-
]}
|
|
63
|
-
data-invalid={critical || undefined}
|
|
64
|
-
>
|
|
65
|
-
{
|
|
66
|
-
(label || Astro.slots.has("label")) && (
|
|
67
|
-
<!-- prettier-ignore -->
|
|
68
|
-
<span class="label" id={labelId}>{label}<slot name="label" /></span>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
{
|
|
72
|
-
(description || Astro.slots.has("description")) && (
|
|
73
|
-
<!-- prettier-ignore -->
|
|
74
|
-
<span class="start-text">{description}<slot name="description" /></span>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
<span class="field">
|
|
78
|
-
<select
|
|
79
|
-
aria-labelledby={label ? labelId : undefined}
|
|
80
|
-
disabled={disabled}
|
|
81
|
-
id={selectId}
|
|
82
|
-
name={fieldName}
|
|
83
|
-
required={required}
|
|
84
|
-
value={value}
|
|
85
|
-
{...rest}
|
|
86
|
-
>
|
|
87
|
-
<button>
|
|
88
|
-
<selectedcontent></selectedcontent>
|
|
89
|
-
</button>
|
|
90
|
-
<div class:list={["list", { dense }]}>
|
|
91
|
-
{items.map((item) => <option value={item.value}>{item.text}</option>)}
|
|
92
|
-
<slot />
|
|
93
|
-
</div>
|
|
94
|
-
</select>
|
|
95
|
-
{Astro.slots.has("prefix") && <span class="prefix"><slot name="prefix" /></span>}
|
|
96
|
-
{Astro.slots.has("suffix") && <span class="suffix"><slot name="suffix" /></span>}
|
|
97
|
-
{Astro.slots.has("header") && <span class="header"><slot name="header" /></span>}
|
|
98
|
-
{Astro.slots.has("footer") && <span class="footer"><slot name="footer" /></span>}
|
|
99
|
-
</span>
|
|
100
|
-
{
|
|
101
|
-
(endText || Astro.slots.has("end-text")) && (
|
|
102
|
-
<!-- prettier-ignore -->
|
|
103
|
-
<span id={$id("end-text")} class="end-text">{endText}<slot name="end-text" /></span>
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
</label>
|
|
1
|
+
---
|
|
2
|
+
type Item = {
|
|
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
|
+
critical?: 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
|
+
}
|
|
25
|
+
|
|
26
|
+
export const title = "Select"
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
class: className,
|
|
30
|
+
description,
|
|
31
|
+
disabled,
|
|
32
|
+
critical,
|
|
33
|
+
dense,
|
|
34
|
+
id,
|
|
35
|
+
items = [],
|
|
36
|
+
label,
|
|
37
|
+
name,
|
|
38
|
+
spread,
|
|
39
|
+
required,
|
|
40
|
+
size,
|
|
41
|
+
endText,
|
|
42
|
+
value,
|
|
43
|
+
variant = "outlined",
|
|
44
|
+
...rest
|
|
45
|
+
} = Astro.props
|
|
46
|
+
|
|
47
|
+
const { $id, currentFieldName } = Astro.locals
|
|
48
|
+
const selectId = id || $id("select")
|
|
49
|
+
const fieldName = name || currentFieldName
|
|
50
|
+
const labelId = $id("select-label")
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
<label
|
|
54
|
+
class:list={[
|
|
55
|
+
"ui-select",
|
|
56
|
+
size && `ui-${size}`,
|
|
57
|
+
{
|
|
58
|
+
"ui-filled": variant === "filled",
|
|
59
|
+
"ui-spread": spread,
|
|
60
|
+
},
|
|
61
|
+
className,
|
|
62
|
+
]}
|
|
63
|
+
data-invalid={critical || undefined}
|
|
64
|
+
>
|
|
65
|
+
{
|
|
66
|
+
(label || Astro.slots.has("label")) && (
|
|
67
|
+
<!-- prettier-ignore -->
|
|
68
|
+
<span class="ui-label" id={labelId}>{label}<slot name="label" /></span>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
{
|
|
72
|
+
(description || Astro.slots.has("description")) && (
|
|
73
|
+
<!-- prettier-ignore -->
|
|
74
|
+
<span class="ui-start-text">{description}<slot name="description" /></span>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
<span class="ui-field">
|
|
78
|
+
<select
|
|
79
|
+
aria-labelledby={label ? labelId : undefined}
|
|
80
|
+
disabled={disabled}
|
|
81
|
+
id={selectId}
|
|
82
|
+
name={fieldName}
|
|
83
|
+
required={required}
|
|
84
|
+
value={value}
|
|
85
|
+
{...rest}
|
|
86
|
+
>
|
|
87
|
+
<button>
|
|
88
|
+
<selectedcontent></selectedcontent>
|
|
89
|
+
</button>
|
|
90
|
+
<div class:list={["ui-list", { "ui-dense": dense }]}>
|
|
91
|
+
{items.map((item) => <option value={item.value}>{item.text}</option>)}
|
|
92
|
+
<slot />
|
|
93
|
+
</div>
|
|
94
|
+
</select>
|
|
95
|
+
{Astro.slots.has("prefix") && <span class="ui-prefix"><slot name="prefix" /></span>}
|
|
96
|
+
{Astro.slots.has("suffix") && <span class="ui-suffix"><slot name="suffix" /></span>}
|
|
97
|
+
{Astro.slots.has("header") && <span class="ui-header"><slot name="header" /></span>}
|
|
98
|
+
{Astro.slots.has("footer") && <span class="ui-footer"><slot name="footer" /></span>}
|
|
99
|
+
</span>
|
|
100
|
+
{
|
|
101
|
+
(endText || Astro.slots.has("end-text")) && (
|
|
102
|
+
<!-- prettier-ignore -->
|
|
103
|
+
<span id={$id("end-text")} class="ui-end-text">{endText}<slot name="end-text" /></span>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
</label>
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
---
|
|
2
|
-
import SwitchInput from "./SwitchInput.astro"
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
[key: string]: any
|
|
6
|
-
checked?: boolean
|
|
7
|
-
class?: string
|
|
8
|
-
disabled?: boolean
|
|
9
|
-
critical?: 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
|
-
}
|
|
19
|
-
|
|
20
|
-
export const title = "Switch"
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
checked,
|
|
24
|
-
class: className,
|
|
25
|
-
disabled,
|
|
26
|
-
critical,
|
|
27
|
-
hideLabel,
|
|
28
|
-
id,
|
|
29
|
-
name,
|
|
30
|
-
required,
|
|
31
|
-
small,
|
|
32
|
-
spread,
|
|
33
|
-
stack,
|
|
34
|
-
value,
|
|
35
|
-
...rest
|
|
36
|
-
} = Astro.props
|
|
37
|
-
|
|
38
|
-
const { $id, currentFieldName } = Astro.locals
|
|
39
|
-
const endTextId = Astro.slots.has("end-text") ? $id("end-text") : undefined
|
|
40
|
-
|
|
41
|
-
const finalName = name || currentFieldName
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
import.meta.env.DEV &&
|
|
45
|
-
!Astro.slots.has("default") &&
|
|
46
|
-
!Astro.props["aria-label"] &&
|
|
47
|
-
!Astro.props["aria-labelledby"]
|
|
48
|
-
) {
|
|
49
|
-
console.warn(
|
|
50
|
-
"[OPUI Switch] Missing accessible name. Provide a default slot, `aria-label`, or `aria-labelledby`."
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
<label
|
|
56
|
-
class:list={[
|
|
57
|
-
"switch",
|
|
58
|
-
{
|
|
59
|
-
small,
|
|
60
|
-
stack,
|
|
61
|
-
spread,
|
|
62
|
-
},
|
|
63
|
-
className,
|
|
64
|
-
]}
|
|
65
|
-
data-invalid={critical || undefined}
|
|
66
|
-
>
|
|
67
|
-
{
|
|
68
|
-
Astro.slots.has("icon-unchecked") && (
|
|
69
|
-
<span class="icon-unchecked" aria-hidden="true">
|
|
70
|
-
<slot name="icon-unchecked" />
|
|
71
|
-
</span>
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
{
|
|
75
|
-
Astro.slots.has("icon-checked") && (
|
|
76
|
-
<span class="icon-checked" aria-hidden="true">
|
|
77
|
-
<slot name="icon-checked" />
|
|
78
|
-
</span>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
<SwitchInput
|
|
82
|
-
aria-describedby={endTextId}
|
|
83
|
-
{checked}
|
|
84
|
-
{disabled}
|
|
85
|
-
{id}
|
|
86
|
-
name={finalName}
|
|
87
|
-
{required}
|
|
88
|
-
{value}
|
|
89
|
-
{...rest}
|
|
90
|
-
/>
|
|
91
|
-
{
|
|
92
|
-
Astro.slots.has("default") && (
|
|
93
|
-
<!-- prettier-ignore --><span class:list={[hideLabel ? "sr-only" : "label"]}><slot /></span>)
|
|
94
|
-
}
|
|
95
|
-
{
|
|
96
|
-
Astro.slots.has("end-text") && (
|
|
97
|
-
<!-- prettier-ignore -->
|
|
98
|
-
<span id={endTextId} class="end-text"><slot name="end-text" /></span>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
</label>
|
|
1
|
+
---
|
|
2
|
+
import SwitchInput from "./SwitchInput.astro"
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
[key: string]: any
|
|
6
|
+
checked?: boolean
|
|
7
|
+
class?: string
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
critical?: 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
|
+
}
|
|
19
|
+
|
|
20
|
+
export const title = "Switch"
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
checked,
|
|
24
|
+
class: className,
|
|
25
|
+
disabled,
|
|
26
|
+
critical,
|
|
27
|
+
hideLabel,
|
|
28
|
+
id,
|
|
29
|
+
name,
|
|
30
|
+
required,
|
|
31
|
+
small,
|
|
32
|
+
spread,
|
|
33
|
+
stack,
|
|
34
|
+
value,
|
|
35
|
+
...rest
|
|
36
|
+
} = Astro.props
|
|
37
|
+
|
|
38
|
+
const { $id, currentFieldName } = Astro.locals
|
|
39
|
+
const endTextId = Astro.slots.has("end-text") ? $id("end-text") : undefined
|
|
40
|
+
|
|
41
|
+
const finalName = name || currentFieldName
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
import.meta.env.DEV &&
|
|
45
|
+
!Astro.slots.has("default") &&
|
|
46
|
+
!Astro.props["aria-label"] &&
|
|
47
|
+
!Astro.props["aria-labelledby"]
|
|
48
|
+
) {
|
|
49
|
+
console.warn(
|
|
50
|
+
"[OPUI Switch] Missing accessible name. Provide a default slot, `aria-label`, or `aria-labelledby`."
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
<label
|
|
56
|
+
class:list={[
|
|
57
|
+
"ui-switch",
|
|
58
|
+
{
|
|
59
|
+
"ui-small": small,
|
|
60
|
+
"ui-stack": stack,
|
|
61
|
+
"ui-spread": spread,
|
|
62
|
+
},
|
|
63
|
+
className,
|
|
64
|
+
]}
|
|
65
|
+
data-invalid={critical || undefined}
|
|
66
|
+
>
|
|
67
|
+
{
|
|
68
|
+
Astro.slots.has("icon-unchecked") && (
|
|
69
|
+
<span class="ui-icon-unchecked" aria-hidden="true">
|
|
70
|
+
<slot name="icon-unchecked" />
|
|
71
|
+
</span>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
{
|
|
75
|
+
Astro.slots.has("icon-checked") && (
|
|
76
|
+
<span class="ui-icon-checked" aria-hidden="true">
|
|
77
|
+
<slot name="icon-checked" />
|
|
78
|
+
</span>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
<SwitchInput
|
|
82
|
+
aria-describedby={endTextId}
|
|
83
|
+
{checked}
|
|
84
|
+
{disabled}
|
|
85
|
+
{id}
|
|
86
|
+
name={finalName}
|
|
87
|
+
{required}
|
|
88
|
+
{value}
|
|
89
|
+
{...rest}
|
|
90
|
+
/>
|
|
91
|
+
{
|
|
92
|
+
Astro.slots.has("default") && (
|
|
93
|
+
<!-- prettier-ignore --><span class:list={[hideLabel ? "ui-sr-only" : "ui-label"]}><slot /></span>)
|
|
94
|
+
}
|
|
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
|
+
</label>
|