@wirecore/wirelayer-recipes 0.9.0 → 0.11.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/dist/avatar.js +5 -5
- package/dist/avatar.js.map +1 -1
- package/dist/collections.js +2 -2
- package/dist/collections.js.map +1 -1
- package/dist/controls.js +1 -1
- package/dist/controls.js.map +1 -1
- package/dist/hierarchy.d.ts.map +1 -1
- package/dist/hierarchy.js +22 -10
- package/dist/hierarchy.js.map +1 -1
- package/dist/i18n.d.ts +4 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +4 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs.js +4 -4
- package/dist/inputs.js.map +1 -1
- package/dist/locales/ar.d.ts.map +1 -1
- package/dist/locales/ar.js +4 -0
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/cs.d.ts.map +1 -1
- package/dist/locales/cs.js +4 -0
- package/dist/locales/cs.js.map +1 -1
- package/dist/locales/de.d.ts +4 -0
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +4 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/es.d.ts.map +1 -1
- package/dist/locales/es.js +4 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts.map +1 -1
- package/dist/locales/fr.js +4 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/hu.d.ts.map +1 -1
- package/dist/locales/hu.js +4 -0
- package/dist/locales/hu.js.map +1 -1
- package/dist/locales/it.d.ts.map +1 -1
- package/dist/locales/it.js +4 -0
- package/dist/locales/it.js.map +1 -1
- package/dist/locales/lv.d.ts.map +1 -1
- package/dist/locales/lv.js +4 -0
- package/dist/locales/lv.js.map +1 -1
- package/dist/locales/nl.d.ts.map +1 -1
- package/dist/locales/nl.js +4 -0
- package/dist/locales/nl.js.map +1 -1
- package/dist/locales/pl.d.ts.map +1 -1
- package/dist/locales/pl.js +4 -0
- package/dist/locales/pl.js.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/locales/pt-BR.js +1 -0
- package/dist/locales/pt-BR.js.map +1 -1
- package/dist/locales/pt.d.ts.map +1 -1
- package/dist/locales/pt.js +4 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/locales/tr.d.ts.map +1 -1
- package/dist/locales/tr.js +4 -0
- package/dist/locales/tr.js.map +1 -1
- package/dist/media.js +2 -2
- package/dist/native/display.js +5 -5
- package/dist/native/display.js.map +1 -1
- package/dist/native/form.d.ts +7 -7
- package/dist/native/form.d.ts.map +1 -1
- package/dist/native/form.js +20 -8
- package/dist/native/form.js.map +1 -1
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.d.ts.map +1 -1
- package/dist/native/index.js +1 -0
- package/dist/native/index.js.map +1 -1
- package/dist/native/inputs.js +1 -1
- package/dist/native/inputs.js.map +1 -1
- package/dist/native/overlay.js +2 -2
- package/dist/native/overlay.js.map +1 -1
- package/dist/native/picker.d.ts.map +1 -1
- package/dist/native/picker.js +11 -3
- package/dist/native/picker.js.map +1 -1
- package/dist/native/tv.d.ts.map +1 -1
- package/dist/native/tv.js +2 -0
- package/dist/native/tv.js.map +1 -1
- package/dist/native/widgets.js +4 -4
- package/dist/native/widgets.js.map +1 -1
- package/dist/overlay.js +2 -2
- package/dist/overlay.js.map +1 -1
- package/dist/patterns.js +1 -1
- package/dist/patterns.js.map +1 -1
- package/dist/selection.js +1 -1
- package/dist/selection.js.map +1 -1
- package/dist/sortable.d.ts +7 -0
- package/dist/sortable.d.ts.map +1 -1
- package/dist/sortable.js +76 -17
- package/dist/sortable.js.map +1 -1
- package/dist/sources/avatar.css +1 -1
- package/dist/sources/cascadeSelect.css +1 -1
- package/dist/sources/checkbox.css +1 -1
- package/dist/sources/dialog.css +1 -1
- package/dist/sources/gallery.css +1 -1
- package/dist/sources/listbox.css +1 -1
- package/dist/sources/multiSelect.css +1 -1
- package/dist/sources/orderList.css +1 -1
- package/dist/sources/pickList.css +1 -1
- package/dist/sources/selectionCard.css +1 -1
- package/dist/sources/timeGrid.css +1 -1
- package/dist/sources/tree.css +1 -1
- package/dist/sources/treeSelect.css +1 -1
- package/dist/tour-steps.d.ts +21 -0
- package/dist/tour-steps.d.ts.map +1 -0
- package/dist/tour-steps.js +41 -0
- package/dist/tour-steps.js.map +1 -0
- package/dist/tv.js +2 -2
- package/dist/tv.js.map +1 -1
- package/package.json +1 -1
- package/src/avatar.ts +5 -5
- package/src/collections.ts +2 -2
- package/src/controls.ts +1 -1
- package/src/hierarchy.ts +22 -10
- package/src/i18n.ts +5 -0
- package/src/index.ts +1 -0
- package/src/inputs.ts +4 -4
- package/src/locales/ar.ts +5 -0
- package/src/locales/cs.ts +5 -0
- package/src/locales/de.ts +5 -0
- package/src/locales/es.ts +5 -0
- package/src/locales/fr.ts +5 -0
- package/src/locales/hu.ts +5 -0
- package/src/locales/it.ts +5 -0
- package/src/locales/lv.ts +5 -0
- package/src/locales/nl.ts +5 -0
- package/src/locales/pl.ts +5 -0
- package/src/locales/pt-BR.ts +2 -0
- package/src/locales/pt.ts +5 -0
- package/src/locales/tr.ts +5 -0
- package/src/media.ts +2 -2
- package/src/native/display.ts +5 -5
- package/src/native/form.ts +21 -8
- package/src/native/index.ts +1 -0
- package/src/native/inputs.ts +1 -1
- package/src/native/overlay.ts +2 -2
- package/src/native/picker.ts +11 -3
- package/src/native/tv.ts +2 -0
- package/src/native/widgets.ts +4 -4
- package/src/overlay.ts +2 -2
- package/src/patterns.ts +1 -1
- package/src/selection.ts +1 -1
- package/src/sortable.ts +78 -17
- package/src/tour-steps.ts +52 -0
- package/src/tv.ts +2 -2
package/src/media.ts
CHANGED
|
@@ -72,7 +72,7 @@ export const gallery = tv({
|
|
|
72
72
|
// Fullscreen view: a dialog filling the screen
|
|
73
73
|
positioner: 'fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-8',
|
|
74
74
|
content: [
|
|
75
|
-
'flex max-h-full w-full max-w-6xl flex-col gap-3 overflow-y-auto rounded-
|
|
75
|
+
'flex max-h-full w-full max-w-6xl flex-col gap-3 overflow-y-auto rounded-dialog border border-line-2 bg-card p-4 text-fg outline-none',
|
|
76
76
|
'motion-safe:data-[state=open]:animate-dialog-in motion-safe:data-[state=closed]:animate-dialog-out',
|
|
77
77
|
],
|
|
78
78
|
header: 'flex items-center justify-between gap-3',
|
|
@@ -82,7 +82,7 @@ export const gallery = tv({
|
|
|
82
82
|
video: 'aspect-video w-full rounded-xl bg-black',
|
|
83
83
|
/** Lightbox (`tools`): toolbar, zoomable stage, the zoom in percent and the keyboard help */
|
|
84
84
|
lightbox: [
|
|
85
|
-
'flex max-h-full w-full max-w-6xl flex-col gap-3 overflow-hidden rounded-
|
|
85
|
+
'flex max-h-full w-full max-w-6xl flex-col gap-3 overflow-hidden rounded-dialog border border-line-2 bg-card p-4 text-fg outline-none',
|
|
86
86
|
'motion-safe:data-[state=open]:animate-dialog-in motion-safe:data-[state=closed]:animate-dialog-out',
|
|
87
87
|
'[&:fullscreen]:max-w-none [&:fullscreen]:rounded-none [&:fullscreen]:border-0',
|
|
88
88
|
],
|
package/src/native/display.ts
CHANGED
|
@@ -168,11 +168,11 @@ export const avatar = tv({
|
|
|
168
168
|
},
|
|
169
169
|
},
|
|
170
170
|
compoundVariants: [
|
|
171
|
-
{ shape: 'square', size: 'sm', class: { base: 'rounded-
|
|
172
|
-
{ shape: 'square', size: 'md', class: { base: 'rounded-[10px]' } },
|
|
173
|
-
{ shape: 'square', size: 'lg', class: { base: 'rounded-
|
|
174
|
-
{ shape: 'square', size: 'xl', class: { base: 'rounded-
|
|
175
|
-
{ shape: 'square', size: '2xl', class: { base: 'rounded-[20px]' } },
|
|
171
|
+
{ shape: 'square', size: 'sm', class: { base: 'rounded-[var(--wc-avatar-radius,8px)]' } },
|
|
172
|
+
{ shape: 'square', size: 'md', class: { base: 'rounded-[var(--wc-avatar-radius,10px)]' } },
|
|
173
|
+
{ shape: 'square', size: 'lg', class: { base: 'rounded-[var(--wc-avatar-radius,12px)]' } },
|
|
174
|
+
{ shape: 'square', size: 'xl', class: { base: 'rounded-[var(--wc-avatar-radius,16px)]' } },
|
|
175
|
+
{ shape: 'square', size: '2xl', class: { base: 'rounded-[var(--wc-avatar-radius,20px)]' } },
|
|
176
176
|
],
|
|
177
177
|
defaultVariants: {
|
|
178
178
|
variant: 'soft',
|
package/src/native/form.ts
CHANGED
|
@@ -47,9 +47,21 @@ export const input = tv({
|
|
|
47
47
|
},
|
|
48
48
|
variants: {
|
|
49
49
|
size: {
|
|
50
|
-
sm: {
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
sm: {
|
|
51
|
+
base: 'h-8 rounded-[var(--wc-control-radius-sm,6px)]',
|
|
52
|
+
control: 'px-2.5 text-[13px]',
|
|
53
|
+
icon: 'ml-2.5 size-3.5',
|
|
54
|
+
},
|
|
55
|
+
md: {
|
|
56
|
+
base: 'h-10 rounded-[var(--wc-control-radius-md,8px)]',
|
|
57
|
+
control: 'px-3 text-[15px]',
|
|
58
|
+
icon: 'ml-3 size-4',
|
|
59
|
+
},
|
|
60
|
+
lg: {
|
|
61
|
+
base: 'h-12 rounded-[var(--wc-control-radius-lg,10px)]',
|
|
62
|
+
control: 'px-4 text-base',
|
|
63
|
+
icon: 'ml-4 size-[18px]',
|
|
64
|
+
},
|
|
53
65
|
},
|
|
54
66
|
focused: {
|
|
55
67
|
true: { base: 'border-primary' },
|
|
@@ -78,7 +90,7 @@ export const input = tv({
|
|
|
78
90
|
});
|
|
79
91
|
|
|
80
92
|
export const textarea = tv({
|
|
81
|
-
base: 'min-h-24 w-full rounded-
|
|
93
|
+
base: 'min-h-24 w-full rounded-[var(--wc-control-radius-md,8px)] border border-line-strong bg-bg px-3 py-[9px] font-sans text-[15px] leading-6 text-fg web:outline-none',
|
|
82
94
|
variants: {
|
|
83
95
|
focused: {
|
|
84
96
|
true: 'border-primary',
|
|
@@ -93,9 +105,9 @@ export const textarea = tv({
|
|
|
93
105
|
true: 'border-line bg-bg-2 text-muted',
|
|
94
106
|
},
|
|
95
107
|
size: {
|
|
96
|
-
sm: 'rounded-
|
|
108
|
+
sm: 'rounded-[var(--wc-control-radius-sm,6px)] px-2.5 py-1.5 text-[13px] leading-5',
|
|
97
109
|
md: {},
|
|
98
|
-
lg: 'rounded-[10px] px-4 py-3 text-base',
|
|
110
|
+
lg: 'rounded-[var(--wc-control-radius-lg,10px)] px-4 py-3 text-base',
|
|
99
111
|
},
|
|
100
112
|
/** Monospace font of the theme – for keys, codes and logs */
|
|
101
113
|
mono: {
|
|
@@ -129,7 +141,8 @@ export const textareaParts = tv({
|
|
|
129
141
|
export const checkbox = tv({
|
|
130
142
|
slots: {
|
|
131
143
|
base: ['flex-row items-start gap-2.5', pressable],
|
|
132
|
-
control:
|
|
144
|
+
control:
|
|
145
|
+
'mt-px size-[18px] shrink-0 items-center justify-center rounded-[var(--wc-checkbox-radius,5px)] border border-line-strong',
|
|
133
146
|
icon: 'size-[13px] text-on-primary',
|
|
134
147
|
label: 'min-w-0 shrink font-sans text-sm leading-5 text-muted',
|
|
135
148
|
},
|
|
@@ -192,7 +205,7 @@ export const selectionCard = tv({
|
|
|
192
205
|
},
|
|
193
206
|
variants: {
|
|
194
207
|
type: {
|
|
195
|
-
checkbox: { control: 'rounded-[5px]' },
|
|
208
|
+
checkbox: { control: 'rounded-[var(--wc-checkbox-radius,5px)]' },
|
|
196
209
|
radio: { control: 'rounded-full' },
|
|
197
210
|
},
|
|
198
211
|
checked: {
|
package/src/native/index.ts
CHANGED
|
@@ -472,6 +472,7 @@ export {
|
|
|
472
472
|
type SortableTexts,
|
|
473
473
|
} from '../sortable.js';
|
|
474
474
|
export { moveItem } from '../data-table.js';
|
|
475
|
+
export { prepareTourStep, tourSkipTarget, type TourStepPreparation } from '../tour-steps.js';
|
|
475
476
|
export { kanbanLimitState } from '../apps.js';
|
|
476
477
|
// RN part 3: scheduler and gantt
|
|
477
478
|
export { gantt, scheduler } from './scheduler.js';
|
package/src/native/inputs.ts
CHANGED
|
@@ -113,7 +113,7 @@ export const phoneInput = tv({
|
|
|
113
113
|
/** Entries as chips with a text field after them (TagsInput, Autocomplete multiple) */
|
|
114
114
|
export const tagsInput = tv({
|
|
115
115
|
slots: {
|
|
116
|
-
base: 'min-h-10 w-full flex-row flex-wrap items-center gap-1 rounded-
|
|
116
|
+
base: 'min-h-10 w-full flex-row flex-wrap items-center gap-1 rounded-[var(--wc-control-radius-md,8px)] border border-line-strong bg-bg px-1.5 py-1',
|
|
117
117
|
tag: 'h-7 flex-row items-center rounded-full bg-line pl-2.5',
|
|
118
118
|
tagText: 'font-sans-medium text-[13px] text-fg',
|
|
119
119
|
tagRemove: ['-my-2 size-9 items-center justify-center rounded-full', pressable],
|
package/src/native/overlay.ts
CHANGED
|
@@ -27,9 +27,9 @@ export const dialog = tv({
|
|
|
27
27
|
backdrop: 'flex-1 items-center justify-center bg-black/60 p-4',
|
|
28
28
|
/** Behind the content: pressing outside closes */
|
|
29
29
|
dismissArea: 'absolute inset-0',
|
|
30
|
-
content: 'w-full max-w-[400px] rounded-
|
|
30
|
+
content: 'w-full max-w-[400px] rounded-dialog border border-line-2 bg-card',
|
|
31
31
|
header: 'flex-row items-center justify-between gap-3 pt-4 pr-4 pl-[18px]',
|
|
32
|
-
iconBox: 'size-9 items-center justify-center rounded-[10px]',
|
|
32
|
+
iconBox: 'size-9 items-center justify-center rounded-[var(--wc-dialog-icon-radius,10px)]',
|
|
33
33
|
icon: 'size-[18px]',
|
|
34
34
|
close: [
|
|
35
35
|
'ml-auto size-8 items-center justify-center rounded-full',
|
package/src/native/picker.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const sheetSize = tv({
|
|
|
33
33
|
export const select = tv({
|
|
34
34
|
slots: {
|
|
35
35
|
trigger: [
|
|
36
|
-
'h-10 w-full flex-row items-center justify-between gap-2.5 rounded-
|
|
36
|
+
'h-10 w-full flex-row items-center justify-between gap-2.5 rounded-[var(--wc-control-radius-md,8px)] border border-line-strong bg-bg pr-2.5 pl-3',
|
|
37
37
|
pressable,
|
|
38
38
|
'active:opacity-100',
|
|
39
39
|
],
|
|
@@ -76,9 +76,17 @@ export const select = tv({
|
|
|
76
76
|
true: { trigger: 'border-primary' },
|
|
77
77
|
},
|
|
78
78
|
size: {
|
|
79
|
-
sm: {
|
|
79
|
+
sm: {
|
|
80
|
+
trigger: 'h-8 rounded-[var(--wc-control-radius-sm,6px)] pl-2.5',
|
|
81
|
+
valueText: 'text-[13px]',
|
|
82
|
+
placeholder: 'text-[13px]',
|
|
83
|
+
},
|
|
80
84
|
md: {},
|
|
81
|
-
lg: {
|
|
85
|
+
lg: {
|
|
86
|
+
trigger: 'h-12 rounded-[var(--wc-control-radius-lg,10px)] pl-4',
|
|
87
|
+
valueText: 'text-base',
|
|
88
|
+
placeholder: 'text-base',
|
|
89
|
+
},
|
|
82
90
|
},
|
|
83
91
|
/** The chips make the trigger grow with them */
|
|
84
92
|
hasChips: {
|
package/src/native/tv.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { createTV } from 'tailwind-variants';
|
|
|
7
7
|
export const tv = createTV({
|
|
8
8
|
twMergeConfig: {
|
|
9
9
|
extend: {
|
|
10
|
+
// rounded-card, -dialog … are radii, so rounded-none (a full-screen dialog, `classes`) replaces them
|
|
11
|
+
theme: { radius: ['popup', 'card', 'panel', 'dialog'] },
|
|
10
12
|
classGroups: {
|
|
11
13
|
'font-family': [{ font: ['sans', 'sans-medium', 'sans-semibold', 'sans-bold', 'mono'] }],
|
|
12
14
|
},
|
package/src/native/widgets.ts
CHANGED
|
@@ -63,7 +63,7 @@ export const timeGrid = tv({
|
|
|
63
63
|
label: 'font-sans-medium text-[13px] text-fg',
|
|
64
64
|
grid: 'flex-row flex-wrap -m-1',
|
|
65
65
|
cell: 'p-1',
|
|
66
|
-
slot: ['items-center justify-center rounded-
|
|
66
|
+
slot: ['items-center justify-center rounded-[var(--wc-control-radius-md,8px)] border border-line-2', pressable],
|
|
67
67
|
slotText: 'font-sans-medium text-fg',
|
|
68
68
|
status: 'font-sans text-sm text-muted',
|
|
69
69
|
statusRow: 'flex-row items-center gap-2',
|
|
@@ -117,7 +117,7 @@ export const miniCalendar = tv({
|
|
|
117
117
|
/** DurationInput: one number field per unit */
|
|
118
118
|
export const durationInput = tv({
|
|
119
119
|
slots: {
|
|
120
|
-
base: 'w-full flex-row items-center gap-2 rounded-
|
|
120
|
+
base: 'w-full flex-row items-center gap-2 rounded-[var(--wc-control-radius-md,8px)] border border-line-strong bg-bg px-3',
|
|
121
121
|
part: 'flex-row items-baseline gap-1',
|
|
122
122
|
control: 'w-10 py-2 text-right font-mono text-[15px] text-fg web:outline-none',
|
|
123
123
|
unit: 'font-sans text-xs text-muted',
|
|
@@ -125,9 +125,9 @@ export const durationInput = tv({
|
|
|
125
125
|
},
|
|
126
126
|
variants: {
|
|
127
127
|
size: {
|
|
128
|
-
sm: { base: 'h-8 rounded-
|
|
128
|
+
sm: { base: 'h-8 rounded-[var(--wc-control-radius-sm,6px)] px-2.5' },
|
|
129
129
|
md: { base: 'h-10' },
|
|
130
|
-
lg: { base: 'h-12 rounded-[10px] px-4' },
|
|
130
|
+
lg: { base: 'h-12 rounded-[var(--wc-control-radius-lg,10px)] px-4' },
|
|
131
131
|
},
|
|
132
132
|
focused: {
|
|
133
133
|
true: { base: 'border-primary' },
|
package/src/overlay.ts
CHANGED
|
@@ -102,12 +102,12 @@ export const dialog = tv({
|
|
|
102
102
|
positioner: 'fixed inset-0 z-50 flex items-center justify-center overflow-y-auto p-4',
|
|
103
103
|
content: [
|
|
104
104
|
// Width from --wc-dialog-w: set by `size`, or your own, e.g. style="--wc-dialog-w: 36rem"
|
|
105
|
-
'flex w-full max-w-[var(--wc-dialog-w,400px)] flex-col rounded-
|
|
105
|
+
'flex w-full max-w-[var(--wc-dialog-w,400px)] flex-col rounded-dialog border border-line-2 bg-card text-fg outline-none',
|
|
106
106
|
'shadow-[0_24px_48px_-20px_rgba(0,0,0,.55)]',
|
|
107
107
|
'motion-safe:data-[state=open]:animate-dialog-in motion-safe:data-[state=closed]:animate-dialog-out',
|
|
108
108
|
],
|
|
109
109
|
header: 'flex items-center justify-between gap-3 pt-4 pe-4 ps-[18px]',
|
|
110
|
-
iconBox: 'flex size-9 items-center justify-center rounded-[10px]',
|
|
110
|
+
iconBox: 'flex size-9 items-center justify-center rounded-[var(--wc-dialog-icon-radius,10px)]',
|
|
111
111
|
icon: 'size-[18px]',
|
|
112
112
|
close: [
|
|
113
113
|
'ms-auto flex size-8 items-center justify-center rounded-full text-muted hover:bg-line hover:text-fg',
|
package/src/patterns.ts
CHANGED
|
@@ -156,7 +156,7 @@ export const selectionCard = tv({
|
|
|
156
156
|
},
|
|
157
157
|
variants: {
|
|
158
158
|
type: {
|
|
159
|
-
checkbox: { control: 'rounded-[5px]' },
|
|
159
|
+
checkbox: { control: 'rounded-[var(--wc-checkbox-radius,5px)]' },
|
|
160
160
|
radio: {
|
|
161
161
|
control:
|
|
162
162
|
'rounded-full data-[state=checked]:bg-transparent after:size-2 after:rounded-full data-[state=checked]:after:bg-primary forced-colors:data-[state=checked]:after:bg-[Highlight]',
|
package/src/selection.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const checkbox = tv({
|
|
|
8
8
|
slots: {
|
|
9
9
|
base: 'inline-flex cursor-pointer items-start gap-2.5 text-sm leading-[1.45] text-muted data-disabled:cursor-not-allowed data-disabled:opacity-40',
|
|
10
10
|
control: [
|
|
11
|
-
'mt-px flex size-[18px] shrink-0 items-center justify-center rounded-[5px] border border-line-strong text-on-primary',
|
|
11
|
+
'mt-px flex size-[18px] shrink-0 items-center justify-center rounded-[var(--wc-checkbox-radius,5px)] border border-line-strong text-on-primary',
|
|
12
12
|
'transition-colors motion-reduce:transition-none data-invalid:border-danger',
|
|
13
13
|
'data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary',
|
|
14
14
|
'forced-colors:data-[state=checked]:forced-color-adjust-none forced-colors:data-[state=checked]:border-[Highlight] forced-colors:data-[state=checked]:bg-[Highlight] forced-colors:data-[state=checked]:text-[HighlightText]',
|
package/src/sortable.ts
CHANGED
|
@@ -77,6 +77,8 @@ export interface SortableTexts {
|
|
|
77
77
|
movedTo: (item: string, container: string, position: number, count: number) => string;
|
|
78
78
|
dropped: (item: string, position: number, count: number) => string;
|
|
79
79
|
cancelled: (item: string, position: number, count: number) => string;
|
|
80
|
+
/** A copy out of a source list was dropped nowhere (or Escape) */
|
|
81
|
+
copyCancelled: (item: string) => string;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/** A move that changed the order: from and to which container (its `id`) and index */
|
|
@@ -105,6 +107,11 @@ export interface SortableContainer<T = unknown> {
|
|
|
105
107
|
disabled: () => boolean;
|
|
106
108
|
/** Whether an item from another container may come in (default: yes) */
|
|
107
109
|
accepts?: (item: T, from: string) => boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Makes the container a source (e.g. a palette): its items are copied out – this function makes the copy – and
|
|
112
|
+
* it keeps them, takes none in and is not sorted
|
|
113
|
+
*/
|
|
114
|
+
clone?: () => ((item: T) => unknown) | undefined;
|
|
108
115
|
texts: () => SortableTexts;
|
|
109
116
|
/** Focuses the handle at `index` once the new order is rendered (default: in the next task) */
|
|
110
117
|
focus?: (index: number) => void;
|
|
@@ -123,6 +130,8 @@ export interface SortableState {
|
|
|
123
130
|
type Mode = 'keyboard' | 'pointer' | 'click';
|
|
124
131
|
interface Active {
|
|
125
132
|
item: unknown;
|
|
133
|
+
/** The item of a source the carried copy was made of (undefined: the item itself is carried) */
|
|
134
|
+
copyOf: unknown;
|
|
126
135
|
origin: { container: SortableContainer; index: number };
|
|
127
136
|
current: { container: SortableContainer; index: number; count: number };
|
|
128
137
|
mode: Mode;
|
|
@@ -132,6 +141,8 @@ const idleState: SortableState = { grabbed: null, dragging: false, active: false
|
|
|
132
141
|
const DRAG_THRESHOLD = 5;
|
|
133
142
|
/** Attribute of the drag handles: the id of their container (several Sortables can be nested) */
|
|
134
143
|
export const SORTABLE_HANDLE = 'data-sortable-handle';
|
|
144
|
+
const CONTAINER = '[data-sortable-container]';
|
|
145
|
+
const INDEX = 'data-sortable-index';
|
|
135
146
|
|
|
136
147
|
/** Pick-up, keyboard and pointer moves of all Sortables on the page (one item at a time) */
|
|
137
148
|
export class SortableController {
|
|
@@ -170,11 +181,11 @@ export class SortableController {
|
|
|
170
181
|
const active = this.#active;
|
|
171
182
|
if (!active) return idleState;
|
|
172
183
|
const container = this.#containers.get(id);
|
|
173
|
-
const sameGroup = !!container && (container === active.current.container || this.#sameGroup(container));
|
|
174
184
|
return {
|
|
175
185
|
grabbed: active.current.container.id === id ? active.current.index : null,
|
|
176
186
|
dragging: active.mode === 'pointer' && active.current.container.id === id,
|
|
177
|
-
|
|
187
|
+
// Takes the item (a source only takes its copy back – not shown as a target)
|
|
188
|
+
active: !!container && !container.clone?.() && this.#accepts(container),
|
|
178
189
|
};
|
|
179
190
|
}
|
|
180
191
|
|
|
@@ -271,18 +282,30 @@ export class SortableController {
|
|
|
271
282
|
const container = this.#containers.get(id);
|
|
272
283
|
const active = this.#active;
|
|
273
284
|
if (!container || !active || active.mode !== 'click') return;
|
|
274
|
-
|
|
285
|
+
const target = event.target as Element | null;
|
|
286
|
+
if (target?.closest(`[${SORTABLE_HANDLE}]`)) return;
|
|
287
|
+
// A click in a nested container belongs to that one (it bubbles up here)
|
|
288
|
+
if (target?.closest(CONTAINER) !== container.element()) return;
|
|
275
289
|
if (!this.#accepts(container)) return;
|
|
276
290
|
if (container !== active.current.container) this.#moveTo(container, container.items().length);
|
|
277
291
|
this.drop();
|
|
278
292
|
}
|
|
279
293
|
|
|
280
294
|
pickUp(container: SortableContainer, index: number, mode: Mode) {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
295
|
+
const original = container.items()[index];
|
|
296
|
+
if (original === undefined) return;
|
|
297
|
+
// A source carries a copy – made now, so the targets decide on it (`accepts`)
|
|
298
|
+
const clone = container.clone?.();
|
|
299
|
+
const item = clone ? clone(original) : original;
|
|
283
300
|
const count = container.items().length;
|
|
284
|
-
this.#active = {
|
|
285
|
-
|
|
301
|
+
this.#active = {
|
|
302
|
+
item,
|
|
303
|
+
copyOf: clone ? original : undefined,
|
|
304
|
+
origin: { container, index },
|
|
305
|
+
current: { container, index, count },
|
|
306
|
+
mode,
|
|
307
|
+
};
|
|
308
|
+
announce(container.texts().picked(container.itemLabel(original), index + 1, count));
|
|
286
309
|
this.#notify();
|
|
287
310
|
}
|
|
288
311
|
|
|
@@ -292,6 +315,12 @@ export class SortableController {
|
|
|
292
315
|
this.#active = null;
|
|
293
316
|
const { container, index, count } = active.current;
|
|
294
317
|
const { origin } = active;
|
|
318
|
+
// A copy still at its source was not put anywhere
|
|
319
|
+
if (active.copyOf !== undefined && container === origin.container) {
|
|
320
|
+
announce(container.texts().copyCancelled(container.itemLabel(active.copyOf)));
|
|
321
|
+
this.#notify();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
295
324
|
announce(container.texts().dropped(container.itemLabel(active.item), index + 1, count));
|
|
296
325
|
if (origin.container !== container || origin.index !== index) {
|
|
297
326
|
container.onMove?.({
|
|
@@ -311,8 +340,9 @@ export class SortableController {
|
|
|
311
340
|
this.#moveTo(origin.container, origin.index, false);
|
|
312
341
|
const count = active.current.count;
|
|
313
342
|
this.#active = null;
|
|
314
|
-
const
|
|
315
|
-
announce(origin.container.
|
|
343
|
+
const texts = origin.container.texts();
|
|
344
|
+
if (active.copyOf !== undefined) announce(texts.copyCancelled(origin.container.itemLabel(active.copyOf)));
|
|
345
|
+
else announce(texts.cancelled(origin.container.itemLabel(active.item), origin.index + 1, count));
|
|
316
346
|
this.#focus(origin.container, origin.index);
|
|
317
347
|
this.#notify();
|
|
318
348
|
}
|
|
@@ -328,16 +358,36 @@ export class SortableController {
|
|
|
328
358
|
const active = this.#active;
|
|
329
359
|
if (!active) return;
|
|
330
360
|
const { container, index: from } = active.current;
|
|
361
|
+
const origin = active.origin;
|
|
362
|
+
if (active.copyOf !== undefined && target === origin.container) {
|
|
363
|
+
// A source is not sorted; a copy that comes back leaves the container it was put in
|
|
364
|
+
if (container === target) return;
|
|
365
|
+
const rest = [...container.items()];
|
|
366
|
+
rest.splice(from, 1);
|
|
367
|
+
container.setItems(rest);
|
|
368
|
+
const count = target.items().length;
|
|
369
|
+
active.current = { container: target, index: origin.index, count };
|
|
370
|
+
if (speak) announce(target.texts().picked(target.itemLabel(active.copyOf), origin.index + 1, count));
|
|
371
|
+
if (active.mode !== 'pointer') this.#focus(target, origin.index);
|
|
372
|
+
this.#notify();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
331
375
|
let next: unknown[];
|
|
332
376
|
if (target === container) {
|
|
333
377
|
next = moveItem(target.items(), from, index);
|
|
334
378
|
target.setItems(next);
|
|
335
379
|
} else {
|
|
336
380
|
if (!this.#accepts(target)) return;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
381
|
+
if (active.copyOf !== undefined && container === origin.container) {
|
|
382
|
+
// The copy leaves its source: put into the target, the source keeps its item
|
|
383
|
+
next = [...target.items()];
|
|
384
|
+
next.splice(Math.max(0, Math.min(index, next.length)), 0, active.item);
|
|
385
|
+
} else {
|
|
386
|
+
const moved = moveBetween(container.items(), target.items(), from, index);
|
|
387
|
+
container.setItems(moved.from);
|
|
388
|
+
next = moved.to;
|
|
389
|
+
}
|
|
390
|
+
target.setItems(next);
|
|
341
391
|
}
|
|
342
392
|
const position = Math.max(0, Math.min(index, next.length - 1));
|
|
343
393
|
active.current = { container: target, index: position, count: next.length };
|
|
@@ -357,10 +407,20 @@ export class SortableController {
|
|
|
357
407
|
const active = this.#active;
|
|
358
408
|
if (!active || container.disabled()) return false;
|
|
359
409
|
if (container === active.current.container) return true;
|
|
360
|
-
|
|
410
|
+
// A source takes nothing – only its own copy back
|
|
411
|
+
if (container.clone?.()) return active.copyOf !== undefined && container === active.origin.container;
|
|
412
|
+
if (!this.#sameGroup(container) || this.#inside(container)) return false;
|
|
361
413
|
return container.accepts?.(active.item, active.current.container.id) ?? true;
|
|
362
414
|
}
|
|
363
415
|
|
|
416
|
+
/** The container is nested in the carried item – it cannot take the item it is part of */
|
|
417
|
+
#inside(container: SortableContainer): boolean {
|
|
418
|
+
const { current } = this.#active!;
|
|
419
|
+
const item = current.container.element()?.querySelector(`:scope > [${INDEX}="${current.index}"]`);
|
|
420
|
+
const element = container.element();
|
|
421
|
+
return !!item && !!element && item.contains(element);
|
|
422
|
+
}
|
|
423
|
+
|
|
364
424
|
#sameGroup(container: SortableContainer) {
|
|
365
425
|
const group = this.#active?.current.container.group();
|
|
366
426
|
return group !== undefined && container.group() === group;
|
|
@@ -386,12 +446,13 @@ export class SortableController {
|
|
|
386
446
|
/** Container and index under the pointer: an item (its place) or the empty area of a container (the end) */
|
|
387
447
|
#targetAt(x: number, y: number): { container: SortableContainer; index: number } | undefined {
|
|
388
448
|
const element = document.elementFromPoint(x, y);
|
|
389
|
-
|
|
390
|
-
const owner =
|
|
449
|
+
// The innermost container: over a nested one (also its empty area) the item goes there, not to its parent
|
|
450
|
+
const owner = element?.closest<HTMLElement>(CONTAINER);
|
|
391
451
|
const container = owner ? this.#containers.get(owner.dataset.sortableContainer ?? '') : undefined;
|
|
392
452
|
if (!container || !this.#accepts(container)) return undefined;
|
|
393
453
|
const active = this.#active!;
|
|
394
|
-
|
|
454
|
+
const item = element?.closest<HTMLElement>(`[${INDEX}]`);
|
|
455
|
+
if (item && item.parentElement === owner) return { container, index: Number(item.dataset.sortableIndex) };
|
|
395
456
|
const end = container.items().length - (container === active.current.container ? 1 : 0);
|
|
396
457
|
return { container, index: end };
|
|
397
458
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Steps of a tour (Tour) that need the app first: `before` runs (e.g. switches a tab), then the target is awaited
|
|
2
|
+
// for up to `waitFor` ms. Framework-neutral – Vue, React and React Native show the step once it is ready.
|
|
3
|
+
|
|
4
|
+
/** What a step needs before it is shown */
|
|
5
|
+
export interface TourStepPreparation<E> {
|
|
6
|
+
/** Runs first, may be async */
|
|
7
|
+
before?: () => void | Promise<void>;
|
|
8
|
+
/** Finds the target; without it the step has none */
|
|
9
|
+
find?: () => E | null | undefined;
|
|
10
|
+
/** How long (ms) to wait for the target after `before` (default 0: look once) */
|
|
11
|
+
waitFor?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const POLL = 50;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Prepares a step: runs `before`, then looks for the target until it is there or `waitFor` has passed. `ready` gets
|
|
18
|
+
* the target – null without one or when it did not appear (`missing`). Returns the cancel function (the tour moved
|
|
19
|
+
* on or ended): `ready` is not called after it.
|
|
20
|
+
*/
|
|
21
|
+
export function prepareTourStep<E>(
|
|
22
|
+
step: TourStepPreparation<E>,
|
|
23
|
+
ready: (target: E | null, missing: boolean) => void
|
|
24
|
+
): () => void {
|
|
25
|
+
let cancelled = false;
|
|
26
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
27
|
+
const look = (until: number) => {
|
|
28
|
+
if (cancelled) return;
|
|
29
|
+
const target = step.find?.() ?? null;
|
|
30
|
+
if (target || !step.find) return ready(target, false);
|
|
31
|
+
if (Date.now() >= until) return ready(null, true);
|
|
32
|
+
timer = setTimeout(() => look(until), Math.min(POLL, until - Date.now()));
|
|
33
|
+
};
|
|
34
|
+
Promise.resolve()
|
|
35
|
+
.then(step.before)
|
|
36
|
+
// A failing `before` does not stop the tour – the target decides
|
|
37
|
+
.catch((error: unknown) => console.error(error))
|
|
38
|
+
.then(() => look(Date.now() + (step.waitFor ?? 0)));
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The step to go to instead of a skipped one at `index`, in the direction the tour was moving (from `current`):
|
|
47
|
+
* the next or previous index, `'end'` past the last step, undefined before the first (stay)
|
|
48
|
+
*/
|
|
49
|
+
export function tourSkipTarget(index: number, current: number, count: number): number | 'end' | undefined {
|
|
50
|
+
if (index > current) return index + 1 < count ? index + 1 : 'end';
|
|
51
|
+
return index > 0 ? index - 1 : undefined;
|
|
52
|
+
}
|
package/src/tv.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { createTV } from 'tailwind-variants';
|
|
|
3
3
|
/** tailwind-merge knows the custom WireLayer utilities (also used by the @wirecore/wirelayer-css generator). */
|
|
4
4
|
export const twMergeConfig = {
|
|
5
5
|
extend: {
|
|
6
|
-
// rounded-popup, -card and -
|
|
7
|
-
theme: { radius: ['popup', 'card', 'panel'] },
|
|
6
|
+
// rounded-popup, -card, -panel and -dialog are radii, so `classes` like rounded-none (or a Card's size) replace them
|
|
7
|
+
theme: { radius: ['popup', 'card', 'panel', 'dialog'] },
|
|
8
8
|
classGroups: {
|
|
9
9
|
'bg-image': ['bg-glow'],
|
|
10
10
|
'text-gradient': ['text-gradient'],
|