@stacksjs/components 0.2.465 → 0.2.467
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/{ChatLauncher-pc9nqh43.stx → ChatLauncher-3zph4trh.stx} +10 -2
- package/dist/{Combobox-9xh1jgjr.stx → Combobox-9n04ec5w.stx} +16 -4
- package/dist/{CommandPalette-vvaqtqat.stx → CommandPalette-qqjdbcyg.stx} +33 -8
- package/dist/{DateRangePicker-z64qqw84.stx → DateRangePicker-4zmf34e4.stx} +13 -9
- package/dist/Dialog-pdq8rxvy.stx +162 -0
- package/dist/{Drawer-hc0jjpsw.stx → Drawer-nmq100vy.stx} +24 -128
- package/dist/{Dropdown-25160tc6.stx → Dropdown-hb8ks69x.stx} +16 -4
- package/dist/{EmailInput-ffzwvp9r.stx → EmailInput-57626391.stx} +3 -0
- package/dist/{Listbox-32gzxace.stx → Listbox-83j2q4x6.stx} +16 -4
- package/dist/{NumberInput-r2wsh8w9.stx → NumberInput-pq4k2k4k.stx} +31 -10
- package/dist/{PasswordInput-36bws0kf.stx → PasswordInput-dg41ktgd.stx} +8 -1
- package/dist/{Popover-9m42pym0.stx → Popover-khtvagcs.stx} +16 -4
- package/dist/{Select-pv44ngbe.stx → Select-61zv5tr7.stx} +98 -17
- package/dist/Tab-46mxm7f8.stx +35 -0
- package/dist/TabList-76bpx5fp.stx +154 -0
- package/dist/Table-0a4y46vd.stx +43 -0
- package/dist/TableCell-jhvsxw8b.stx +17 -0
- package/dist/TableHeader-krzcx4sv.stx +62 -0
- package/dist/{Tabs-3j2h0jjn.stx → Tabs-1swcxmfb.stx} +4 -1
- package/dist/{TextInput-h9trj9f9.stx → TextInput-nknmz9md.stx} +57 -4
- package/dist/{Textarea-k8cjs4zs.stx → Textarea-9xmhjqp8.stx} +30 -7
- package/dist/{Tooltip-z13bn0pv.stx → Tooltip-rg1c2zrc.stx} +13 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -7
- package/dist/ui/input/index.d.ts +18 -5
- package/dist/ui/select/index.d.ts +1 -1
- package/dist/ui/table/index.d.ts +4 -0
- package/dist/ui/tabs/index.d.ts +35 -3
- package/dist/utils/overlays.d.ts +39 -0
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/ui/chat/ChatLauncher.stx +10 -2
- package/src/ui/combobox/Combobox.stx +16 -4
- package/src/ui/command-palette/CommandPalette.stx +33 -8
- package/src/ui/date-range-picker/DateRangePicker.stx +13 -9
- package/src/ui/dialog/Dialog.stx +29 -169
- package/src/ui/dialog/README.md +5 -0
- package/src/ui/drawer/Drawer.stx +24 -128
- package/src/ui/drawer/README.md +4 -0
- package/src/ui/dropdown/Dropdown.stx +16 -4
- package/src/ui/input/EmailInput.stx +3 -0
- package/src/ui/input/NumberInput.stx +31 -10
- package/src/ui/input/PasswordInput.stx +8 -1
- package/src/ui/input/TextInput.stx +57 -4
- package/src/ui/input/index.ts +31 -5
- package/src/ui/listbox/Listbox.stx +16 -4
- package/src/ui/popover/Popover.stx +16 -4
- package/src/ui/select/README.md +59 -21
- package/src/ui/select/Select.stx +98 -17
- package/src/ui/select/index.ts +8 -1
- package/src/ui/table/README.md +69 -1
- package/src/ui/table/Table.stx +31 -2
- package/src/ui/table/TableCell.stx +8 -1
- package/src/ui/table/TableHeader.stx +47 -5
- package/src/ui/table/index.ts +9 -0
- package/src/ui/tabs/Tab.stx +35 -0
- package/src/ui/tabs/TabList.stx +154 -0
- package/src/ui/tabs/Tabs.stx +4 -1
- package/src/ui/tabs/index.ts +37 -3
- package/src/ui/textarea/Textarea.stx +30 -7
- package/src/ui/tooltip/Tooltip.stx +13 -3
- package/src/utils/overlays.ts +69 -0
- package/dist/Dialog-e9a4r6d0.stx +0 -302
- package/dist/Table-3ek3w95h.stx +0 -14
- package/dist/TableCell-8swtcq8s.stx +0 -10
- package/dist/TableHeader-qsc3e208.stx +0 -20
|
@@ -11,7 +11,7 @@ export const required = $bool($props.required)
|
|
|
11
11
|
export const leftIcon = $props.leftIcon || ''
|
|
12
12
|
export const rightIcon = $props.rightIcon || ''
|
|
13
13
|
export const clearable = $bool($props.clearable)
|
|
14
|
-
export const maxLength = $props.maxLength
|
|
14
|
+
export const maxLength = $props.maxLength ?? $props.maxlength
|
|
15
15
|
export const showCount = $bool($props.showCount)
|
|
16
16
|
export const className = $props.className || ''
|
|
17
17
|
export const inputClassName = $props.inputClassName || ''
|
|
@@ -26,7 +26,14 @@ export const inputClassName = $props.inputClassName || ''
|
|
|
26
26
|
* is 3.25rem of content inside a declared 3rem box - so py-2.5 lands on the
|
|
27
27
|
* 3rem it always claimed. sm and md were already exact.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
/*
|
|
30
|
+
* md -- the size nearly every form uses -- reads the density roles, so an
|
|
31
|
+
* app sets its own field size with --stx-control-px, --stx-control-py,
|
|
32
|
+
* --stx-control-text and --stx-control-leading instead of a className
|
|
33
|
+
* that ties with py-2 on specificity. The fallbacks are px-4 / py-2 /
|
|
34
|
+
* text-base, so nothing moves by default (stacksjs/stx#1993).
|
|
35
|
+
*/
|
|
36
|
+
const sizeClasses = { sm: 'px-3 py-1.5 text-sm', md: 'px-control-x py-control-y text-control', lg: 'px-5 py-2.5 text-lg' }
|
|
30
37
|
const iconSizeClasses = { sm: 'h-4 w-4', md: 'h-5 w-5', lg: 'h-6 w-6' }
|
|
31
38
|
|
|
32
39
|
const baseClasses = 'block w-full border-0 rounded-control shadow-sm ring-1 ring-inset transition-colors duration-200 focus:ring-2 focus:ring-inset bg-field'
|
|
@@ -98,6 +105,44 @@ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
|
|
|
98
105
|
export const form = $props.form || ''
|
|
99
106
|
export const inputMode = $props.inputMode || $props.inputmode || ''
|
|
100
107
|
export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* The text-like input types (stacksjs/stx#2059).
|
|
111
|
+
*
|
|
112
|
+
* `type` was hard-coded to text, so a form with a date, a time, a URL or a
|
|
113
|
+
* phone number in it had to mix library and native controls -- the
|
|
114
|
+
* inconsistency the library exists to remove. email, number and password have
|
|
115
|
+
* components of their own but are accepted here too. Anything else (checkbox,
|
|
116
|
+
* file, range...) is not a text field, and is served as text rather than as a
|
|
117
|
+
* control this markup was not drawn for.
|
|
118
|
+
*/
|
|
119
|
+
const TEXT_TYPES = ['text', 'date', 'time', 'datetime-local', 'month', 'week', 'url', 'tel', 'color', 'search', 'email', 'number', 'password']
|
|
120
|
+
export const type = TEXT_TYPES.includes(String($props.type)) ? String($props.type) : 'text'
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
* The constraint attributes, each emitted only when given AND only on the
|
|
124
|
+
* types HTML applies it to, so a control renders exactly the markup it did
|
|
125
|
+
* before unless the caller asked for something it can use: min/max/step
|
|
126
|
+
* bound the date, time and number types; pattern, minlength, maxlength and
|
|
127
|
+
* size the free-text ones; list every type but password.
|
|
128
|
+
*/
|
|
129
|
+
const RANGED_TYPES = ['date', 'time', 'datetime-local', 'month', 'week', 'number']
|
|
130
|
+
const FREE_TEXT_TYPES = ['text', 'search', 'url', 'tel', 'email', 'password']
|
|
131
|
+
const given = (v) => v !== undefined && v !== null && v !== '' && v !== false
|
|
132
|
+
const ranged = RANGED_TYPES.includes(type)
|
|
133
|
+
export const freeText = FREE_TEXT_TYPES.includes(type)
|
|
134
|
+
export const min = ranged && given($props.min) ? String($props.min) : ''
|
|
135
|
+
export const max = ranged && given($props.max) ? String($props.max) : ''
|
|
136
|
+
export const step = ranged && given($props.step) ? String($props.step) : ''
|
|
137
|
+
export const pattern = freeText && given($props.pattern) ? String($props.pattern) : ''
|
|
138
|
+
export const minLength = freeText && given($props.minLength ?? $props.minlength) ? String($props.minLength ?? $props.minlength) : ''
|
|
139
|
+
/*
|
|
140
|
+
* The HTML `size` attribute (a width in characters). Not `size`, which is
|
|
141
|
+
* already this component's sm / md / lg.
|
|
142
|
+
*/
|
|
143
|
+
export const htmlSize = freeText && given($props.htmlSize) ? String($props.htmlSize) : ''
|
|
144
|
+
export const list = type !== 'password' && given($props.list) ? String($props.list) : ''
|
|
145
|
+
export const autofocus = $bool($props.autofocus)
|
|
101
146
|
</script>
|
|
102
147
|
|
|
103
148
|
<script client>
|
|
@@ -153,7 +198,15 @@ defineExpose({ value: inputValue, clear: onClear })
|
|
|
153
198
|
@if(form)form="{{ form }}"@endif
|
|
154
199
|
@if(inputMode)inputmode="{{ inputMode }}"@endif
|
|
155
200
|
@if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
|
|
156
|
-
type="
|
|
201
|
+
type="{{ type }}"
|
|
202
|
+
@if(min)min="{{ min }}"@endif
|
|
203
|
+
@if(max)max="{{ max }}"@endif
|
|
204
|
+
@if(step)step="{{ step }}"@endif
|
|
205
|
+
@if(pattern)pattern="{{ pattern }}"@endif
|
|
206
|
+
@if(minLength)minlength="{{ minLength }}"@endif
|
|
207
|
+
@if(htmlSize)size="{{ htmlSize }}"@endif
|
|
208
|
+
@if(list)list="{{ list }}"@endif
|
|
209
|
+
@if(autofocus)autofocus@endif
|
|
157
210
|
id="{{ inputId }}"
|
|
158
211
|
class="{{ inputClasses }}"
|
|
159
212
|
|
|
@@ -173,7 +226,7 @@ defineExpose({ value: inputValue, clear: onClear })
|
|
|
173
226
|
@if(disabled)disabled@endif
|
|
174
227
|
@if(readonly)readonly@endif
|
|
175
228
|
@if(required)required@endif
|
|
176
|
-
@if(maxLength)maxlength="{{ maxLength }}"@endif
|
|
229
|
+
@if(maxLength && freeText)maxlength="{{ maxLength }}"@endif
|
|
177
230
|
@input="onInput($event)"
|
|
178
231
|
@change="onChange($event)"
|
|
179
232
|
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
@@ -33,7 +33,14 @@ export const resize = $props.resize || 'vertical'
|
|
|
33
33
|
export const className = $props.className || ''
|
|
34
34
|
|
|
35
35
|
const resizeClasses = { none: 'resize-none', vertical: 'resize-y', horizontal: 'resize-x', both: 'resize' }
|
|
36
|
-
|
|
36
|
+
/*
|
|
37
|
+
* The padding and type read the density roles, so an
|
|
38
|
+
* app sets its own field size with --stx-control-px, --stx-control-py,
|
|
39
|
+
* --stx-control-text and --stx-control-leading instead of a className
|
|
40
|
+
* that ties with py-2 on specificity. The fallbacks are px-4 / py-2 /
|
|
41
|
+
* text-base, so nothing moves by default (stacksjs/stx#1993).
|
|
42
|
+
*/
|
|
43
|
+
const baseClasses = 'block w-full border-0 rounded-control shadow-sm ring-1 ring-inset transition-colors duration-200 focus:ring-2 focus:ring-inset px-control-x py-control-y text-control bg-field'
|
|
37
44
|
/*
|
|
38
45
|
* The two halves of the validity state, exported so the CLIENT can swap them
|
|
39
46
|
* (stacksjs/stx#2047). Toggled per class rather than as a whole string,
|
|
@@ -82,8 +89,12 @@ const emit = defineEmits()
|
|
|
82
89
|
const isError = useReactiveProp('error', {{ error }})
|
|
83
90
|
const autoResize = {{ autoResize }}
|
|
84
91
|
const maxRows = {{ maxRows }}
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
/*
|
|
93
|
+
* Two-way, like TextInput (stacksjs/stx#2059): `v-model:value="bio"` keeps the
|
|
94
|
+
* page's signal in step, with `.lazy` and `.trim` honoured. `input` is still
|
|
95
|
+
* emitted for the callers that listen for it.
|
|
96
|
+
*/
|
|
97
|
+
const inputValue = useModel('value', { default: {{ value }}, parse: (v) => v == null ? '' : String(v) })
|
|
87
98
|
|
|
88
99
|
function resizeTextarea(el) {
|
|
89
100
|
if (!autoResize) return
|
|
@@ -96,19 +107,26 @@ function resizeTextarea(el) {
|
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
function onInput(event) {
|
|
99
|
-
inputValue.
|
|
110
|
+
inputValue.input(event.target.value)
|
|
100
111
|
resizeTextarea(event.target)
|
|
101
|
-
emit('input', inputValue())
|
|
112
|
+
if (!inputValue.modifiers.lazy) emit('input', inputValue())
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function onChange(event) {
|
|
116
|
+
inputValue.change(event.target.value)
|
|
117
|
+
if (inputValue.modifiers.lazy) emit('input', inputValue())
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
onMount(() => {
|
|
105
121
|
if (autoResize) {
|
|
106
|
-
|
|
122
|
+
// The instance's own id: a fixed 'textarea-input' stopped matching
|
|
123
|
+
// anything once ids became unique per instance.
|
|
124
|
+
const el = document.getElementById({{ inputId }})
|
|
107
125
|
if (el) resizeTextarea(el)
|
|
108
126
|
}
|
|
109
127
|
})
|
|
110
128
|
|
|
111
|
-
const charCount = derived(() => `${inputValue().length} / {{ maxLength || 0 }}`)
|
|
129
|
+
const charCount = derived(() => `${String(inputValue()).length} / {{ maxLength || 0 }}`)
|
|
112
130
|
|
|
113
131
|
defineExpose({ value: inputValue })
|
|
114
132
|
</script>
|
|
@@ -137,7 +155,12 @@ defineExpose({ value: inputValue })
|
|
|
137
155
|
@if(readonly)readonly@endif
|
|
138
156
|
@if(required)required@endif
|
|
139
157
|
@if(maxLength)maxlength="{{ maxLength }}"@endif
|
|
158
|
+
{{-- The live value. The served text between the tags is the default
|
|
159
|
+
value; this keeps the element in step when the page's signal moves,
|
|
160
|
+
which nothing did before -- the field had no binding at all. --}}
|
|
161
|
+
:value="inputValue()"
|
|
140
162
|
@input="onInput($event)"
|
|
163
|
+
@change="onChange($event)"
|
|
141
164
|
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
142
165
|
:aria-invalid="isError() ? 'true' : 'false'"
|
|
143
166
|
:class="{ '{{ stateInvalidClasses }}': isError(), '{{ stateValidClasses }}': !isError() }"
|
|
@@ -133,9 +133,19 @@ function hideTooltip() {
|
|
|
133
133
|
* unless this tooltip is the one showing. useEventListener drops it on
|
|
134
134
|
* teardown, so a page of tooltips does not leak one apiece.
|
|
135
135
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
/*
|
|
137
|
+
* While it shows, the tooltip is a popup layer on the page's overlay stack, so
|
|
138
|
+
* Escape dismisses it first: a tooltip over a dialog's field goes, and the
|
|
139
|
+
* dialog stays (stacksjs/stx#2057). It listened on the document itself, where
|
|
140
|
+
* the dialog's listener could take the same Escape.
|
|
141
|
+
*/
|
|
142
|
+
effect(() => {
|
|
143
|
+
if (isVisible()) window.stx.overlays.open(tooltipId, { modal: false, panel: null, onEscape: hideTooltip })
|
|
144
|
+
else window.stx.overlays.close(tooltipId)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
onDestroy(() => {
|
|
148
|
+
window.stx.overlays.close(tooltipId)
|
|
139
149
|
})
|
|
140
150
|
|
|
141
151
|
/*
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export { default as Hero } from './components/Hero.stx';
|
|
|
34
34
|
export { default as Installation } from './components/Installation.stx';
|
|
35
35
|
// Export composables
|
|
36
36
|
export * from './composables/index';
|
|
37
|
+
// The page's overlay stack, for overlays an app draws itself (stacksjs/stx#2057).
|
|
38
|
+
export * from './utils/overlays';
|
|
37
39
|
// Theme seam — see src/theme for how an app redirects the components' colours.
|
|
38
40
|
export * from './theme/index';
|
|
39
41
|
// Export UI components
|