@wirecore/wirelayer-recipes 0.5.0 → 0.6.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.
Files changed (96) hide show
  1. package/dist/app.js +2 -2
  2. package/dist/app.js.map +1 -1
  3. package/dist/button.js +8 -8
  4. package/dist/button.js.map +1 -1
  5. package/dist/card.d.ts +1 -1
  6. package/dist/card.js +1 -1
  7. package/dist/card.js.map +1 -1
  8. package/dist/control-ids.d.ts +10 -0
  9. package/dist/control-ids.d.ts.map +1 -0
  10. package/dist/control-ids.js +15 -0
  11. package/dist/control-ids.js.map +1 -0
  12. package/dist/data.d.ts +70 -0
  13. package/dist/data.d.ts.map +1 -1
  14. package/dist/data.js +20 -0
  15. package/dist/data.js.map +1 -1
  16. package/dist/dev.d.ts +5 -0
  17. package/dist/dev.d.ts.map +1 -1
  18. package/dist/dev.js +13 -0
  19. package/dist/dev.js.map +1 -1
  20. package/dist/extras.d.ts.map +1 -1
  21. package/dist/extras.js +7 -3
  22. package/dist/extras.js.map +1 -1
  23. package/dist/field.d.ts +9 -9
  24. package/dist/field.js +10 -10
  25. package/dist/field.js.map +1 -1
  26. package/dist/index.d.ts +5 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +4 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/inputs.d.ts +39 -0
  31. package/dist/inputs.d.ts.map +1 -1
  32. package/dist/inputs.js +73 -40
  33. package/dist/inputs.js.map +1 -1
  34. package/dist/list-items.d.ts +8 -0
  35. package/dist/list-items.d.ts.map +1 -1
  36. package/dist/list-items.js +16 -2
  37. package/dist/list-items.js.map +1 -1
  38. package/dist/media.d.ts +24 -0
  39. package/dist/media.d.ts.map +1 -1
  40. package/dist/media.js +15 -0
  41. package/dist/media.js.map +1 -1
  42. package/dist/native/controls.d.ts +18 -0
  43. package/dist/native/controls.d.ts.map +1 -1
  44. package/dist/native/controls.js +4 -0
  45. package/dist/native/controls.js.map +1 -1
  46. package/dist/navigation.d.ts.map +1 -1
  47. package/dist/navigation.js +7 -3
  48. package/dist/navigation.js.map +1 -1
  49. package/dist/overlay.d.ts +36 -0
  50. package/dist/overlay.d.ts.map +1 -1
  51. package/dist/overlay.js +10 -2
  52. package/dist/overlay.js.map +1 -1
  53. package/dist/overrides.d.ts +27 -2
  54. package/dist/overrides.d.ts.map +1 -1
  55. package/dist/overrides.js +100 -11
  56. package/dist/overrides.js.map +1 -1
  57. package/dist/sources/button.css +1 -1
  58. package/dist/sources/card.css +1 -1
  59. package/dist/sources/colorPicker.css +1 -1
  60. package/dist/sources/combobox.css +1 -1
  61. package/dist/sources/dataTable.css +1 -1
  62. package/dist/sources/datePicker.css +1 -1
  63. package/dist/sources/dialog.css +1 -1
  64. package/dist/sources/drawer.css +1 -1
  65. package/dist/sources/iconButton.css +1 -1
  66. package/dist/sources/input.css +1 -1
  67. package/dist/sources/multiSelect.css +1 -1
  68. package/dist/sources/nativeSelect.css +1 -1
  69. package/dist/sources/numberInput.css +1 -1
  70. package/dist/sources/passwordInput.css +1 -1
  71. package/dist/sources/select.css +1 -1
  72. package/dist/sources/slider.css +1 -1
  73. package/dist/sources/tagsInput.css +1 -1
  74. package/dist/sources/textarea.css +1 -1
  75. package/dist/vite.d.ts +19 -0
  76. package/dist/vite.d.ts.map +1 -0
  77. package/dist/vite.js +161 -0
  78. package/dist/vite.js.map +1 -0
  79. package/package.json +15 -2
  80. package/src/app.ts +2 -2
  81. package/src/button.ts +8 -8
  82. package/src/card.ts +1 -1
  83. package/src/control-ids.ts +21 -0
  84. package/src/data.ts +24 -0
  85. package/src/dev.ts +14 -0
  86. package/src/extras.ts +7 -3
  87. package/src/field.ts +10 -10
  88. package/src/index.ts +7 -2
  89. package/src/inputs.ts +77 -40
  90. package/src/list-items.ts +21 -0
  91. package/src/media.ts +15 -0
  92. package/src/native/controls.ts +4 -0
  93. package/src/navigation.ts +9 -3
  94. package/src/overlay.ts +10 -2
  95. package/src/overrides.ts +130 -15
  96. package/src/vite.ts +162 -0
