@wirecore/wirelayer-recipes 0.4.0 → 0.5.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.d.ts +12 -3
- package/dist/avatar.d.ts.map +1 -1
- package/dist/avatar.js +28 -7
- package/dist/avatar.js.map +1 -1
- package/dist/data-table.d.ts +10 -0
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +16 -0
- package/dist/data-table.js.map +1 -1
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +1 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +12 -0
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +7 -3
- package/dist/inputs.js.map +1 -1
- package/dist/list-items.d.ts +13 -3
- package/dist/list-items.d.ts.map +1 -1
- package/dist/list-items.js +16 -4
- package/dist/list-items.js.map +1 -1
- package/dist/locales/ar.d.ts.map +1 -1
- package/dist/locales/ar.js +1 -0
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/cs.d.ts.map +1 -1
- package/dist/locales/cs.js +1 -0
- package/dist/locales/cs.js.map +1 -1
- package/dist/locales/de.d.ts +1 -0
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +1 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/es.d.ts.map +1 -1
- package/dist/locales/es.js +1 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts.map +1 -1
- package/dist/locales/fr.js +1 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/hu.d.ts.map +1 -1
- package/dist/locales/hu.js +1 -0
- package/dist/locales/hu.js.map +1 -1
- package/dist/locales/it.d.ts.map +1 -1
- package/dist/locales/it.js +1 -0
- package/dist/locales/it.js.map +1 -1
- package/dist/locales/lv.d.ts.map +1 -1
- package/dist/locales/lv.js +1 -0
- package/dist/locales/lv.js.map +1 -1
- package/dist/locales/nl.d.ts.map +1 -1
- package/dist/locales/nl.js +1 -0
- package/dist/locales/nl.js.map +1 -1
- package/dist/locales/pl.d.ts.map +1 -1
- package/dist/locales/pl.js +1 -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 +1 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/locales/tr.d.ts.map +1 -1
- package/dist/locales/tr.js +1 -0
- package/dist/locales/tr.js.map +1 -1
- package/dist/native/charts.d.ts +3 -3
- package/dist/overlay.d.ts +3 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +7 -6
- package/dist/overlay.js.map +1 -1
- package/dist/selection.d.ts.map +1 -1
- package/dist/selection.js +2 -1
- package/dist/selection.js.map +1 -1
- package/dist/sources/avatar.css +1 -1
- package/dist/sources/datePicker.css +1 -1
- package/dist/sources/dialog.css +1 -1
- package/dist/sources/segmentedControl.css +1 -1
- package/dist/widgets.d.ts +3 -3
- package/package.json +1 -1
- package/src/avatar.ts +29 -7
- package/src/data-table.ts +27 -0
- package/src/i18n.ts +1 -0
- package/src/index.ts +4 -0
- package/src/inputs.ts +8 -3
- package/src/list-items.ts +24 -4
- package/src/locales/ar.ts +1 -0
- package/src/locales/cs.ts +1 -0
- package/src/locales/de.ts +1 -0
- package/src/locales/es.ts +1 -0
- package/src/locales/fr.ts +1 -0
- package/src/locales/hu.ts +1 -0
- package/src/locales/it.ts +1 -0
- package/src/locales/lv.ts +1 -0
- package/src/locales/nl.ts +1 -0
- package/src/locales/pl.ts +1 -0
- package/src/locales/pt-BR.ts +1 -0
- package/src/locales/pt.ts +1 -0
- package/src/locales/tr.ts +1 -0
- package/src/overlay.ts +7 -6
- package/src/selection.ts +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Classes of the WireLayer recipe datePicker – generated by scripts/sources.ts, do not edit */
|
|
2
|
-
@source inline("bg-bg bg-black/40 bg-card bg-transparent border border-collapse border-line border-line-2 border-line-strong border-t bottom-0 cursor-pointer data-[side=bottom]:[--wc-pop-y:-4px] data-[side=top]:[--wc-pop-y:4px] data-[type=literal]:normal-nums data-[type=literal]:px-0 data-[type=literal]:text-muted data-[type=literal]:whitespace-pre data-disabled:bg-bg-2 data-disabled:border-line data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:text-muted data-in-hover-range:not-data-selected:bg-line data-in-range:not-data-selected:bg-line data-invalid:border-danger data-outside-range:invisible data-outside-range:text-muted data-placeholder-shown:text-muted data-placeholder:text-muted data-selected:bg-primary data-selected:text-on-primary data-today:font-normal data-today:font-semibold data-today:no-underline data-today:underline data-today:underline-offset-4 data-unavailable:line-through disabled:cursor-not-allowed disabled:opacity-40 fixed flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 focus-within:border-primary focus:bg-primary focus:text-on-primary font-medium font-mono font-normal font-semibold forced-colors:data-selected:bg-[Highlight] forced-colors:data-selected:forced-color-adjust-none forced-colors:data-selected:text-[HighlightText] forced-colors:focus:bg-[Highlight] forced-colors:focus:forced-color-adjust-none forced-colors:focus:text-[HighlightText] gap-1 gap-1.5 gap-2 gap-4 grid grid-cols-2 h-10 h-12 h-7 h-8 h-full hover:bg-line hover:border-fg hover:text-fg inline-flex inset-0 inset-x-0 items-center items-stretch justify-between justify-center leading-none max-h-64 max-h-[85dvh] min-w-0 min-w-[278px] motion-reduce:transition-none motion-safe:animate-fade-in motion-safe:data-[state=closed]:animate-pop-out motion-safe:data-[state=open]:animate-pop-in mx-auto outline-none overflow-hidden overflow-y-auto p-0 p-3 pe-1 placeholder:text-muted pointer-events-none pt-2.5 px-1 px-1.5 px-2.5 px-3 px-4 px-px relative rounded-[10px] rounded-b-none rounded-full rounded-lg rounded-md rounded-popup rounded-sm rounded-xl rtl:-scale-x-100 self-center shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)] shrink-0 size-3.5 size-4 size-8 size-9 size-full sm:flex-row sm:items-start sr-only tabular-nums text-[11px] text-[13px] text-[15px] text-base text-center text-fg text-inherit text-muted text-sm text-xs transition-colors truncate uppercase w-10 w-11 w-32 w-7 w-8 w-[304px] w-auto w-full z-40 z-50");
|
|
2
|
+
@source inline("absolute bg-bg bg-black/40 bg-card bg-transparent border border-collapse border-line border-line-2 border-line-strong border-t bottom-0 cursor-pointer cursor-text data-[side=bottom]:[--wc-pop-y:-4px] data-[side=top]:[--wc-pop-y:4px] data-[type=literal]:normal-nums data-[type=literal]:px-0 data-[type=literal]:text-muted data-[type=literal]:whitespace-pre data-disabled:bg-bg-2 data-disabled:border-line data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:text-muted data-hidden:opacity-0 data-hidden:pointer-events-none data-in-hover-range:not-data-selected:bg-line data-in-range:not-data-selected:bg-line data-invalid:border-danger data-outside-range:invisible data-outside-range:text-muted data-placeholder-shown:opacity-0 data-placeholder-shown:text-muted data-placeholder:text-muted data-selected:bg-primary data-selected:text-on-primary data-today:font-normal data-today:font-semibold data-today:no-underline data-today:underline data-today:underline-offset-4 data-unavailable:line-through disabled:cursor-not-allowed disabled:opacity-40 fixed flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 focus-within:border-primary focus:bg-primary focus:text-on-primary font-medium font-mono font-normal font-semibold forced-colors:data-selected:bg-[Highlight] forced-colors:data-selected:forced-color-adjust-none forced-colors:data-selected:text-[HighlightText] forced-colors:focus:bg-[Highlight] forced-colors:focus:forced-color-adjust-none forced-colors:focus:text-[HighlightText] gap-1 gap-1.5 gap-2 gap-4 grid grid-cols-2 h-10 h-12 h-7 h-8 h-full hover:bg-line hover:border-fg hover:text-fg inline-flex inset-0 inset-x-0 items-center items-stretch justify-between justify-center leading-none max-h-64 max-h-[85dvh] min-w-0 min-w-[278px] motion-reduce:transition-none motion-safe:animate-fade-in motion-safe:data-[state=closed]:animate-pop-out motion-safe:data-[state=open]:animate-pop-in mx-auto outline-none overflow-hidden overflow-y-auto p-0 p-3 pe-1 placeholder:text-muted pointer-events-none pt-2.5 px-1 px-1.5 px-2.5 px-3 px-4 px-px relative rounded-[10px] rounded-b-none rounded-full rounded-lg rounded-md rounded-popup rounded-sm rounded-xl rtl:-scale-x-100 self-center shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)] shrink-0 size-3.5 size-4 size-8 size-9 size-full sm:flex-row sm:items-start sr-only tabular-nums text-[11px] text-[13px] text-[15px] text-base text-center text-fg text-inherit text-muted text-sm text-xs transition-colors truncate uppercase w-10 w-11 w-32 w-7 w-8 w-[304px] w-auto w-full whitespace-nowrap z-40 z-50");
|
|
3
3
|
:root {
|
|
4
4
|
--wc-recipe-datePicker: 1;
|
|
5
5
|
}
|
package/dist/sources/dialog.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Classes of the WireLayer recipe dialog – generated by scripts/sources.ts, do not edit */
|
|
2
|
-
@source inline("aria-busy:cursor-wait bg-black/60 bg-card bg-danger/14 bg-info/14 bg-line bg-success/14 bg-warn/14 border border-0 border-line border-line-2 border-t cursor-move cursor-pointer disabled:cursor-not-allowed disabled:opacity-40 duration-150 fixed flex flex-1 flex-col flex-wrap focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 font-semibold forced-colors:border forced-colors:border-[ButtonBorder] gap-1.5 gap-2 gap-3 h-full hover:bg-line hover:text-fg inset-0 items-center items-end items-start justify-between justify-center justify-end justify-start leading-[1.55] max-h-full max-h-none max-sm:max-w-none max-w-[
|
|
2
|
+
@source inline("[--wc-dialog-w:320px] [--wc-dialog-w:400px] [--wc-dialog-w:560px] [--wc-dialog-w:800px] aria-busy:cursor-wait bg-black/60 bg-card bg-danger/14 bg-info/14 bg-line bg-success/14 bg-warn/14 border border-0 border-line border-line-2 border-t cursor-move cursor-pointer disabled:cursor-not-allowed disabled:opacity-40 duration-150 fixed flex flex-1 flex-col flex-wrap focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 font-semibold forced-colors:border forced-colors:border-[ButtonBorder] gap-1.5 gap-2 gap-3 h-full hover:bg-line hover:text-fg inset-0 items-center items-end items-start justify-between justify-center justify-end justify-start leading-[1.55] max-h-full max-h-none max-sm:max-w-none max-w-[var(--wc-dialog-w,400px)] max-w-none min-h-0 motion-reduce:transition-none motion-safe:data-[state=closed]:animate-dialog-out motion-safe:data-[state=closed]:animate-fade-out motion-safe:data-[state=open]:animate-dialog-in motion-safe:data-[state=open]:animate-fade-in ms-0 ms-auto outline-none overflow-visible overflow-y-auto p-0 p-4 pb-[18px] pe-4 ps-[18px] pt-3 pt-4 px-4 px-[18px] py-3 rounded-[10px] rounded-[14px] rounded-full rounded-none select-none shadow-[0_24px_48px_-20px_rgba(0,0,0,.55)] size-4 size-8 size-9 size-[18px] text-danger text-fg text-info text-lg text-muted text-sm text-success text-warn touch-none tracking-[-0.02em] transition-[opacity,background-color,border-color,color] w-full z-50");
|
|
3
3
|
:root {
|
|
4
4
|
--wc-recipe-dialog: 1;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Classes of the WireLayer recipe segmentedControl – generated by scripts/sources.ts, do not edit */
|
|
2
|
-
@source inline("border border-line-2 cursor-pointer data-[state=checked]:bg-primary data-[state=checked]:text-on-primary data-disabled:cursor-not-allowed data-disabled:opacity-40 data-focus-visible:outline-2 data-focus-visible:outline-fg data-focus-visible:outline-offset-2 font-mono font-semibold forced-colors:data-[state=checked]:bg-[Highlight] forced-colors:data-[state=checked]:forced-color-adjust-none forced-colors:data-[state=checked]:text-[HighlightText] gap-0.5 gap-1.5 h-8 h-[26px] hover:text-fg inline-flex items-center motion-reduce:transition-none p-[3px] px-2.5 px-3 rounded-full shrink-0 size-3 size-[15px] sr-only text-[11px] text-[13px] text-muted transition-colors whitespace-nowrap");
|
|
2
|
+
@source inline("border border-line-2 cursor-pointer data-[state=checked]:bg-primary data-[state=checked]:text-on-primary data-disabled:cursor-not-allowed data-disabled:opacity-40 data-focus-visible:outline-2 data-focus-visible:outline-fg data-focus-visible:outline-offset-2 font-mono font-semibold forced-colors:data-[state=checked]:bg-[Highlight] forced-colors:data-[state=checked]:forced-color-adjust-none forced-colors:data-[state=checked]:text-[HighlightText] gap-0.5 gap-1.5 h-8 h-[26px] hover:text-fg inline-flex items-center motion-reduce:transition-none p-[3px] px-2.5 px-3 rounded-full shrink-0 size-3 size-[15px] sr-only text-[11px] text-[13px] text-muted transition-colors w-fit whitespace-nowrap");
|
|
3
3
|
:root {
|
|
4
4
|
--wc-recipe-segmentedControl: 1;
|
|
5
5
|
}
|
package/dist/widgets.d.ts
CHANGED
|
@@ -155,12 +155,12 @@ export declare const imageCropper: import("tailwind-variants").TVReturnType<{
|
|
|
155
155
|
viewport?: import("tailwind-variants").ClassValue;
|
|
156
156
|
grid?: import("tailwind-variants").ClassValue;
|
|
157
157
|
toolbar?: import("tailwind-variants").ClassValue;
|
|
158
|
+
selection?: import("tailwind-variants").ClassValue;
|
|
158
159
|
root?: import("tailwind-variants").ClassValue;
|
|
159
160
|
handle?: import("tailwind-variants").ClassValue;
|
|
160
161
|
toolIcon?: import("tailwind-variants").ClassValue;
|
|
161
162
|
tool?: import("tailwind-variants").ClassValue;
|
|
162
163
|
zoom?: import("tailwind-variants").ClassValue;
|
|
163
|
-
selection?: import("tailwind-variants").ClassValue;
|
|
164
164
|
};
|
|
165
165
|
};
|
|
166
166
|
} | {
|
|
@@ -171,12 +171,12 @@ export declare const imageCropper: import("tailwind-variants").TVReturnType<{
|
|
|
171
171
|
viewport?: import("tailwind-variants").ClassValue;
|
|
172
172
|
grid?: import("tailwind-variants").ClassValue;
|
|
173
173
|
toolbar?: import("tailwind-variants").ClassValue;
|
|
174
|
+
selection?: import("tailwind-variants").ClassValue;
|
|
174
175
|
root?: import("tailwind-variants").ClassValue;
|
|
175
176
|
handle?: import("tailwind-variants").ClassValue;
|
|
176
177
|
toolIcon?: import("tailwind-variants").ClassValue;
|
|
177
178
|
tool?: import("tailwind-variants").ClassValue;
|
|
178
179
|
zoom?: import("tailwind-variants").ClassValue;
|
|
179
|
-
selection?: import("tailwind-variants").ClassValue;
|
|
180
180
|
};
|
|
181
181
|
};
|
|
182
182
|
} | {}, {
|
|
@@ -199,12 +199,12 @@ export declare const imageCropper: import("tailwind-variants").TVReturnType<{
|
|
|
199
199
|
viewport?: import("tailwind-variants").ClassValue;
|
|
200
200
|
grid?: import("tailwind-variants").ClassValue;
|
|
201
201
|
toolbar?: import("tailwind-variants").ClassValue;
|
|
202
|
+
selection?: import("tailwind-variants").ClassValue;
|
|
202
203
|
root?: import("tailwind-variants").ClassValue;
|
|
203
204
|
handle?: import("tailwind-variants").ClassValue;
|
|
204
205
|
toolIcon?: import("tailwind-variants").ClassValue;
|
|
205
206
|
tool?: import("tailwind-variants").ClassValue;
|
|
206
207
|
zoom?: import("tailwind-variants").ClassValue;
|
|
207
|
-
selection?: import("tailwind-variants").ClassValue;
|
|
208
208
|
};
|
|
209
209
|
};
|
|
210
210
|
} | {}, {
|
package/package.json
CHANGED
package/src/avatar.ts
CHANGED
|
@@ -8,6 +8,18 @@ export type AvatarColor = 'primary' | 'success' | 'info' | 'warn' | 'danger';
|
|
|
8
8
|
|
|
9
9
|
const avatarColors: AvatarColor[] = ['primary', 'info', 'success', 'warn', 'danger'];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Hover of a tinted avatar button: the tint goes from 14 % to 18 %, like soft buttons from /10 to /14 – more would miss
|
|
13
|
+
* 4.5:1 in some themes (token contrast test)
|
|
14
|
+
*/
|
|
15
|
+
const tintHover: Record<AvatarColor, string> = {
|
|
16
|
+
primary: 'hover:bg-[color-mix(in_srgb,var(--color-primary)_18%,var(--color-card))]',
|
|
17
|
+
success: 'hover:bg-[color-mix(in_srgb,var(--color-success)_18%,var(--color-card))]',
|
|
18
|
+
info: 'hover:bg-[color-mix(in_srgb,var(--color-info)_18%,var(--color-card))]',
|
|
19
|
+
warn: 'hover:bg-[color-mix(in_srgb,var(--color-warn)_18%,var(--color-card))]',
|
|
20
|
+
danger: 'hover:bg-[color-mix(in_srgb,var(--color-danger)_18%,var(--color-card))]',
|
|
21
|
+
};
|
|
22
|
+
|
|
11
23
|
/** The same name always gets the same colour: "Julia Klein" → "info" */
|
|
12
24
|
export function avatarColor(name: string): AvatarColor {
|
|
13
25
|
let hash = 0;
|
|
@@ -56,14 +68,12 @@ export const avatar = tv({
|
|
|
56
68
|
grouped: {
|
|
57
69
|
true: { base: 'border-2 border-card' },
|
|
58
70
|
},
|
|
59
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
|
|
73
|
+
* same look (see the compound variants), so triggers side by side in a bar behave alike
|
|
74
|
+
*/
|
|
60
75
|
interactive: {
|
|
61
|
-
true: {
|
|
62
|
-
base: [
|
|
63
|
-
...pressable,
|
|
64
|
-
'hover:ring-2 hover:ring-line-2 data-[state=open]:ring-2 data-[state=open]:ring-line-2',
|
|
65
|
-
],
|
|
66
|
-
},
|
|
76
|
+
true: { base: pressable },
|
|
67
77
|
},
|
|
68
78
|
},
|
|
69
79
|
compoundVariants: [
|
|
@@ -73,6 +83,18 @@ export const avatar = tv({
|
|
|
73
83
|
{ shape: 'square', size: 'xl', class: { base: 'rounded-2xl' } },
|
|
74
84
|
{ shape: 'square', size: '2xl', class: { base: 'rounded-3xl' } },
|
|
75
85
|
{ grouped: true, variant: 'soft', class: { base: 'bg-bg-2 shadow-[inset_0_0_0_1px_var(--color-line-2)]' } },
|
|
86
|
+
// Hover like IconButton: outline darkens its border, soft (bg-line) the background like `secondary`, solid
|
|
87
|
+
// fades like the filled variants
|
|
88
|
+
{ interactive: true, variant: 'outline', class: { base: 'hover:border-fg' } },
|
|
89
|
+
{ interactive: true, variant: 'soft', class: { base: 'hover:bg-line-2' } },
|
|
90
|
+
{ interactive: true, variant: 'solid', class: { base: 'hover:opacity-85' } },
|
|
91
|
+
...avatarColors.map((color) => ({ interactive: true, color, class: { base: tintHover[color] } })),
|
|
92
|
+
// A loaded image covers the background, and without a border nothing would change: a ring on hover instead
|
|
93
|
+
{
|
|
94
|
+
interactive: true,
|
|
95
|
+
variant: ['soft', 'solid'] as AvatarVariant[],
|
|
96
|
+
class: { base: 'hover:has-[img:not([hidden])]:ring-2 hover:has-[img:not([hidden])]:ring-line-2' },
|
|
97
|
+
},
|
|
76
98
|
],
|
|
77
99
|
defaultVariants: {
|
|
78
100
|
variant: 'soft',
|
package/src/data-table.ts
CHANGED
|
@@ -293,6 +293,20 @@ export function matchesColumnFilter(cell: DataTableCellFilterInput, filter: Data
|
|
|
293
293
|
export const matchesSearch = (values: unknown[], search: string, locale?: string) =>
|
|
294
294
|
!search || values.some((value) => fold(value, locale).includes(fold(search, locale)));
|
|
295
295
|
|
|
296
|
+
/** Whether the extra search text of a row (`rowKeywords`) contains the search – an empty search finds nothing here */
|
|
297
|
+
export const matchesRowKeywords = (
|
|
298
|
+
keywords: string | readonly string[] | null | undefined,
|
|
299
|
+
search: string,
|
|
300
|
+
locale?: string
|
|
301
|
+
) =>
|
|
302
|
+
!!search &&
|
|
303
|
+
keywords !== null &&
|
|
304
|
+
keywords !== undefined &&
|
|
305
|
+
matchesSearch(typeof keywords === 'string' ? [keywords] : [...keywords], search, locale);
|
|
306
|
+
|
|
307
|
+
/** Whether two values of a controlled prop (sorting, filters, ids …) have the same content */
|
|
308
|
+
export const sameTableValue = (a: unknown, b: unknown) => a === b || listValueKey(a) === listValueKey(b);
|
|
309
|
+
|
|
296
310
|
/**
|
|
297
311
|
* The sorting after a click on a column header: ascending → descending → unsorted. With `add` (Shift+click in
|
|
298
312
|
* the multiple mode) the column is added to the existing sorting instead of replacing it.
|
|
@@ -381,6 +395,19 @@ export interface DataTableState {
|
|
|
381
395
|
expanded?: string[];
|
|
382
396
|
selection?: string[];
|
|
383
397
|
density?: 'sm' | 'md' | 'lg';
|
|
398
|
+
/** Whether the filter row is shown (`filterToggle`) */
|
|
399
|
+
showFilters?: boolean;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** A part of the saved state, e.g. for `stateExclude` */
|
|
403
|
+
export type DataTableStateKey = keyof DataTableState;
|
|
404
|
+
|
|
405
|
+
/** The state without the excluded parts */
|
|
406
|
+
export function omitTableState(state: DataTableState, exclude: readonly DataTableStateKey[] = []): DataTableState {
|
|
407
|
+
if (!exclude.length) return state;
|
|
408
|
+
const kept = { ...state };
|
|
409
|
+
for (const key of exclude) delete kept[key];
|
|
410
|
+
return kept;
|
|
384
411
|
}
|
|
385
412
|
|
|
386
413
|
const storageOf = (kind: 'local' | 'session') => {
|
package/src/i18n.ts
CHANGED
|
@@ -563,6 +563,7 @@ const en: Translations = {
|
|
|
563
563
|
exportAll: 'All rows',
|
|
564
564
|
exportSelection: 'Selected rows',
|
|
565
565
|
filterToggle: 'Show filters',
|
|
566
|
+
resetFilters: 'Reset filters',
|
|
566
567
|
rowCount: (count) => (count === 1 ? '1 row' : `${count} rows`),
|
|
567
568
|
filteredCount: (count) => `${count} filtered`,
|
|
568
569
|
copy: (header, value) => `Copy ${value}, ${header}`,
|
package/src/index.ts
CHANGED
|
@@ -537,6 +537,7 @@ export {
|
|
|
537
537
|
matchesColumnFilter,
|
|
538
538
|
matchesConstraint,
|
|
539
539
|
matchesFilter,
|
|
540
|
+
matchesRowKeywords,
|
|
540
541
|
matchesSearch,
|
|
541
542
|
matchModeDefinition,
|
|
542
543
|
matchModeLabel,
|
|
@@ -546,9 +547,11 @@ export {
|
|
|
546
547
|
moveTreeRow,
|
|
547
548
|
nextSorting,
|
|
548
549
|
numberSummary,
|
|
550
|
+
omitTableState,
|
|
549
551
|
printHtml,
|
|
550
552
|
printTableHtml,
|
|
551
553
|
saveTableState,
|
|
554
|
+
sameTableValue,
|
|
552
555
|
toFilterRule,
|
|
553
556
|
type ColumnBlock,
|
|
554
557
|
type PrintCell,
|
|
@@ -563,6 +566,7 @@ export {
|
|
|
563
566
|
type DataTableMatchModeDefinition,
|
|
564
567
|
type DataTableSort,
|
|
565
568
|
type DataTableState,
|
|
569
|
+
type DataTableStateKey,
|
|
566
570
|
} from './data-table.js';
|
|
567
571
|
export {
|
|
568
572
|
fitColumnWidth,
|
package/src/inputs.ts
CHANGED
|
@@ -272,9 +272,12 @@ export const datePicker = tv({
|
|
|
272
272
|
base: 'flex w-full flex-col',
|
|
273
273
|
control: [...box, 'h-10'],
|
|
274
274
|
// Segmented date field (DateInput): one spin button per part, separators come from the locale
|
|
275
|
-
dateInput: 'flex min-w-0 flex-1 items-center px-3',
|
|
276
|
-
// Holds one date, or start – end of a range, in a row
|
|
277
|
-
dateControl: 'flex min-w-0 items-center',
|
|
275
|
+
dateInput: 'relative flex min-w-0 flex-1 items-center px-3',
|
|
276
|
+
// Holds one date, or start – end of a range, in a row; invisible (still usable) while the placeholder shows
|
|
277
|
+
dateControl: 'flex min-w-0 items-center data-placeholder-shown:opacity-0',
|
|
278
|
+
/** Own placeholder of the empty field (`placeholder`) – gives way to the parts on focus */
|
|
279
|
+
placeholder:
|
|
280
|
+
'absolute inset-0 flex cursor-text items-center overflow-hidden px-3 text-[15px] whitespace-nowrap text-muted data-hidden:pointer-events-none data-hidden:opacity-0',
|
|
278
281
|
segments: 'flex items-center text-[15px]',
|
|
279
282
|
segment: [
|
|
280
283
|
'rounded-sm px-px text-fg tabular-nums outline-none data-placeholder-shown:text-muted',
|
|
@@ -380,6 +383,7 @@ export const datePicker = tv({
|
|
|
380
383
|
sm: {
|
|
381
384
|
control: 'h-8 rounded-md',
|
|
382
385
|
dateInput: 'px-2.5',
|
|
386
|
+
placeholder: 'px-2.5 text-[13px]',
|
|
383
387
|
segments: 'text-[13px]',
|
|
384
388
|
multiValue: 'px-2.5 text-[13px]',
|
|
385
389
|
textInput: 'px-2.5 text-[13px]',
|
|
@@ -391,6 +395,7 @@ export const datePicker = tv({
|
|
|
391
395
|
lg: {
|
|
392
396
|
control: 'h-12 rounded-[10px]',
|
|
393
397
|
dateInput: 'px-4',
|
|
398
|
+
placeholder: 'px-4 text-base',
|
|
394
399
|
segments: 'text-base',
|
|
395
400
|
multiValue: 'px-4 text-base',
|
|
396
401
|
textInput: 'px-4 text-base',
|
package/src/list-items.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface ListItemAccessors<T = unknown> {
|
|
|
13
13
|
itemLabel?: ItemAccessor<T, string>;
|
|
14
14
|
itemDisabled?: ItemAccessor<T, boolean>;
|
|
15
15
|
itemGroup?: ItemAccessor<T, string | null | undefined>;
|
|
16
|
+
/** More text the search finds an item by, besides its label (e.g. the name of its category) */
|
|
17
|
+
itemKeywords?: ItemAccessor<T, string | readonly string[] | null | undefined>;
|
|
16
18
|
// The value type is unknown here – any accessor of the component's value type fits
|
|
17
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
20
|
valueKey?: ItemAccessor<any, string | number>;
|
|
@@ -27,6 +29,8 @@ export interface ListOption<T = unknown> {
|
|
|
27
29
|
group?: string;
|
|
28
30
|
description?: string;
|
|
29
31
|
icon?: unknown;
|
|
32
|
+
/** More text the search finds the option by (`itemKeywords`, otherwise the item's `keywords`) */
|
|
33
|
+
keywords?: string[];
|
|
30
34
|
/** The original item (for slots and render functions) */
|
|
31
35
|
item: T;
|
|
32
36
|
}
|
|
@@ -78,6 +82,7 @@ export function toListOption<T>(item: T, accessors: ListItemAccessors<T> = {}):
|
|
|
78
82
|
accessors.itemLabel !== undefined ? read(item, accessors.itemLabel, 'label') : read(item, 'label', '');
|
|
79
83
|
const group = read(item, accessors.itemGroup, 'group');
|
|
80
84
|
const description = read(item, undefined, 'description');
|
|
85
|
+
const keywords = read(item, accessors.itemKeywords, 'keywords');
|
|
81
86
|
return {
|
|
82
87
|
key: listValueKey(value, accessors.valueKey),
|
|
83
88
|
value,
|
|
@@ -86,6 +91,10 @@ export function toListOption<T>(item: T, accessors: ListItemAccessors<T> = {}):
|
|
|
86
91
|
group: group === null || group === undefined || group === '' ? undefined : String(group),
|
|
87
92
|
description: typeof description === 'string' ? description : undefined,
|
|
88
93
|
icon: read(item, undefined, 'icon'),
|
|
94
|
+
keywords:
|
|
95
|
+
keywords === null || keywords === undefined || keywords === ''
|
|
96
|
+
? undefined
|
|
97
|
+
: (Array.isArray(keywords) ? keywords : [keywords]).map(String),
|
|
89
98
|
item,
|
|
90
99
|
};
|
|
91
100
|
}
|
|
@@ -119,14 +128,21 @@ export function groupListOptions<T>(options: readonly ListOption<T>[]): ListGrou
|
|
|
119
128
|
return groups;
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Options whose label or one of their keywords contains the query; `contains` decides about case and accents (Ark's
|
|
133
|
+
* useFilter)
|
|
134
|
+
*/
|
|
123
135
|
export function filterListOptions<T>(
|
|
124
136
|
options: readonly ListOption<T>[],
|
|
125
137
|
query: string,
|
|
126
138
|
contains: (text: string, query: string) => boolean
|
|
127
139
|
): ListOption<T>[] {
|
|
128
140
|
const text = query.trim();
|
|
129
|
-
return text
|
|
141
|
+
return text
|
|
142
|
+
? options.filter(
|
|
143
|
+
(option) => contains(option.label, text) || !!option.keywords?.some((keyword) => contains(keyword, text))
|
|
144
|
+
)
|
|
145
|
+
: [...options];
|
|
130
146
|
}
|
|
131
147
|
|
|
132
148
|
/** Looks options up by key; earlier lists win (e.g. the current items before remembered ones) */
|
|
@@ -161,8 +177,12 @@ export function listOptionsForValues<T>(
|
|
|
161
177
|
});
|
|
162
178
|
}
|
|
163
179
|
|
|
164
|
-
/**
|
|
165
|
-
|
|
180
|
+
/**
|
|
181
|
+
* The value of a single choice as a list: undefined → [], null → [] – unless one of the options has the value null
|
|
182
|
+
* (e.g. "All"): then null chooses it.
|
|
183
|
+
*/
|
|
184
|
+
export const listValues = (value: unknown, options: readonly ListOption[] = []): unknown[] =>
|
|
185
|
+
value === undefined || (value === null && !options.some((option) => option.value === null)) ? [] : [value];
|
|
166
186
|
|
|
167
187
|
/**
|
|
168
188
|
* "Select all": the selectable options in view (filtered, enabled) are added – or removed when all of them are
|
package/src/locales/ar.ts
CHANGED
|
@@ -790,6 +790,7 @@ export const ar: Translations = {
|
|
|
790
790
|
exportAll: 'كل الصفوف',
|
|
791
791
|
exportSelection: 'الصفوف المحددة',
|
|
792
792
|
filterToggle: 'عرض الفلاتر',
|
|
793
|
+
resetFilters: 'إعادة تعيين الفلاتر',
|
|
793
794
|
rowCount: (count) => plural(count, { ...rows, zero: 'لا توجد صفوف' }),
|
|
794
795
|
filteredCount: (count) => `${count} بعد التصفية`,
|
|
795
796
|
copy: (header, value) => `نسخ ${value}، ${header}`,
|
package/src/locales/cs.ts
CHANGED
|
@@ -645,6 +645,7 @@ export const cs: Translations = {
|
|
|
645
645
|
exportAll: 'Všechny řádky',
|
|
646
646
|
exportSelection: 'Vybrané řádky',
|
|
647
647
|
filterToggle: 'Zobrazit filtry',
|
|
648
|
+
resetFilters: 'Zrušit filtry',
|
|
648
649
|
rowCount: (count) => plural(count, { one: '{count} řádek', few: '{count} řádky', other: '{count} řádků' }),
|
|
649
650
|
filteredCount: (count) =>
|
|
650
651
|
plural(count, {
|
package/src/locales/de.ts
CHANGED
|
@@ -589,6 +589,7 @@ export const de = {
|
|
|
589
589
|
exportAll: 'Alle Zeilen',
|
|
590
590
|
exportSelection: 'Ausgewählte Zeilen',
|
|
591
591
|
filterToggle: 'Filter anzeigen',
|
|
592
|
+
resetFilters: 'Filter zurücksetzen',
|
|
592
593
|
rowCount: (count: number) => (count === 1 ? '1 Zeile' : `${count} Zeilen`),
|
|
593
594
|
filteredCount: (count: number) => `${count} gefiltert`,
|
|
594
595
|
copy: (header: string, value: string) => `${value}, ${header} kopieren`,
|
package/src/locales/es.ts
CHANGED
|
@@ -570,6 +570,7 @@ export const es: Translations = {
|
|
|
570
570
|
exportAll: 'Todas las filas',
|
|
571
571
|
exportSelection: 'Filas seleccionadas',
|
|
572
572
|
filterToggle: 'Mostrar filtros',
|
|
573
|
+
resetFilters: 'Restablecer filtros',
|
|
573
574
|
rowCount: (count) => plural(count, { one: '{count} fila', other: '{count} filas' }),
|
|
574
575
|
filteredCount: (count) => plural(count, { one: '{count} filtrada', other: '{count} filtradas' }),
|
|
575
576
|
copy: (header, value) => `Copiar ${value}, ${header}`,
|
package/src/locales/fr.ts
CHANGED
|
@@ -583,6 +583,7 @@ export const fr: Translations = {
|
|
|
583
583
|
exportAll: 'Toutes les lignes',
|
|
584
584
|
exportSelection: 'Lignes sélectionnées',
|
|
585
585
|
filterToggle: 'Afficher les filtres',
|
|
586
|
+
resetFilters: 'Réinitialiser les filtres',
|
|
586
587
|
rowCount: (count) => plural(count, { one: '{count} ligne', other: '{count} lignes' }),
|
|
587
588
|
filteredCount: (count) => plural(count, { one: '{count} filtrée', other: '{count} filtrées' }),
|
|
588
589
|
copy: (header, value) => `Copier ${value}, ${header}`,
|
package/src/locales/hu.ts
CHANGED
|
@@ -605,6 +605,7 @@ export const hu: Translations = {
|
|
|
605
605
|
exportAll: 'Összes sor',
|
|
606
606
|
exportSelection: 'Kiválasztott sorok',
|
|
607
607
|
filterToggle: 'Szűrők megjelenítése',
|
|
608
|
+
resetFilters: 'Szűrők törlése',
|
|
608
609
|
rowCount: (count) => rows(count),
|
|
609
610
|
filteredCount: (count) => plural(count, { one: '{count} szűrve', other: '{count} szűrve' }),
|
|
610
611
|
copy: (header, value) => `${value}, ${header} másolása`,
|
package/src/locales/it.ts
CHANGED
|
@@ -596,6 +596,7 @@ export const it: Translations = {
|
|
|
596
596
|
exportAll: 'Tutte le righe',
|
|
597
597
|
exportSelection: 'Righe selezionate',
|
|
598
598
|
filterToggle: 'Mostra filtri',
|
|
599
|
+
resetFilters: 'Reimposta filtri',
|
|
599
600
|
rowCount: (count) => plural(count, lines),
|
|
600
601
|
filteredCount: (count) => plural(count, { one: '{count} filtrato', other: '{count} filtrati' }),
|
|
601
602
|
copy: (header, value) => `Copia ${value}, ${header}`,
|
package/src/locales/lv.ts
CHANGED
|
@@ -605,6 +605,7 @@ export const lv: Translations = {
|
|
|
605
605
|
exportAll: 'Visas rindas',
|
|
606
606
|
exportSelection: 'Atlasītās rindas',
|
|
607
607
|
filterToggle: 'Rādīt filtrus',
|
|
608
|
+
resetFilters: 'Atiestatīt filtrus',
|
|
608
609
|
rowCount: (count) => plural(count, forms('{count} rinda', '{count} rindas')),
|
|
609
610
|
filteredCount: (count) => plural(count, forms('{count} filtrēta', '{count} filtrētas')),
|
|
610
611
|
copy: (header, value) => `Kopēt: ${value}, ${header}`,
|
package/src/locales/nl.ts
CHANGED
|
@@ -557,6 +557,7 @@ export const nl: Translations = {
|
|
|
557
557
|
exportAll: 'Alle rijen',
|
|
558
558
|
exportSelection: 'Geselecteerde rijen',
|
|
559
559
|
filterToggle: 'Filters weergeven',
|
|
560
|
+
resetFilters: 'Filters wissen',
|
|
560
561
|
rowCount: (count) => plural(count, { one: '{count} rij', other: '{count} rijen' }),
|
|
561
562
|
filteredCount: (count) => `${count} gefilterd`,
|
|
562
563
|
copy: (header, value) => `${value}, ${header} kopiëren`,
|
package/src/locales/pl.ts
CHANGED
|
@@ -660,6 +660,7 @@ export const pl: Translations = {
|
|
|
660
660
|
exportAll: 'Wszystkie wiersze',
|
|
661
661
|
exportSelection: 'Zaznaczone wiersze',
|
|
662
662
|
filterToggle: 'Pokaż filtry',
|
|
663
|
+
resetFilters: 'Wyczyść filtry',
|
|
663
664
|
rowCount: (count) => rows(count),
|
|
664
665
|
filteredCount: (count) => `Po filtrowaniu: ${count}`,
|
|
665
666
|
copy: (header, value) => `Kopiuj: ${value}, ${header}`,
|
package/src/locales/pt-BR.ts
CHANGED
|
@@ -120,6 +120,7 @@ export const ptBR: Translations = {
|
|
|
120
120
|
sortAscending: 'Classificar em ordem crescente',
|
|
121
121
|
sortDescending: 'Classificar em ordem decrescente',
|
|
122
122
|
clearSort: 'Remover classificação',
|
|
123
|
+
resetFilters: 'Redefinir filtros',
|
|
123
124
|
sortPriority: (position, desc) => `nível de classificação ${position}, ${desc ? 'decrescente' : 'crescente'}`,
|
|
124
125
|
pinEnd: 'Fixar no final',
|
|
125
126
|
columnMoved: (header, position, count) => `${header} agora é a coluna ${position} de ${count}`,
|
package/src/locales/pt.ts
CHANGED
|
@@ -576,6 +576,7 @@ export const pt: Translations = {
|
|
|
576
576
|
exportAll: 'Todas as linhas',
|
|
577
577
|
exportSelection: 'Linhas selecionadas',
|
|
578
578
|
filterToggle: 'Mostrar filtros',
|
|
579
|
+
resetFilters: 'Repor filtros',
|
|
579
580
|
rowCount: (count) => plural(count, { one: '{count} linha', other: '{count} linhas' }),
|
|
580
581
|
filteredCount: (count) => plural(count, { one: '{count} filtrada', other: '{count} filtradas' }),
|
|
581
582
|
copy: (header, value) => `Copiar ${value}, ${header}`,
|
package/src/locales/tr.ts
CHANGED
|
@@ -554,6 +554,7 @@ export const tr: Translations = {
|
|
|
554
554
|
exportAll: 'Tüm satırlar',
|
|
555
555
|
exportSelection: 'Seçili satırlar',
|
|
556
556
|
filterToggle: 'Filtreleri göster',
|
|
557
|
+
resetFilters: 'Filtreleri sıfırla',
|
|
557
558
|
rowCount: (count) => plural(count, { one: '{count} satır', other: '{count} satır' }),
|
|
558
559
|
filteredCount: (count) => plural(count, { one: '{count} filtrelendi', other: '{count} filtrelendi' }),
|
|
559
560
|
copy: (header, value) => `Kopyala: ${value}, ${header}`,
|
package/src/overlay.ts
CHANGED
|
@@ -101,7 +101,8 @@ export const dialog = tv({
|
|
|
101
101
|
],
|
|
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-[14px] border border-line-2 bg-card text-fg outline-none',
|
|
105
106
|
'shadow-[0_24px_48px_-20px_rgba(0,0,0,.55)]',
|
|
106
107
|
'motion-safe:data-[state=open]:animate-dialog-in motion-safe:data-[state=closed]:animate-dialog-out',
|
|
107
108
|
],
|
|
@@ -132,12 +133,12 @@ export const dialog = tv({
|
|
|
132
133
|
warn: { iconBox: 'bg-warn/14 text-warn' },
|
|
133
134
|
danger: { iconBox: 'bg-danger/14 text-danger' },
|
|
134
135
|
},
|
|
135
|
-
/** Maximum width
|
|
136
|
+
/** Maximum width: sm 320px (20rem), md 400px (25rem, default), lg 560px (35rem), xl 800px (50rem) */
|
|
136
137
|
size: {
|
|
137
|
-
sm: { content: '
|
|
138
|
-
md: { content: '
|
|
139
|
-
lg: { content: '
|
|
140
|
-
xl: { content: '
|
|
138
|
+
sm: { content: '[--wc-dialog-w:320px]' },
|
|
139
|
+
md: { content: '[--wc-dialog-w:400px]' },
|
|
140
|
+
lg: { content: '[--wc-dialog-w:560px]' },
|
|
141
|
+
xl: { content: '[--wc-dialog-w:800px]' },
|
|
141
142
|
full: { content: 'max-w-none' },
|
|
142
143
|
},
|
|
143
144
|
/** Where the dialog sits on the screen; without it centred */
|
package/src/selection.ts
CHANGED
|
@@ -110,7 +110,8 @@ export type SegmentedControlSize = 'sm' | 'md';
|
|
|
110
110
|
|
|
111
111
|
export const segmentedControl = tv({
|
|
112
112
|
slots: {
|
|
113
|
-
|
|
113
|
+
// As wide as its segments – also as a flex item of a column (inside a Field)
|
|
114
|
+
base: 'inline-flex w-fit items-center gap-0.5 rounded-full border border-line-2 p-[3px]',
|
|
114
115
|
label: 'sr-only',
|
|
115
116
|
item: [
|
|
116
117
|
'inline-flex cursor-pointer items-center gap-1.5 rounded-full whitespace-nowrap text-muted',
|