@stacksjs/components 0.2.867 → 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/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/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/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
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script server>
|
|
2
|
-
export const value = $props.value
|
|
3
|
-
export const disabled = $bool($props.disabled)
|
|
4
|
-
export const className = $props.className || ''
|
|
5
|
-
export const as = $props.as || 'div'
|
|
6
|
-
|
|
7
|
-
const baseClasses = 'relative flex cursor-pointer rounded-panel px-5 py-4 shadow-md focus:outline-none transition-all bg-panel text-fg focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-panel'
|
|
8
|
-
const disabledClasses = disabled ? 'opacity-50 cursor-not-allowed' : ''
|
|
9
|
-
export const optionClasses = `${baseClasses} ${disabledClasses} ${className}`.trim()
|
|
10
|
-
export const valueJson = JSON.stringify(value === undefined ? null : value)
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<script client>
|
|
14
|
-
const isDisabled = {{ disabled }}
|
|
15
|
-
/*
|
|
16
|
-
* JSON built on the server and emitted raw, rather than a 'null' sentinel
|
|
17
|
-
* through an ordinary interpolation.
|
|
18
|
-
*
|
|
19
|
-
* A `value === undefined ? 'null' : value` ternary was meant to put the bare
|
|
20
|
-
* token null into the script. An interpolation QUOTES a string, so what it
|
|
21
|
-
* emitted was the four-character string "null" -- truthy, in the one place a
|
|
22
|
-
* value is meant to be absent. JSON.stringify produces the correct literal for
|
|
23
|
-
* every type, null included, and raw interpolation passes it through unquoted.
|
|
24
|
-
* Calendar and DateRangePicker already avoid this sentinel and say why
|
|
25
|
-
* (stacksjs/stx#1981).
|
|
26
|
-
*/
|
|
27
|
-
const optionValue = {!! valueJson !!}
|
|
28
|
-
|
|
29
|
-
function onClick(event) {
|
|
30
|
-
if (isDisabled) return
|
|
31
|
-
event.currentTarget.dispatchEvent(
|
|
32
|
-
new CustomEvent('stx:radio-select', { bubbles: true, detail: optionValue }),
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function onKey(event) {
|
|
37
|
-
if (isDisabled) return
|
|
38
|
-
if (event.key === ' ' || event.key === 'Enter') {
|
|
39
|
-
event.preventDefault()
|
|
40
|
-
event.currentTarget.dispatchEvent(
|
|
41
|
-
new CustomEvent('stx:radio-select', { bubbles: true, detail: optionValue }),
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<component
|
|
48
|
-
:is="{{ as }}"
|
|
49
|
-
class="{{ optionClasses }}"
|
|
50
|
-
data-stx-radio-option
|
|
51
|
-
data-option-value="{{ valueJson }}"
|
|
52
|
-
role="radio"
|
|
53
|
-
aria-checked="false"
|
|
54
|
-
@if(disabled)aria-disabled="true"@endif
|
|
55
|
-
tabindex="{{ disabled ? '-1' : '0' }}"
|
|
56
|
-
@click="onClick($event)"
|
|
57
|
-
@keydown="onKey($event)"
|
|
58
|
-
>
|
|
59
|
-
<slot :disabled="disabled" />
|
|
60
|
-
</component>
|
|
61
|
-
|
|
62
|
-
<style>
|
|
63
|
-
[data-stx-radio-option][data-checked="true"] {
|
|
64
|
-
background-color: rgb(30 58 138 / 0.75);
|
|
65
|
-
color: white;
|
|
66
|
-
}
|
|
67
|
-
.dark [data-stx-radio-option][data-checked="true"] {
|
|
68
|
-
background-color: rgb(30 64 175 / 1);
|
|
69
|
-
}
|
|
70
|
-
</style>
|
package/dist/Switch-s8yf2rvm.stx
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
<script server>
|
|
2
|
-
export const checked = $bool($props.checked)
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Form participation, which a <button role="switch"> cannot have on its own
|
|
6
|
-
* (stacksjs/stx#2043).
|
|
7
|
-
*
|
|
8
|
-
* The control the user operates is a button, and a button is never submitted
|
|
9
|
-
* by name -- so a Switch inside a form contributed nothing to FormData no
|
|
10
|
-
* matter what it was set to. A hidden input carries the state instead, which
|
|
11
|
-
* is what it takes for a custom switch to be readable the way a checkbox is.
|
|
12
|
-
*
|
|
13
|
-
* Only rendered when a `name` is given, so a Switch used as a plain toggle
|
|
14
|
-
* emits exactly the markup it did before.
|
|
15
|
-
*/
|
|
16
|
-
export const name = $props.name || ''
|
|
17
|
-
export const form = $props.form || ''
|
|
18
|
-
export const checkedValue = $props.checkedValue || 'true'
|
|
19
|
-
export const uncheckedValue = $props.uncheckedValue || 'false'
|
|
20
|
-
export const disabled = $bool($props.disabled)
|
|
21
|
-
export const size = $props.size || 'md'
|
|
22
|
-
export const className = $props.className || ''
|
|
23
|
-
export const label = $props.label || ''
|
|
24
|
-
|
|
25
|
-
const sizeConfig = {
|
|
26
|
-
sm: { track: 'h-5 w-9', thumb: 'h-4 w-4', translate: 'translate-x-4' },
|
|
27
|
-
md: { track: 'h-[38px] w-[74px]', thumb: 'h-[34px] w-[34px]', translate: 'translate-x-9' },
|
|
28
|
-
lg: { track: 'h-12 w-24', thumb: 'h-11 w-11', translate: 'translate-x-12' },
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Falls back rather than indexing to undefined: `size="huge"` is a typo, and
|
|
32
|
-
// without this it became `const config = {{ config }}` in the client script --
|
|
33
|
-
// a SyntaxError that killed the whole component rather than mis-sizing it.
|
|
34
|
-
export const config = sizeConfig[size] || sizeConfig.md
|
|
35
|
-
|
|
36
|
-
export const trackBaseClasses = 'relative inline-flex shrink-0 cursor-pointer border-2 border-transparent rounded-full transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-panel'
|
|
37
|
-
export const trackDisabledClasses = 'opacity-50 cursor-not-allowed pointer-events-none'
|
|
38
|
-
export const thumbBaseClasses = 'pointer-events-none inline-block transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out'
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<script client>
|
|
42
|
-
const emit = defineEmits(['change'])
|
|
43
|
-
const isDisabled = useReactiveProp('disabled', {{ disabled }})
|
|
44
|
-
const currentLabel = useReactiveProp('label', {{ label }}, { parse: value => value ?? '' })
|
|
45
|
-
const config = {{ config }}
|
|
46
|
-
const trackBase = {{ trackBaseClasses }}
|
|
47
|
-
const trackDisabled = {{ trackDisabledClasses }}
|
|
48
|
-
const thumbBase = {{ thumbBaseClasses }}
|
|
49
|
-
const extraClass = {{ className }}
|
|
50
|
-
// v-model:checked adds two-way binding; keep @change for existing callers.
|
|
51
|
-
const isChecked = useModel('checked', { default: {{ checked }} })
|
|
52
|
-
|
|
53
|
-
function toggle() {
|
|
54
|
-
if (isDisabled()) return
|
|
55
|
-
isChecked.set(!isChecked())
|
|
56
|
-
emit('change', isChecked())
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function trackClasses() {
|
|
60
|
-
const stateClass = isChecked()
|
|
61
|
-
? 'bg-accent-solid'
|
|
62
|
-
: 'bg-neutral-400 dark:bg-neutral-600'
|
|
63
|
-
return `${trackBase} ${stateClass} ${isDisabled() ? trackDisabled : ''} ${config.track} ${extraClass}`.trim()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// The platform's switch reports its new value itself (a native host's
|
|
67
|
-
// value change); the web's button only says it was pressed.
|
|
68
|
-
function onNativeChange(event) {
|
|
69
|
-
if (isDisabled()) return
|
|
70
|
-
const next = event && typeof event === 'object'
|
|
71
|
-
? (event.value ?? event.nativeEvent?.value ?? event.target?.value)
|
|
72
|
-
: event
|
|
73
|
-
if (typeof next !== 'boolean' || next === isChecked()) return
|
|
74
|
-
isChecked.set(next)
|
|
75
|
-
emit('change', isChecked())
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function thumbClasses() {
|
|
79
|
-
const pos = isChecked() ? config.translate : 'translate-x-0'
|
|
80
|
-
return `${thumbBase} ${pos} ${config.thumb}`.trim()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
defineExpose({ isChecked, toggle })
|
|
84
|
-
</script>
|
|
85
|
-
|
|
86
|
-
@if($native)
|
|
87
|
-
{{-- On a native host the control is the platform's own switch (UISwitch,
|
|
88
|
-
Android's Switch), at the end of its row as a settings row puts it. --}}
|
|
89
|
-
<label class="flex-row items-center justify-between gap-3 {{ className }}">
|
|
90
|
-
<span :if="currentLabel()" :text="currentLabel()" class="flex-1 text-[17px] text-[#000000] dark:text-[#ffffff]">{{ label }}</span>
|
|
91
|
-
@if(name)
|
|
92
|
-
<input
|
|
93
|
-
type="hidden"
|
|
94
|
-
name="{{ name }}"
|
|
95
|
-
@if(disabled)disabled@endif
|
|
96
|
-
:disabled="isDisabled()"
|
|
97
|
-
@if(form)form="{{ form }}"@endif
|
|
98
|
-
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
99
|
-
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
100
|
-
/>
|
|
101
|
-
@endif
|
|
102
|
-
{{-- Keep the controlled value boolean when a nullable model resets. --}}
|
|
103
|
-
<div
|
|
104
|
-
data-native="Switch"
|
|
105
|
-
data-stx-native-host-root
|
|
106
|
-
role="switch"
|
|
107
|
-
value="{{ checked ? 'true' : 'false' }}"
|
|
108
|
-
:value="!!isChecked()"
|
|
109
|
-
aria-label="{{ label || 'Toggle switch' }}"
|
|
110
|
-
:aria-label="currentLabel() || 'Toggle switch'"
|
|
111
|
-
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
112
|
-
@if(disabled)disabled@endif
|
|
113
|
-
:disabled="isDisabled()"
|
|
114
|
-
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
115
|
-
class="text-accent disabled:opacity-50"
|
|
116
|
-
@change="onNativeChange($event)"
|
|
117
|
-
></div>
|
|
118
|
-
</label>
|
|
119
|
-
@else
|
|
120
|
-
<label class="inline-flex items-center gap-3 cursor-pointer">
|
|
121
|
-
<span :if="currentLabel()" :text="currentLabel()" class="text-sm font-medium text-fg-strong">
|
|
122
|
-
{{ label }}
|
|
123
|
-
</span>
|
|
124
|
-
|
|
125
|
-
@if(name)
|
|
126
|
-
{{-- Always submitted, carrying one of two values, rather than a checkbox's
|
|
127
|
-
present-or-absent convention: a reader then gets an explicit "false"
|
|
128
|
-
instead of a missing key, which is the difference between "switched
|
|
129
|
-
off" and "field was never in the form". --}}
|
|
130
|
-
<input
|
|
131
|
-
type="hidden"
|
|
132
|
-
name="{{ name }}"
|
|
133
|
-
@if(disabled)disabled@endif
|
|
134
|
-
:disabled="isDisabled()"
|
|
135
|
-
@if(form)form="{{ form }}"@endif
|
|
136
|
-
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
137
|
-
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
138
|
-
/>
|
|
139
|
-
@endif
|
|
140
|
-
|
|
141
|
-
<button
|
|
142
|
-
data-stx-native-host-root
|
|
143
|
-
type="button"
|
|
144
|
-
role="switch"
|
|
145
|
-
aria-label="{{ label || 'Toggle switch' }}"
|
|
146
|
-
:aria-label="currentLabel() || 'Toggle switch'"
|
|
147
|
-
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
148
|
-
:class="trackClasses()"
|
|
149
|
-
@if(disabled)disabled aria-disabled="true"@endif
|
|
150
|
-
:disabled="isDisabled()"
|
|
151
|
-
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
152
|
-
@click="toggle()"
|
|
153
|
-
>
|
|
154
|
-
<span aria-hidden="true" :class="thumbClasses()"></span>
|
|
155
|
-
</button>
|
|
156
|
-
</label>
|
|
157
|
-
@endif
|