package/dist/vite.js ADDED
@@ -0,0 +1,161 @@
1
+ /// <reference types="node" />
2
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import { dirname, extname, join, relative } from 'node:path';
5
+ const PACKAGES = ['vue', 'react', 'blocks-vue', 'blocks-react', 'recipes'].map((name) => `@wirecore/wirelayer-${name}`);
6
+ /** The CSS file that gets the imports: the one importing the theme without component classes */
7
+ const ENTRY = /@import\s+['"]@wirecore\/wirelayer-(?:vue|react)\/(?:theme|styles-core)\.css['"]/;
8
+ const IMPORT = /(?:import|export)\s+(type\s+)?(\{[^}]*\}|\*\s+as\s+\w+)\s+from\s+['"](@wirecore\/wirelayer-[\w-]+)(?:\/[\w-]+)?['"]/g;
9
+ const SOURCE_FILES = new Set(['.vue', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.mts', '.astro', '.mdx', '.svelte']);
10
+ const SKIPPED = ['node_modules', 'dist', '.git', '.nuxt', '.output', '.next', '.astro', '.vercel', 'storybook-static'];
11
+ /** Names imported from the WireLayer packages, by package; `*` for a namespace import (`import * as W`) */
12
+ export function findImports(code, found = new Map()) {
13
+ for (const [, typeOnly, names, pkg] of code.matchAll(IMPORT)) {
14
+ if (typeOnly || !PACKAGES.includes(pkg))
15
+ continue;
16
+ const set = found.get(pkg) ?? new Set();
17
+ found.set(pkg, set);
18
+ if (names.startsWith('*')) {
19
+ set.add('*');
20
+ continue;
21
+ }
22
+ for (const part of names.slice(1, -1).split(',')) {
23
+ const name = part.trim().split(/\s+as\s+/)[0];
24
+ if (name && !name.startsWith('type '))
25
+ set.add(name);
26
+ }
27
+ }
28
+ return found;
29
+ }
30
+ /** The sources files (absolute paths) for the imported names – names without one (helpers, types) are skipped */
31
+ export function sourcesFiles(imports, root) {
32
+ const require = createRequire(join(root, 'package.json'));
33
+ const files = new Set();
34
+ for (const [pkg, names] of imports) {
35
+ const folder = sourcesFolder(require, pkg);
36
+ if (!folder)
37
+ continue;
38
+ if (!existsSync(folder))
39
+ continue;
40
+ const wanted = names.has('*') ? readdirSync(folder).map((file) => file.slice(0, -4)) : [...names];
41
+ for (const name of wanted) {
42
+ const file = join(folder, `${name}.css`);
43
+ if (existsSync(file))
44
+ files.add(file);
45
+ }
46
+ }
47
+ return [...files].sort();
48
+ }
49
+ /** dist/sources of an installed package: up from its main entry to the folder of its package.json */
50
+ function sourcesFolder(require, pkg) {
51
+ let folder;
52
+ try {
53
+ folder = dirname(require.resolve(pkg));
54
+ }
55
+ catch {
56
+ return undefined;
57
+ }
58
+ while (!existsSync(join(folder, 'package.json'))) {
59
+ const parent = dirname(folder);
60
+ if (parent === folder)
61
+ return undefined;
62
+ folder = parent;
63
+ }
64
+ return join(folder, 'dist/sources');
65
+ }
66
+ function sourceFilesIn(folder, skipped, out = []) {
67
+ for (const entry of readdirSync(folder, { withFileTypes: true })) {
68
+ if (entry.isDirectory()) {
69
+ if (!skipped.has(entry.name))
70
+ sourceFilesIn(join(folder, entry.name), skipped, out);
71
+ }
72
+ else if (SOURCE_FILES.has(extname(entry.name)))
73
+ out.push(join(folder, entry.name));
74
+ }
75
+ return out;
76
+ }
77
+ /**
78
+ * Vite plugin for smaller CSS: imports the sources files of the components and recipes used in the app into the CSS
79
+ * file that imports `@wirecore/wirelayer-vue/theme.css` (or `styles-core.css`; the same for React). Put it before
80
+ * Tailwind's plugin. Components that are registered globally or imported automatically are not found – the warning
81
+ * "classes … are missing" names them in development; import their sources files by hand.
82
+ */
83
+ export function wirelayer(options = {}) {
84
+ let root = process.cwd();
85
+ const skipped = new Set(options.exclude ?? SKIPPED);
86
+ /** Imports per source file, so a changed file is read again on its own */
87
+ const perFile = new Map();
88
+ let imports = '';
89
+ const entries = new Set();
90
+ const read = (file) => {
91
+ try {
92
+ perFile.set(file, findImports(readFileSync(file, 'utf8')));
93
+ }
94
+ catch {
95
+ perFile.delete(file);
96
+ }
97
+ };
98
+ const collect = () => {
99
+ const all = new Map();
100
+ for (const found of perFile.values())
101
+ for (const [pkg, names] of found)
102
+ all.set(pkg, new Set([...(all.get(pkg) ?? []), ...names]));
103
+ return sourcesFiles(all, root)
104
+ .map((file) => `@import '${file.replaceAll('\\', '/')}';`)
105
+ .join('\n');
106
+ };
107
+ const scan = () => {
108
+ perFile.clear();
109
+ for (const folder of options.include ?? ['.']) {
110
+ const path = join(root, folder);
111
+ if (existsSync(path) && statSync(path).isDirectory())
112
+ for (const file of sourceFilesIn(path, skipped))
113
+ read(file);
114
+ }
115
+ imports = collect();
116
+ };
117
+ return {
118
+ name: 'wirelayer-sources',
119
+ enforce: 'pre',
120
+ configResolved(config) {
121
+ root = config.root;
122
+ },
123
+ buildStart() {
124
+ scan();
125
+ },
126
+ transform(code, id) {
127
+ const entry = id.split('?')[0].endsWith('.css') ? ENTRY.exec(code) : null;
128
+ if (!entry)
129
+ return;
130
+ entries.add(id);
131
+ // Right after the theme import – @import rules come before all others
132
+ const end = code.indexOf(';', entry.index) + 1;
133
+ return {
134
+ code: `${code.slice(0, end)}\n/* added by wirelayer() */\n${imports}\n${code.slice(end)}`,
135
+ map: null,
136
+ };
137
+ },
138
+ configureServer(server) {
139
+ // A new or changed import adds its sources file: the CSS is built again
140
+ const update = (file) => {
141
+ if (!SOURCE_FILES.has(extname(file)) || relative(root, file).startsWith('..'))
142
+ return;
143
+ if ([...skipped].some((name) => file.split(/[\\/]/).includes(name)))
144
+ return;
145
+ read(file);
146
+ const next = collect();
147
+ if (next === imports)
148
+ return;
149
+ imports = next;
150
+ for (const id of entries) {
151
+ const module = server.moduleGraph.getModuleById(id);
152
+ if (module)
153
+ void server.reloadModule(module);
154
+ }
155
+ };
156
+ server.watcher.on('add', update);
157
+ server.watcher.on('change', update);
158
+ },
159
+ };
160
+ }
161
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE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KACJ,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecore/wirelayer-recipes",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-agnostic WireLayer component recipes (tailwind-variants)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/locales/*.d.ts",
30
30
  "default": "./dist/locales/*.js"
31
31
  },
32
+ "./vite": {
33
+ "types": "./dist/vite.d.ts",
34
+ "default": "./dist/vite.js"
35
+ },
32
36
  "./tailwind.css": "./tailwind.css",
33
37
  "./sources/*": "./dist/sources/*",
34
38
  "./native.css": "./native.css"
@@ -43,8 +47,17 @@
43
47
  "tailwind-merge": "^3.7.0",
44
48
  "tailwind-variants": "^3.3.1"
45
49
  },
50
+ "peerDependencies": {
51
+ "vite": ">=7"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "vite": {
55
+ "optional": true
56
+ }
57
+ },
46
58
  "devDependencies": {
47
- "typescript": "~6.0.3"
59
+ "typescript": "~6.0.3",
60
+ "vite": "^8.3.4"
48
61
  },
49
62
  "scripts": {
50
63
  "build": "tsc -p tsconfig.build.json && node ../../scripts/sources.ts recipes",
package/src/app.ts CHANGED
@@ -138,7 +138,7 @@ export const tagsInput = tv({
138
138
  // relative: the suggestions open below the field
139
139
  base: 'relative flex w-full flex-col',
140
140
  control: [
141
- 'flex min-h-10 w-full flex-wrap items-center gap-1.5 rounded-lg border border-line-strong bg-bg px-2 py-1.5 text-fg',
141
+ 'flex min-h-[var(--wc-control-h-md,2.5rem)] w-full flex-wrap items-center gap-1.5 rounded-[var(--wc-control-radius-md,0.5rem)] border border-line-strong bg-bg px-2 py-1.5 text-fg',
142
142
  'transition-colors focus-within:border-primary motion-reduce:transition-none',
143
143
  'data-invalid:border-danger data-disabled:cursor-not-allowed data-disabled:border-line data-disabled:bg-bg-2',
144
144
  ],
@@ -153,7 +153,7 @@ export const tagsInput = tv({
153
153
  ],
154
154
  deleteIcon: 'size-3.5',
155
155
  itemInput: 'h-7 rounded-md border border-primary bg-bg px-2 text-sm outline-none',
156
- input: 'h-7 min-w-24 flex-1 bg-transparent px-1 text-[15px] outline-none placeholder:text-muted',
156
+ input: 'h-7 min-w-24 flex-1 bg-transparent px-1 text-[length:var(--wc-control-text-md,15px)] outline-none placeholder:text-muted',
157
157
  clear: [
158
158
  'ms-auto flex size-7 cursor-pointer items-center justify-center rounded-full text-muted hover:text-fg',
159
159
  focusRing,
package/src/button.ts CHANGED
@@ -158,13 +158,13 @@ export const button = tv({
158
158
  color: colorKeys,
159
159
  size: {
160
160
  xs: { base: 'h-6 gap-1 px-2.5 text-xs', icon: 'size-3' },
161
- sm: { base: 'h-8 gap-1 px-3 text-[13px]', icon: 'size-3.5' },
162
- md: { base: 'h-10 gap-1.5 px-4 text-sm', icon: 'size-4' },
163
- lg: { base: 'h-12 gap-2 px-5.5 text-[15px]', icon: 'size-[18px]' },
161
+ sm: { base: 'h-[var(--wc-control-h-sm,2rem)] gap-1 px-3 text-[13px]', icon: 'size-3.5' },
162
+ md: { base: 'h-[var(--wc-control-h-md,2.5rem)] gap-1.5 px-4 text-sm', icon: 'size-4' },
163
+ lg: { base: 'h-[var(--wc-control-h-lg,3rem)] gap-2 px-5.5 text-[15px]', icon: 'size-[18px]' },
164
164
  },
165
165
  shape: {
166
166
  pill: {},
167
- rounded: { base: 'rounded-lg' },
167
+ rounded: { base: 'rounded-[var(--wc-button-radius,0.5rem)]' },
168
168
  square: { base: 'rounded-none' },
169
169
  },
170
170
  /** Full width of its container */
@@ -225,13 +225,13 @@ export const iconButton = tv({
225
225
  color: colorKeys,
226
226
  size: {
227
227
  xs: { base: 'size-6', icon: 'size-3.5' },
228
- sm: { base: 'size-8', icon: 'size-3.5' },
229
- md: { base: 'size-10', icon: 'size-[18px]' },
230
- lg: { base: 'size-12', icon: 'size-5' },
228
+ sm: { base: 'size-[var(--wc-control-h-sm,2rem)]', icon: 'size-3.5' },
229
+ md: { base: 'size-[var(--wc-control-h-md,2.5rem)]', icon: 'size-[18px]' },
230
+ lg: { base: 'size-[var(--wc-control-h-lg,3rem)]', icon: 'size-5' },
231
231
  },
232
232
  shape: {
233
233
  pill: {},
234
- rounded: { base: 'rounded-lg' },
234
+ rounded: { base: 'rounded-[var(--wc-button-radius,0.5rem)]' },
235
235
  square: { base: 'rounded-none' },
236
236
  },
237
237
  },
package/src/card.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { tv } from './tv.js';
2
2
 
3
3
  export const card = tv({
4
- base: 'flex flex-col gap-2.5 rounded-card border border-line bg-card p-6',
4
+ base: 'flex flex-col gap-2.5 rounded-card border border-line bg-card p-[var(--wc-card-p,1.5rem)]',
5
5
  variants: {
6
6
  interactive: {
7
7
  true: [
@@ -0,0 +1,21 @@
1
+ // Own ids on Ark-based controls. Ark finds its parts by the ids it generates – an `id` attribute spread onto a part
2
+ // overwrites that id, and the machine loses the element (a Select list opened at the top left of the page). An own id
3
+ // therefore goes through Ark's `ids` option to the part a `<label for>` points to (trigger, input …).
4
+
5
+ export type ControlIds = Record<string, string | undefined>;
6
+
7
+ /**
8
+ * The props for an Ark root that put an own `id` on `part`. Ark replaces its `ids` as a whole, so `fieldIds` are the
9
+ * ones it would take from a surrounding Field (e.g. `{ label, hiddenSelect }` for a Select). Without an own id nothing
10
+ * is passed (Ark keeps its ids); `standalone` drops the Field's ids (a second control inside a Field).
11
+ */
12
+ export function controlIds(
13
+ id: string | undefined,
14
+ part: string,
15
+ fieldIds: ControlIds = {},
16
+ standalone = false
17
+ ): { ids?: ControlIds } {
18
+ const own = id ? { [part]: id } : {};
19
+ if (standalone) return { ids: own };
20
+ return id ? { ids: { ...fieldIds, ...own } } : {};
21
+ }
package/src/data.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  import { popupMotion, tv } from './tv.js';
2
2
 
3
+ /** Where the DataTable puts its pagination row: rows per page at the start and pages at the end, or both together */
4
+ export type DataTablePaginatorAlign = 'between' | 'start' | 'center' | 'end';
5
+ /**
6
+ * The recipe value of `paginatorAlign` – prefixed, so the HTML classes do not clash with the column `align`
7
+ * (`.wc-data-table-paginator-start`)
8
+ */
9
+ export const paginatorAlignKey = (align: DataTablePaginatorAlign | undefined) =>
10
+ align && align !== 'between'
11
+ ? (`paginator${align[0]!.toUpperCase()}${align.slice(1)}` as `paginator${Capitalize<Exclude<DataTablePaginatorAlign, 'between'>>}`)
12
+ : undefined;
13
+
3
14
  // DataTable (@wirecore/wirelayer-vue/data-table, @wirecore/wirelayer-react/data-table) and virtualised lists.
4
15
 
5
16
  const focusRing = 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fg';
@@ -211,6 +222,19 @@ export const dataTable = tv({
211
222
  footCell: 'border-e border-line last:border-e-0',
212
223
  },
213
224
  },
225
+ /** A border around the whole table (with or without `gridlines`) */
226
+ bordered: {
227
+ true: { table: 'border border-line' },
228
+ },
229
+ /**
230
+ * The pagination row, both parts together (without it: rows per page at the start, the pages at the end) –
231
+ * the values come from paginatorAlignKey()
232
+ */
233
+ paginatorAlign: {
234
+ paginatorStart: { footer: 'justify-start' },
235
+ paginatorCenter: { footer: 'justify-center' },
236
+ paginatorEnd: { footer: 'justify-end' },
237
+ },
214
238
  /** Every other row tinted */
215
239
  striped: {
216
240
  true: { row: 'even:bg-bg-2/60' },
package/src/dev.ts CHANGED
@@ -19,6 +19,20 @@ export function warnInDevelopment(message: string) {
19
19
  console.warn(`[WireLayer] ${message}`);
20
20
  }
21
21
 
22
+ /**
23
+ * Development only: warns when a `<label for>` points at a control that no label element can name – a date field of
24
+ * spin buttons, a slider, a group of stars … Such controls are named by a surrounding Field or an aria-label.
25
+ */
26
+ export function warnLabelFor(component: string, id: string | undefined) {
27
+ if (!id || typeof document === 'undefined' || !isDevelopment()) return;
28
+ const labels = document.querySelectorAll('label[for]');
29
+ if (![...labels].some((label) => (label as HTMLLabelElement).htmlFor === id)) return;
30
+ warnInDevelopment(
31
+ `<label for="${id}"> does not name the ${component}: a label element cannot point at it. Put a Field ` +
32
+ `around it (it links label, description and error) or give it an aria-label.`
33
+ );
34
+ }
35
+
22
36
  const checkedSources = new Set<string>();
23
37
 
24
38
  /**
package/src/extras.ts CHANGED
@@ -110,7 +110,7 @@ export const nativeSelect = tv({
110
110
  slots: {
111
111
  base: 'relative flex w-full',
112
112
  select: [
113
- 'h-10 w-full cursor-pointer appearance-none rounded-lg border border-line-strong bg-bg pe-9 ps-3 text-[15px] text-fg outline-none',
113
+ 'h-[var(--wc-control-h-md,2.5rem)] w-full cursor-pointer appearance-none rounded-[var(--wc-control-radius-md,0.5rem)] border border-line-strong bg-bg pe-9 ps-3 text-[length:var(--wc-control-text-md,15px)] text-fg outline-none',
114
114
  'transition-colors focus:border-primary motion-reduce:transition-none',
115
115
  'aria-[invalid=true]:border-danger disabled:cursor-not-allowed disabled:border-line disabled:bg-bg-2 disabled:text-muted',
116
116
  ],
@@ -118,9 +118,13 @@ export const nativeSelect = tv({
118
118
  },
119
119
  variants: {
120
120
  size: {
121
- sm: { select: 'h-8 rounded-md ps-2.5 text-[13px]' },
121
+ sm: {
122
+ select: 'h-[var(--wc-control-h-sm,2rem)] rounded-[var(--wc-control-radius-sm,0.375rem)] ps-2.5 text-[length:var(--wc-control-text-sm,13px)]',
123
+ },
122
124
  md: {},
123
- lg: { select: 'h-12 rounded-[10px] ps-4 text-base' },
125
+ lg: {
126
+ select: 'h-[var(--wc-control-h-lg,3rem)] rounded-[var(--wc-control-radius-lg,10px)] ps-4 text-[length:var(--wc-control-text-lg,1rem)] leading-normal',
127
+ },
124
128
  },
125
129
  },
126
130
  defaultVariants: {
package/src/field.ts CHANGED
@@ -44,24 +44,24 @@ export const input = tv({
44
44
  variants: {
45
45
  size: {
46
46
  sm: {
47
- base: 'h-8 rounded-md',
48
- control: 'px-2.5 text-[13px]',
47
+ base: 'h-[var(--wc-control-h-sm,2rem)] rounded-[var(--wc-control-radius-sm,0.375rem)]',
48
+ control: 'px-2.5 text-[length:var(--wc-control-text-sm,13px)]',
49
49
  icon: 'ms-2.5 size-3.5',
50
50
  statusIcon: 'me-2.5 size-3.5',
51
51
  spinner: 'me-2.5 size-3.5',
52
52
  clear: 'me-1 size-6',
53
53
  },
54
54
  md: {
55
- base: 'h-10 rounded-lg',
56
- control: 'px-3 text-[15px]',
55
+ base: 'h-[var(--wc-control-h-md,2.5rem)] rounded-[var(--wc-control-radius-md,0.5rem)]',
56
+ control: 'px-3 text-[length:var(--wc-control-text-md,15px)]',
57
57
  icon: 'ms-3 size-4',
58
58
  statusIcon: 'me-3 size-4',
59
59
  spinner: 'me-3 size-4',
60
60
  clear: 'me-1.5 size-6',
61
61
  },
62
62
  lg: {
63
- base: 'h-12 rounded-[10px]',
64
- control: 'px-4 text-base',
63
+ base: 'h-[var(--wc-control-h-lg,3rem)] rounded-[var(--wc-control-radius-lg,10px)]',
64
+ control: 'px-4 text-[length:var(--wc-control-text-lg,1rem)] leading-normal',
65
65
  icon: 'ms-4 size-[18px]',
66
66
  statusIcon: 'me-4 size-[18px]',
67
67
  spinner: 'me-4 size-[18px]',
@@ -92,14 +92,14 @@ export const input = tv({
92
92
 
93
93
  export const textarea = tv({
94
94
  base: [
95
- 'block w-full resize-y rounded-lg border border-line-strong bg-bg px-3 py-[9px] text-[15px] leading-normal text-fg',
95
+ 'block w-full resize-y rounded-[var(--wc-control-radius-md,0.5rem)] border border-line-strong bg-bg px-3 py-[9px] text-[length:var(--wc-control-text-md,15px)] leading-normal text-fg',
96
96
  'outline-none transition-colors placeholder:text-muted focus:border-primary motion-reduce:transition-none',
97
97
  ],
98
98
  variants: {
99
99
  size: {
100
- sm: 'rounded-md px-2.5 py-1.5 text-[13px]',
101
- md: 'rounded-lg px-3 py-[9px] text-[15px]',
102
- lg: 'rounded-[10px] px-4 py-3 text-base',
100
+ sm: 'rounded-[var(--wc-control-radius-sm,0.375rem)] px-2.5 py-1.5 text-[length:var(--wc-control-text-sm,13px)]',
101
+ md: 'rounded-[var(--wc-control-radius-md,0.5rem)] px-3 py-[9px] text-[length:var(--wc-control-text-md,15px)]',
102
+ lg: 'rounded-[var(--wc-control-radius-lg,10px)] px-4 py-3 text-[length:var(--wc-control-text-lg,1rem)] leading-normal',
103
103
  },
104
104
  invalid: {
105
105
  true: 'border-danger focus:border-danger',
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ export {
23
23
  type AuthValidationOptions,
24
24
  type AuthValues,
25
25
  } from './blocks.js';
26
- export { dataTable, virtualList } from './data.js';
26
+ export { dataTable, paginatorAlignKey, virtualList, type DataTablePaginatorAlign } from './data.js';
27
27
  export { breadcrumb } from './breadcrumb.js';
28
28
  export {
29
29
  button,
@@ -55,6 +55,7 @@ export { statusDot, type StatusDotStatus } from './status-dot.js';
55
55
  export { pagination, progress, select, sidebarNav, stepper, steps, tabs, type StepStatus } from './navigation.js';
56
56
  export {
57
57
  allListOptionsState,
58
+ checkListValues,
58
59
  filterListOptions,
59
60
  groupListOptions,
60
61
  indexListOptions,
@@ -667,11 +668,14 @@ export {
667
668
  withRecipeOverrides,
668
669
  type AnyRecipe,
669
670
  type RecipeClasses,
671
+ type RecipeCompoundClasses,
670
672
  type RecipeConfig,
671
673
  type RecipeName,
672
674
  type RecipeOverride,
673
675
  type RecipeOverrides,
674
676
  type RecipeSlot,
677
+ type RecipeVariantClasses,
678
+ type RecipeVariantName,
675
679
  } from './overrides.js';
676
680
  export {
677
681
  GAUGE_ARC,
@@ -834,7 +838,8 @@ export {
834
838
  type TrendDirection,
835
839
  type TrendTone,
836
840
  } from './format.js';
837
- export { checkRecipeSources, warnInDevelopment } from './dev.js';
841
+ export { checkRecipeSources, warnInDevelopment, warnLabelFor } from './dev.js';
842
+ export { controlIds, type ControlIds } from './control-ids.js';
838
843
  export {
839
844
  formatHotkey,
840
845
  formatHotkeyText,