@stacksjs/components 0.2.865 → 0.2.868
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/dist/AppearancePicker-61r20jpp.stx +351 -0
- package/dist/{Button-sebyqeva.stx → Button-pg8mzsq3.stx} +249 -0
- package/dist/Checkbox-52mhrzkz.stx +417 -0
- package/dist/ColorSwatches-ecfxphjy.stx +287 -0
- package/dist/{NumberInput-axcfj9y8.stx → NumberInput-e2afxyh3.stx} +303 -0
- package/dist/{PasswordInput-8m3109tp.stx → PasswordInput-n2ven456.stx} +315 -0
- package/dist/RadioGroup-ps9kn22f.stx +329 -0
- package/dist/RadioGroupOption-6hyy1bvb.stx +246 -0
- package/dist/{SegmentedControl-fr69q4gb.stx → SegmentedControl-7q0t8c9s.stx} +170 -1
- package/dist/{Select-1cnqbcmg.stx → Select-ygzchedx.stx} +266 -0
- package/dist/SettingsGroup-dkae46k5.stx +200 -0
- package/dist/SettingsPane-jbd1gbdt.stx +50 -0
- package/dist/SettingsPaneHeader-f0cvkqs7.stx +188 -0
- package/dist/SettingsRow-4cxbsf1q.stx +424 -0
- package/dist/SettingsSidebarGroup-p2ygv5yy.stx +108 -0
- package/dist/SettingsSidebarItem-x8fsn3w5.stx +228 -0
- package/dist/SettingsWindow-mm490ymt.stx +537 -0
- package/dist/Slider-j59dgw1c.stx +377 -0
- package/dist/Switch-ga9ap8n8.stx +374 -0
- package/dist/{TextInput-tsvfwxmg.stx → TextInput-tyqzz3jy.stx} +325 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +35 -24
- package/dist/preview-frame/preview-frame.js +58 -2
- package/dist/settings/settings.js +757 -0
- package/dist/ui/appearance-picker/AppearancePicker.d.ts +12 -0
- package/dist/ui/appearance-picker/index.d.ts +16 -0
- package/dist/ui/button/Button.d.ts +24 -1
- package/dist/ui/button/index.d.ts +1 -0
- package/dist/ui/checkbox/Checkbox.d.ts +9 -1
- package/dist/ui/checkbox/index.d.ts +1 -0
- package/dist/ui/color-swatches/ColorSwatches.d.ts +26 -0
- package/dist/ui/color-swatches/index.d.ts +18 -0
- package/dist/ui/input/NumberInput.d.ts +11 -1
- package/dist/ui/input/PasswordInput.d.ts +9 -1
- package/dist/ui/input/TextInput.d.ts +12 -1
- package/dist/ui/input/index.d.ts +7 -3
- package/dist/ui/preview-frame/core.d.ts +22 -0
- package/dist/ui/preview-frame/view.d.ts +9 -0
- package/dist/ui/radio-group/RadioGroup.d.ts +14 -2
- package/dist/ui/radio-group/RadioGroupOption.d.ts +6 -1
- package/dist/ui/radio-group/index.d.ts +2 -0
- package/dist/ui/segmented-control/SegmentedControl.d.ts +9 -1
- package/dist/ui/segmented-control/index.d.ts +1 -0
- package/dist/ui/select/Select.d.ts +10 -1
- package/dist/ui/select/index.d.ts +1 -0
- package/dist/ui/settings/SettingsGroup.d.ts +30 -0
- package/dist/ui/settings/SettingsPane.d.ts +19 -0
- package/dist/ui/settings/SettingsPaneHeader.d.ts +20 -0
- package/dist/ui/settings/SettingsRow.d.ts +53 -0
- package/dist/ui/settings/SettingsSidebarGroup.d.ts +11 -0
- package/dist/ui/settings/SettingsSidebarItem.d.ts +22 -0
- package/dist/ui/settings/SettingsWindow.d.ts +22 -0
- package/dist/ui/settings/core.d.ts +146 -0
- package/dist/ui/settings/index.d.ts +73 -0
- package/dist/ui/settings/settings.d.ts +8 -0
- package/dist/ui/settings/view.d.ts +36 -0
- package/dist/ui/slider/Slider.d.ts +24 -0
- package/dist/ui/slider/core.d.ts +33 -0
- package/dist/ui/slider/index.d.ts +20 -0
- package/dist/ui/switch/Switch.d.ts +10 -1
- package/dist/ui/switch/index.d.ts +2 -1
- package/dist/utils/mac-theme.d.ts +24 -0
- package/package.json +8 -3
- package/src/index.ts +6 -0
- package/src/ui/appearance-picker/AppearancePicker.stx +351 -0
- package/src/ui/appearance-picker/README.md +61 -0
- package/src/ui/appearance-picker/index.ts +22 -0
- package/src/ui/button/Button.stx +249 -0
- package/src/ui/button/README.md +21 -0
- package/src/ui/button/index.ts +8 -0
- package/src/ui/checkbox/Checkbox.stx +275 -0
- package/src/ui/checkbox/index.ts +2 -0
- package/src/ui/color-swatches/ColorSwatches.stx +287 -0
- package/src/ui/color-swatches/README.md +66 -0
- package/src/ui/color-swatches/index.ts +25 -0
- package/src/ui/input/NumberInput.stx +303 -0
- package/src/ui/input/PasswordInput.stx +315 -0
- package/src/ui/input/TextInput.stx +325 -0
- package/src/ui/input/index.ts +9 -3
- package/src/ui/preview-frame/README.md +16 -14
- package/src/ui/preview-frame/core.ts +50 -0
- package/src/ui/preview-frame/index.ts +4 -4
- package/src/ui/preview-frame/view.ts +61 -4
- package/src/ui/radio-group/README.md +17 -0
- package/src/ui/radio-group/RadioGroup.stx +184 -6
- package/src/ui/radio-group/RadioGroupOption.stx +178 -2
- package/src/ui/radio-group/index.ts +4 -0
- package/src/ui/segmented-control/SegmentedControl.stx +170 -1
- package/src/ui/segmented-control/index.ts +2 -0
- package/src/ui/select/README.md +12 -0
- package/src/ui/select/Select.stx +266 -0
- package/src/ui/select/index.ts +2 -0
- package/src/ui/settings/README.md +221 -0
- package/src/ui/settings/SettingsGroup.stx +200 -0
- package/src/ui/settings/SettingsPane.stx +50 -0
- package/src/ui/settings/SettingsPaneHeader.stx +188 -0
- package/src/ui/settings/SettingsRow.stx +424 -0
- package/src/ui/settings/SettingsSidebarGroup.stx +108 -0
- package/src/ui/settings/SettingsSidebarItem.stx +228 -0
- package/src/ui/settings/SettingsWindow.stx +537 -0
- package/src/ui/settings/core.ts +359 -0
- package/src/ui/settings/index.ts +111 -0
- package/src/ui/settings/settings.ts +8 -0
- package/src/ui/settings/view.ts +740 -0
- package/src/ui/slider/README.md +91 -0
- package/src/ui/slider/Slider.stx +377 -0
- package/src/ui/slider/core.ts +120 -0
- package/src/ui/slider/index.ts +34 -0
- package/src/ui/switch/README.md +11 -0
- package/src/ui/switch/Switch.stx +217 -0
- package/src/ui/switch/index.ts +4 -1
- package/src/utils/mac-theme.ts +95 -0
- package/dist/Checkbox-80myyzzm.stx +0 -142
- package/dist/RadioGroup-smqcqgds.stx +0 -151
- package/dist/RadioGroupOption-twcw1b2a.stx +0 -70
- package/dist/Switch-s8yf2rvm.stx +0 -157
|
@@ -41,6 +41,14 @@ export const disabled = $bool($props.disabled)
|
|
|
41
41
|
export const size = $props.size === 'sm' ? 'sm' : $props.size === 'lg' ? 'lg' : 'md'
|
|
42
42
|
export const testID = $props.testID || ''
|
|
43
43
|
export const className = $props.className || ''
|
|
44
|
+
/*
|
|
45
|
+
* `variant="mac"` draws the segmented control a Mac draws: a 24px capsule
|
|
46
|
+
* track with the chosen segment raised in it. The buttons, `aria-pressed` and
|
|
47
|
+
* the events are the ones below; only the classes change, to
|
|
48
|
+
* `stx-mac-segmented`, which this file's <style> block draws from the
|
|
49
|
+
* `--stx-mac-*` tokens. It has one size, so `size` is not read.
|
|
50
|
+
*/
|
|
51
|
+
export const mac = $props.variant === 'mac' && !$native
|
|
44
52
|
|
|
45
53
|
const sizeClasses = {
|
|
46
54
|
sm: { segment: 'min-h-[28px] px-2.5 py-1', text: 'text-[13px]' },
|
|
@@ -64,7 +72,9 @@ const segmentSizing = stretch ? sizing.segment.replace(/\bpx-\S+/, stretchedPadd
|
|
|
64
72
|
*/
|
|
65
73
|
export const trackClasses = $native
|
|
66
74
|
? `${stretch ? 'flex' : 'self-start'} flex-row gap-0.5 p-0.5 rounded-[9px] bg-[#767680]/12 dark:bg-[#767680]/24 ${className}`.replace(/\s+/g, ' ').trim()
|
|
67
|
-
:
|
|
75
|
+
: mac
|
|
76
|
+
? `stx-mac-segmented ${stretch ? 'stx-mac-segmented-stretch' : ''} ${className}`.replace(/\s+/g, ' ').trim()
|
|
77
|
+
: `${stretch ? 'flex' : 'inline-flex'} flex-row gap-0.5 p-0.5 rounded-control bg-surface-sunken ${className}`.replace(/\s+/g, ' ').trim()
|
|
68
78
|
export const segmentBase = $native
|
|
69
79
|
? `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-[7px] ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
70
80
|
: `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-control transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
@@ -89,6 +99,9 @@ const segmentOn = {{ segmentOn }}
|
|
|
89
99
|
const segmentOff = {{ segmentOff }}
|
|
90
100
|
const labelOn = {{ labelOn }}
|
|
91
101
|
const labelOff = {{ labelOff }}
|
|
102
|
+
// The Mac look is drawn from `aria-pressed` and `disabled` in the stylesheet,
|
|
103
|
+
// so a segment's class does not change with its state.
|
|
104
|
+
const macLook = {{ mac }}
|
|
92
105
|
|
|
93
106
|
/** A choice as `{ value, label, disabled }`, whichever way it was written. */
|
|
94
107
|
function normalise(choice) {
|
|
@@ -130,11 +143,13 @@ function onNativeChange(event) {
|
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
function segmentClasses(segment) {
|
|
146
|
+
if (macLook) return 'stx-mac-segment'
|
|
133
147
|
const state = isOn(segment) ? segmentOn : 'bg-transparent'
|
|
134
148
|
return `${segmentBase} ${state} ${isOff(segment) ? segmentOff : 'cursor-pointer'}`
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
function labelClasses(segment) {
|
|
152
|
+
if (macLook) return 'stx-mac-segment-label'
|
|
138
153
|
return `${textSize} ${isOn(segment) ? labelOn : labelOff}`
|
|
139
154
|
}
|
|
140
155
|
|
|
@@ -176,3 +191,157 @@ defineExpose({ selected })
|
|
|
176
191
|
@click="choose(segment)"
|
|
177
192
|
><span class="truncate" :class="labelClasses(segment)" :text="segment.label"></span></button>
|
|
178
193
|
</div>
|
|
194
|
+
|
|
195
|
+
<style data-native-exclude>
|
|
196
|
+
:where(:root) {
|
|
197
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
198
|
+
--stx-mac-font-size: 13px;
|
|
199
|
+
--stx-mac-font-size-small: 11px;
|
|
200
|
+
--stx-mac-hairline: 0.5px;
|
|
201
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
202
|
+
--stx-mac-card-radius: 12px;
|
|
203
|
+
--stx-mac-control-radius: 6px;
|
|
204
|
+
--stx-mac-row-height: 38px;
|
|
205
|
+
--stx-mac-row-inset: 10px;
|
|
206
|
+
--stx-mac-sidebar-width: 226px;
|
|
207
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
208
|
+
--stx-mac-accent-ink: #ffffff;
|
|
209
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
210
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
211
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
212
|
+
--stx-mac-window: #ffffff;
|
|
213
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
214
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
215
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
216
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
217
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
218
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
219
|
+
--stx-mac-control: #ffffff;
|
|
220
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
221
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
|
|
222
|
+
--stx-mac-switch-on: #34c759;
|
|
223
|
+
--stx-mac-knob: #ffffff;
|
|
224
|
+
--stx-mac-danger: #ff3b30;
|
|
225
|
+
}
|
|
226
|
+
:where(.dark) {
|
|
227
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
228
|
+
--stx-mac-accent-ink: #ffffff;
|
|
229
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
230
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
231
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
232
|
+
--stx-mac-window: #1e1e1e;
|
|
233
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
234
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
235
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
236
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
237
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
238
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
239
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
240
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
241
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
|
|
242
|
+
--stx-mac-switch-on: #30d158;
|
|
243
|
+
--stx-mac-knob: #ffffff;
|
|
244
|
+
--stx-mac-danger: #ff453a;
|
|
245
|
+
}
|
|
246
|
+
@media (max-resolution: 1.5dppx) {
|
|
247
|
+
:where(:root) {
|
|
248
|
+
--stx-mac-hairline: 1px;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
@media (prefers-contrast: more) {
|
|
252
|
+
:where(:root) {
|
|
253
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
254
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
255
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
256
|
+
--stx-mac-hairline: 1px;
|
|
257
|
+
}
|
|
258
|
+
:where(.dark) {
|
|
259
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
260
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
261
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.stx-mac-segmented {
|
|
266
|
+
display: inline-flex;
|
|
267
|
+
box-sizing: border-box;
|
|
268
|
+
height: 24px;
|
|
269
|
+
padding: 2px;
|
|
270
|
+
border-radius: 12px;
|
|
271
|
+
background: var(--stx-mac-well);
|
|
272
|
+
font-family: var(--stx-mac-font);
|
|
273
|
+
font-size: var(--stx-mac-font-size);
|
|
274
|
+
letter-spacing: -0.08px;
|
|
275
|
+
-webkit-font-smoothing: antialiased;
|
|
276
|
+
color: var(--stx-mac-ink);
|
|
277
|
+
cursor: default;
|
|
278
|
+
-webkit-user-select: none;
|
|
279
|
+
user-select: none;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.stx-mac-segmented-stretch {
|
|
283
|
+
display: flex;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.stx-mac-segment {
|
|
287
|
+
display: inline-flex;
|
|
288
|
+
flex: none;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
box-sizing: border-box;
|
|
292
|
+
min-width: 0;
|
|
293
|
+
height: 20px;
|
|
294
|
+
margin: 0;
|
|
295
|
+
padding: 0 10px;
|
|
296
|
+
border: 0;
|
|
297
|
+
border-radius: 10px;
|
|
298
|
+
background: transparent;
|
|
299
|
+
color: inherit;
|
|
300
|
+
font: inherit;
|
|
301
|
+
letter-spacing: inherit;
|
|
302
|
+
-webkit-appearance: none;
|
|
303
|
+
appearance: none;
|
|
304
|
+
cursor: default;
|
|
305
|
+
outline: none;
|
|
306
|
+
transition: background-color 150ms ease, box-shadow 150ms ease;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.stx-mac-segmented-stretch .stx-mac-segment {
|
|
310
|
+
flex: 1 1 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.stx-mac-segment[aria-pressed='true'] {
|
|
314
|
+
background: var(--stx-mac-control);
|
|
315
|
+
box-shadow: var(--stx-mac-control-shadow);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.stx-mac-segment:focus-visible {
|
|
319
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.stx-mac-segment[aria-pressed='true']:focus-visible {
|
|
323
|
+
box-shadow: var(--stx-mac-control-shadow), var(--stx-mac-focus-ring);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.stx-mac-segment:disabled {
|
|
327
|
+
opacity: 0.5;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.stx-mac-segment-label {
|
|
331
|
+
overflow: hidden;
|
|
332
|
+
text-overflow: ellipsis;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@media (prefers-reduced-motion: reduce) {
|
|
337
|
+
.stx-mac-segment {
|
|
338
|
+
transition: none;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@media (prefers-contrast: more) {
|
|
343
|
+
.stx-mac-segmented {
|
|
344
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
@@ -25,6 +25,8 @@ export interface SegmentedControlProps {
|
|
|
25
25
|
disabled?: boolean
|
|
26
26
|
/** Large keeps every segment at least 44px tall for touch input. */
|
|
27
27
|
size?: 'sm' | 'md' | 'lg'
|
|
28
|
+
/** `'mac'` draws the 24px Mac capsule track from the `--stx-mac-*` tokens; `size` is not read. */
|
|
29
|
+
variant?: 'mac'
|
|
28
30
|
/** Names the group; each segment is `<testID>-<value>`. */
|
|
29
31
|
testID?: string
|
|
30
32
|
className?: string
|
package/src/ui/select/README.md
CHANGED
|
@@ -216,3 +216,15 @@ const handleCountryChange = (value) => {
|
|
|
216
216
|
/>
|
|
217
217
|
</form>
|
|
218
218
|
```
|
|
219
|
+
|
|
220
|
+
## Mac look
|
|
221
|
+
|
|
222
|
+
`variant="mac"` draws the pop-up button a Mac draws: the chosen value as 13px text, right-aligned, and a 20px disc holding an up and a down chevron. The control is as wide as the chosen value, so it sits at the end of a settings row.
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<Select variant="mac" v-model:value="size" name="size" placeholder="" :options="['Small', 'Medium', 'Large']" />
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
It is still a native `<select>`: the menu it opens, the keys that work in it and the value it submits are the platform's own. On a Mac that menu is the system's pop-up menu; the component does not draw one. `size` is not read under this look.
|
|
229
|
+
|
|
230
|
+
Colours and type come from the `--stx-mac-*` custom properties (`src/utils/mac-theme.ts`), light and dark, so an app re-themes it by setting a variable. A window that is not the key window (`data-stx-window-active="false"` on an ancestor, or Craft's `data-craft-window-active`) draws it without colour. The disc is `--stx-mac-popup-disc`, and `--stx-mac-popup-disc-hover` under the pointer.
|
package/src/ui/select/Select.stx
CHANGED
|
@@ -36,6 +36,15 @@ export const label = $props.label || ''
|
|
|
36
36
|
export const helperText = $props.helperText || ''
|
|
37
37
|
export const required = $bool($props.required)
|
|
38
38
|
export const className = $props.className || ''
|
|
39
|
+
/*
|
|
40
|
+
* `variant="mac"` draws the pop-up button a Mac draws: the chosen value as
|
|
41
|
+
* plain text, right-aligned, and a 20px disc holding an up and a down
|
|
42
|
+
* chevron. It is still the <select> below, so the menu it opens, the keys
|
|
43
|
+
* that work in it and the value it submits are the platform's own (on a Mac
|
|
44
|
+
* that menu is the system's). Only the classes change, to `stx-mac-popup`,
|
|
45
|
+
* which this file's <style> block draws from the `--stx-mac-*` tokens.
|
|
46
|
+
*/
|
|
47
|
+
export const mac = $props.variant === 'mac'
|
|
39
48
|
|
|
40
49
|
/*
|
|
41
50
|
* Padding decides the height here too, with no `h-*` to override it: an app
|
|
@@ -191,6 +200,64 @@ defineExpose({ value: selectedValue, options: optionList })
|
|
|
191
200
|
<p id="{{ helperId }}" class="mt-1.5 px-4 text-[13px] {{ error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]' }}">{{ helperText }}</p>
|
|
192
201
|
@endif
|
|
193
202
|
</div>
|
|
203
|
+
@elseif(mac)
|
|
204
|
+
<div class="stx-mac-popup-field">
|
|
205
|
+
@if(label)
|
|
206
|
+
<label for="{{ selectId }}" class="stx-mac-popup-label">
|
|
207
|
+
{{ label }}
|
|
208
|
+
@if(required)
|
|
209
|
+
<span class="stx-mac-popup-required">*</span>
|
|
210
|
+
@endif
|
|
211
|
+
</label>
|
|
212
|
+
@endif
|
|
213
|
+
|
|
214
|
+
<div class="stx-mac-popup">
|
|
215
|
+
<select
|
|
216
|
+
@if(name)name="{{ name }}"@endif
|
|
217
|
+
@if(autocomplete)autocomplete="{{ autocomplete }}"@endif
|
|
218
|
+
@if(form)form="{{ form }}"@endif
|
|
219
|
+
id="{{ selectId }}"
|
|
220
|
+
class="stx-mac-popup-select {{ className }}"
|
|
221
|
+
:value="selectedValue()"
|
|
222
|
+
@if(disabled)disabled@endif
|
|
223
|
+
@if(required)required@endif
|
|
224
|
+
@change="onChange($event)"
|
|
225
|
+
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
226
|
+
:aria-invalid="isError() ? 'true' : 'false'"
|
|
227
|
+
@if(helperText)aria-describedby="{{ helperId }}"@endif
|
|
228
|
+
>
|
|
229
|
+
@if(placeholder)
|
|
230
|
+
<option value="" disabled>{{ placeholder }}</option>
|
|
231
|
+
@endif
|
|
232
|
+
|
|
233
|
+
{{-- The served list and the live one, as in the default look below. --}}
|
|
234
|
+
@foreach(option in options)
|
|
235
|
+
<option
|
|
236
|
+
x-no-cloak
|
|
237
|
+
x-if="false"
|
|
238
|
+
value="{{ option.value }}"
|
|
239
|
+
@if(option.disabled)disabled@endif
|
|
240
|
+
@if(option.value === String(value))selected@endif
|
|
241
|
+
>{{ option.label }}</option>
|
|
242
|
+
@endforeach
|
|
243
|
+
|
|
244
|
+
<template :for="option in optionList()" :key="option.value">
|
|
245
|
+
<option :value="option.value" :disabled="option.disabled" x-text="option.label"></option>
|
|
246
|
+
</template>
|
|
247
|
+
|
|
248
|
+
<slot />
|
|
249
|
+
</select>
|
|
250
|
+
{{-- The disc is a picture of the control, not a second one: the select
|
|
251
|
+
lies under it and takes the click. --}}
|
|
252
|
+
<span class="stx-mac-popup-disc" aria-hidden="true"></span>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
@if(helperText)
|
|
256
|
+
<p id="{{ helperId }}" class="stx-mac-popup-helper" @if(error)data-error="true"@endif>
|
|
257
|
+
{{ helperText }}
|
|
258
|
+
</p>
|
|
259
|
+
@endif
|
|
260
|
+
</div>
|
|
194
261
|
@else
|
|
195
262
|
<div class="w-full">
|
|
196
263
|
@if(label)
|
|
@@ -263,3 +330,202 @@ defineExpose({ value: selectedValue, options: optionList })
|
|
|
263
330
|
@endif
|
|
264
331
|
</div>
|
|
265
332
|
@endif
|
|
333
|
+
|
|
334
|
+
<style data-native-exclude>
|
|
335
|
+
:where(:root) {
|
|
336
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
337
|
+
--stx-mac-font-size: 13px;
|
|
338
|
+
--stx-mac-font-size-small: 11px;
|
|
339
|
+
--stx-mac-hairline: 0.5px;
|
|
340
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
341
|
+
--stx-mac-card-radius: 12px;
|
|
342
|
+
--stx-mac-control-radius: 6px;
|
|
343
|
+
--stx-mac-row-height: 38px;
|
|
344
|
+
--stx-mac-row-inset: 10px;
|
|
345
|
+
--stx-mac-sidebar-width: 226px;
|
|
346
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
347
|
+
--stx-mac-accent-ink: #ffffff;
|
|
348
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
349
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
350
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
351
|
+
--stx-mac-window: #ffffff;
|
|
352
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
353
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
354
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
355
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
356
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
357
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
358
|
+
--stx-mac-control: #ffffff;
|
|
359
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
360
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
|
|
361
|
+
--stx-mac-switch-on: #34c759;
|
|
362
|
+
--stx-mac-knob: #ffffff;
|
|
363
|
+
--stx-mac-danger: #ff3b30;
|
|
364
|
+
}
|
|
365
|
+
:where(.dark) {
|
|
366
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
367
|
+
--stx-mac-accent-ink: #ffffff;
|
|
368
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
369
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
370
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
371
|
+
--stx-mac-window: #1e1e1e;
|
|
372
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
373
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
374
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
375
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
376
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
377
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
378
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
379
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
380
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
|
|
381
|
+
--stx-mac-switch-on: #30d158;
|
|
382
|
+
--stx-mac-knob: #ffffff;
|
|
383
|
+
--stx-mac-danger: #ff453a;
|
|
384
|
+
}
|
|
385
|
+
@media (max-resolution: 1.5dppx) {
|
|
386
|
+
:where(:root) {
|
|
387
|
+
--stx-mac-hairline: 1px;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
@media (prefers-contrast: more) {
|
|
391
|
+
:where(:root) {
|
|
392
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
393
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
394
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
395
|
+
--stx-mac-hairline: 1px;
|
|
396
|
+
}
|
|
397
|
+
:where(.dark) {
|
|
398
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
399
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
400
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.stx-mac-popup-field {
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
flex-direction: column;
|
|
407
|
+
align-items: flex-end;
|
|
408
|
+
gap: 4px;
|
|
409
|
+
max-width: 100%;
|
|
410
|
+
font-family: var(--stx-mac-font);
|
|
411
|
+
font-size: var(--stx-mac-font-size);
|
|
412
|
+
letter-spacing: -0.08px;
|
|
413
|
+
-webkit-font-smoothing: antialiased;
|
|
414
|
+
color: var(--stx-mac-ink);
|
|
415
|
+
cursor: default;
|
|
416
|
+
-webkit-user-select: none;
|
|
417
|
+
user-select: none;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.stx-mac-popup-required {
|
|
421
|
+
color: var(--stx-mac-danger);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.stx-mac-popup {
|
|
425
|
+
--stx-mac-popup-disc: var(--stx-mac-well);
|
|
426
|
+
--stx-mac-popup-disc-hover: color-mix(in srgb, var(--stx-mac-ink) 14%, transparent);
|
|
427
|
+
position: relative;
|
|
428
|
+
display: inline-flex;
|
|
429
|
+
align-items: center;
|
|
430
|
+
max-width: 100%;
|
|
431
|
+
height: 20px;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.stx-mac-popup-select {
|
|
435
|
+
box-sizing: border-box;
|
|
436
|
+
max-width: 100%;
|
|
437
|
+
height: 20px;
|
|
438
|
+
margin: 0;
|
|
439
|
+
padding: 0 28px 0 6px;
|
|
440
|
+
border: 0;
|
|
441
|
+
border-radius: 10px;
|
|
442
|
+
background: transparent;
|
|
443
|
+
color: var(--stx-mac-ink);
|
|
444
|
+
font: inherit;
|
|
445
|
+
line-height: 20px;
|
|
446
|
+
letter-spacing: inherit;
|
|
447
|
+
text-align: right;
|
|
448
|
+
text-align-last: right;
|
|
449
|
+
field-sizing: content;
|
|
450
|
+
-webkit-appearance: none;
|
|
451
|
+
appearance: none;
|
|
452
|
+
cursor: default;
|
|
453
|
+
outline: none;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.stx-mac-popup-select:focus-visible {
|
|
457
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.stx-mac-popup-select[aria-invalid='true'] {
|
|
461
|
+
color: var(--stx-mac-danger);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.stx-mac-popup-select:disabled,
|
|
465
|
+
.stx-mac-popup-select:disabled + .stx-mac-popup-disc {
|
|
466
|
+
opacity: 0.5;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.stx-mac-popup-disc {
|
|
470
|
+
position: absolute;
|
|
471
|
+
top: 0;
|
|
472
|
+
right: 0;
|
|
473
|
+
width: 20px;
|
|
474
|
+
height: 20px;
|
|
475
|
+
border-radius: 50%;
|
|
476
|
+
background: var(--stx-mac-popup-disc);
|
|
477
|
+
color: var(--stx-mac-ink);
|
|
478
|
+
pointer-events: none;
|
|
479
|
+
transition: background-color 150ms ease;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.stx-mac-popup:hover .stx-mac-popup-select:not(:disabled) + .stx-mac-popup-disc {
|
|
483
|
+
background: var(--stx-mac-popup-disc-hover);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/* The two chevrons, each the corner of a small square turned on its point. */
|
|
487
|
+
.stx-mac-popup-disc::before,
|
|
488
|
+
.stx-mac-popup-disc::after {
|
|
489
|
+
content: '';
|
|
490
|
+
position: absolute;
|
|
491
|
+
left: 7.5px;
|
|
492
|
+
box-sizing: border-box;
|
|
493
|
+
width: 5px;
|
|
494
|
+
height: 5px;
|
|
495
|
+
border: solid currentColor;
|
|
496
|
+
border-width: 1.5px 0 0 1.5px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.stx-mac-popup-disc::before {
|
|
500
|
+
top: 5.5px;
|
|
501
|
+
transform: rotate(45deg);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.stx-mac-popup-disc::after {
|
|
505
|
+
top: 9.5px;
|
|
506
|
+
transform: rotate(225deg);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.stx-mac-popup-helper {
|
|
510
|
+
margin: 0;
|
|
511
|
+
font-size: var(--stx-mac-font-size-small);
|
|
512
|
+
letter-spacing: 0;
|
|
513
|
+
color: var(--stx-mac-ink-secondary);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.stx-mac-popup-helper[data-error='true'] {
|
|
517
|
+
color: var(--stx-mac-danger);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@media (prefers-reduced-motion: reduce) {
|
|
521
|
+
.stx-mac-popup-disc {
|
|
522
|
+
transition: none;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
@media (prefers-contrast: more) {
|
|
527
|
+
.stx-mac-popup-disc {
|
|
528
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
</style>
|
package/src/ui/select/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface SelectProps {
|
|
|
20
20
|
placeholder?: string
|
|
21
21
|
disabled?: boolean
|
|
22
22
|
size?: 'sm' | 'md' | 'lg'
|
|
23
|
+
/** `'mac'` draws the Mac pop-up button from the `--stx-mac-*` tokens; `size` is not read. */
|
|
24
|
+
variant?: 'mac'
|
|
23
25
|
error?: boolean
|
|
24
26
|
label?: string
|
|
25
27
|
helperText?: string
|