@brickflow/ui 0.0.32 → 0.0.34

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "configKey": "brickflowUi",
6
6
  "name": "@brickflow/ui",
7
- "version": "0.0.32",
7
+ "version": "0.0.34",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { defineNuxtModule, createResolver, resolvePath, addTemplate, updateTemplates, addImportsDir, addComponentsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, resolvePath, addTypeTemplate, addTemplate, updateTemplates, addImportsDir, addComponentsDir } from '@nuxt/kit';
2
2
  import tailwindcss from '@tailwindcss/vite';
3
3
  import { createJiti } from 'jiti';
4
4
  import { readdir, mkdir, readFile, writeFile } from 'node:fs/promises';
5
- import { join, resolve, basename, extname, dirname, relative } from 'node:path';
6
- import { defineBrickflowUiConfig } from '../dist/runtime/tailwind.js';
5
+ import { join, basename, extname, dirname, resolve, relative } from 'node:path';
6
+ import { isBrickflowUiStyleReference, getBrickflowUiStyleReferencePath, defineBrickflowUiConfig } from '../dist/runtime/tailwind.js';
7
7
  import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon';
8
8
 
9
9
  const ICON_FILE_PATTERN = /\.svg$/i;
@@ -85,6 +85,8 @@ ${CUSTOM_DARK_VARIANT}${code.slice(index)}`,
85
85
  });
86
86
 
87
87
  const UI_STYLE_PATTERN = /\bUI_STYLE((?:\.[A-Za-z_$][\w$]*)+)/g;
88
+ const UI_CONFIG_PATTERN = /\bUI_CONFIG((?:\.[A-Za-z_$][\w$]*)+)/g;
89
+ const UI_CONFIG_MACRO = "defineUiConfig";
88
90
  const SCRIPT_FILE_PATTERN = /\.(?:[cm]?[jt]sx?|vue)(?:\?.*)?$/;
89
91
  const TYPE_INDENT = " ";
90
92
  const refreshUiStyleModules = (server) => {
@@ -109,7 +111,7 @@ const resolveUiStyleConfigPath = (id, path) => {
109
111
  return path;
110
112
  }
111
113
  const componentName = basename(cleanId, extname(cleanId));
112
- const configName = componentName === "index" ? basename(dirname(cleanId)) : componentName;
114
+ const configName = componentName === "index" || componentName.endsWith(".demo") ? basename(dirname(cleanId)) : componentName;
113
115
  return [toCamelCase(configName), ...path];
114
116
  };
115
117
  const resolveStyleValue = (styles, id, path) => {
@@ -123,6 +125,75 @@ const resolveStyleValue = (styles, id, path) => {
123
125
  }
124
126
  return configPathValue ?? globalValue;
125
127
  };
128
+ const resolveUiConfigValue = (config, id, path) => {
129
+ const configPathValue = readPath(config, resolveUiStyleConfigPath(id, path));
130
+ return configPathValue ?? readPath(config, path);
131
+ };
132
+ const resolveUiConfigStyleReferences = (value, styles, id) => {
133
+ if (isBrickflowUiStyleReference(value)) {
134
+ const stylePath = getBrickflowUiStyleReferencePath(value);
135
+ const styleValue = resolveStyleValue(styles, id, [...stylePath]);
136
+ if (typeof styleValue !== "string") {
137
+ throw new TypeError(`UI_STYLE.${stylePath.join(".")} does not resolve to a string in ${id}.`);
138
+ }
139
+ return styleValue;
140
+ }
141
+ if (typeof value === "string") {
142
+ return value;
143
+ }
144
+ return Object.fromEntries(
145
+ Object.entries(value).map(([key, childValue]) => [
146
+ key,
147
+ resolveUiConfigStyleReferences(childValue, styles, id)
148
+ ])
149
+ );
150
+ };
151
+ const replaceUiConfigMacros = (code, config, styles, id, error) => {
152
+ let result = "";
153
+ let cursor = 0;
154
+ while (cursor < code.length) {
155
+ const start = code.indexOf(UI_CONFIG_MACRO, cursor);
156
+ if (start === -1) {
157
+ return result + code.slice(cursor);
158
+ }
159
+ const genericStart = start + UI_CONFIG_MACRO.length;
160
+ if (code[genericStart] !== "<") {
161
+ result += code.slice(cursor, genericStart);
162
+ cursor = genericStart;
163
+ continue;
164
+ }
165
+ let depth = 0;
166
+ let index = genericStart;
167
+ for (; index < code.length; index += 1) {
168
+ if (code[index] === "<") {
169
+ depth += 1;
170
+ }
171
+ if (code[index] === ">") {
172
+ depth -= 1;
173
+ }
174
+ if (depth === 0) {
175
+ break;
176
+ }
177
+ }
178
+ let callStart = index + 1;
179
+ while (/\s/u.test(code[callStart] ?? "")) {
180
+ callStart += 1;
181
+ }
182
+ if (code.slice(callStart, callStart + 2) !== "()") {
183
+ result += code.slice(cursor, callStart);
184
+ cursor = callStart;
185
+ continue;
186
+ }
187
+ const value = resolveUiConfigValue(config, id, []);
188
+ if (value === void 0) {
189
+ error(`defineUiConfig() in ${id} has no matching uiConfig entry.`);
190
+ }
191
+ result += code.slice(cursor, start);
192
+ result += JSON.stringify(resolveUiConfigStyleReferences(value, styles, id));
193
+ cursor = callStart + 2;
194
+ }
195
+ return result;
196
+ };
126
197
  const createUiStylePathTree = () => ({
127
198
  children: /* @__PURE__ */ new Map()
128
199
  });
@@ -134,16 +205,18 @@ const addPathToTree = (tree, path) => {
134
205
  currentTree = childTree;
135
206
  }
136
207
  };
137
- const renderTypeTree = (tree, level, objectType) => {
208
+ const renderTypeTree = (tree, level, objectType, leafType = "string", path = []) => {
138
209
  const lines = [];
139
210
  const indent = TYPE_INDENT.repeat(level);
140
211
  for (const [key, childTree] of [...tree.children.entries()].sort(([a], [b]) => a.localeCompare(b))) {
141
212
  if (childTree.children.size === 0) {
142
- lines.push(`${indent}readonly ${key}: string`);
213
+ const childPath = [...path, key];
214
+ const childLeafType = typeof leafType === "function" ? leafType(childPath) : leafType;
215
+ lines.push(`${indent}readonly ${key}: ${childLeafType}`);
143
216
  continue;
144
217
  }
145
218
  lines.push(objectType ? `${indent}readonly ${key}: ${objectType} & {` : `${indent}readonly ${key}: {`);
146
- lines.push(...renderTypeTree(childTree, level + 1, objectType));
219
+ lines.push(...renderTypeTree(childTree, level + 1, objectType, leafType, [...path, key]));
147
220
  lines.push(`${indent}}`);
148
221
  }
149
222
  return lines;
@@ -156,18 +229,111 @@ const collectUiStylePathsFromCode = (code) => {
156
229
  return paths.filter((path) => path.length > 0);
157
230
  };
158
231
  const collectUiStyleConfigPathsFromCode = (code, id) => collectUiStylePathsFromCode(code).map((path) => resolveUiStyleConfigPath(id, path));
159
- const renderInterfaceDeclaration = (name, paths, objectType) => {
232
+ const collectUiConfigValuePaths = (value, prefix) => {
233
+ if (typeof value === "string" || isBrickflowUiStyleReference(value)) {
234
+ return [prefix];
235
+ }
236
+ return Object.entries(value).flatMap(
237
+ ([key, childValue]) => collectUiConfigValuePaths(childValue, [...prefix, key])
238
+ );
239
+ };
240
+ const collectUiConfigPathsFromCode = (code, id, config) => {
241
+ const paths = [];
242
+ for (const match of code.matchAll(UI_CONFIG_PATTERN)) {
243
+ const path = match[1]?.slice(1).split(".") ?? [];
244
+ const value = resolveUiConfigValue(config, id, path);
245
+ paths.push(...value === void 0 ? [path] : collectUiConfigValuePaths(value, path));
246
+ }
247
+ return paths.filter((path) => path.length > 0);
248
+ };
249
+ const collectUiConfigComponentPathsFromCode = (code, id, config) => {
250
+ const paths = [];
251
+ for (const match of code.matchAll(UI_CONFIG_PATTERN)) {
252
+ const path = match[1]?.slice(1).split(".") ?? [];
253
+ const componentPath = resolveUiStyleConfigPath(id, path);
254
+ const value = readPath(config, componentPath);
255
+ paths.push(
256
+ ...value === void 0 ? [componentPath] : collectUiConfigValuePaths(value, componentPath)
257
+ );
258
+ }
259
+ if (code.includes(UI_CONFIG_MACRO)) {
260
+ const componentPath = resolveUiStyleConfigPath(id, []);
261
+ const value = readPath(config, componentPath);
262
+ if (value !== void 0) {
263
+ paths.push(...collectUiConfigValuePaths(value, componentPath));
264
+ }
265
+ }
266
+ return paths.filter((path) => path.length > 0);
267
+ };
268
+ const collectUiConfigSchemaEntriesFromCode = (code, id) => {
269
+ const entries = [];
270
+ let cursor = 0;
271
+ while (cursor < code.length) {
272
+ const start = code.indexOf(UI_CONFIG_MACRO, cursor);
273
+ if (start === -1) {
274
+ return entries;
275
+ }
276
+ const genericStart = start + UI_CONFIG_MACRO.length;
277
+ if (code[genericStart] !== "<") {
278
+ cursor = genericStart;
279
+ continue;
280
+ }
281
+ let depth = 0;
282
+ let genericEnd = genericStart;
283
+ for (; genericEnd < code.length; genericEnd += 1) {
284
+ if (code[genericEnd] === "<") {
285
+ depth += 1;
286
+ }
287
+ if (code[genericEnd] === ">") {
288
+ depth -= 1;
289
+ }
290
+ if (depth === 0) {
291
+ break;
292
+ }
293
+ }
294
+ let callStart = genericEnd + 1;
295
+ while (/\s/u.test(code[callStart] ?? "")) {
296
+ callStart += 1;
297
+ }
298
+ if (code.slice(callStart, callStart + 2) !== "()") {
299
+ cursor = callStart;
300
+ continue;
301
+ }
302
+ const schema = code.slice(genericStart + 1, genericEnd).trim();
303
+ const path = resolveUiStyleConfigPath(id, []);
304
+ if (schema.startsWith("{") && path.length > 0) {
305
+ entries.push({ path, schema });
306
+ }
307
+ cursor = callStart + 2;
308
+ }
309
+ return entries;
310
+ };
311
+ const collectUiConfigStyleReferencePathsFromValue = (value, componentPath) => {
312
+ if (isBrickflowUiStyleReference(value)) {
313
+ return [[...componentPath, ...getBrickflowUiStyleReferencePath(value)]];
314
+ }
315
+ if (typeof value === "string") {
316
+ return [];
317
+ }
318
+ return Object.values(value).flatMap(
319
+ (childValue) => collectUiConfigStyleReferencePathsFromValue(childValue, componentPath)
320
+ );
321
+ };
322
+ const collectUiConfigStyleReferencePaths = (config) => Object.entries(config).flatMap(([key, value]) => collectUiConfigStyleReferencePathsFromValue(value, [key]));
323
+ const renderInterfaceDeclaration = (name, paths, objectType, leafType = "string") => {
160
324
  const tree = createUiStylePathTree();
161
325
  for (const path of paths) {
162
326
  addPathToTree(tree, path);
163
327
  }
164
- return [` interface ${name} {`, ...renderTypeTree(tree, 2, objectType), " }"];
328
+ return [` interface ${name} {`, ...renderTypeTree(tree, 2, objectType, leafType), " }"];
165
329
  };
166
330
  const createUiStyleTypeDeclaration = (options) => {
167
331
  return [
168
332
  "declare global {",
169
333
  ...renderInterfaceDeclaration("BrickflowUiConfigStylePaths", options.configPaths),
170
334
  "",
335
+ ...renderInterfaceDeclaration("BrickflowUiConfigPaths", options.uiConfigPaths),
336
+ "",
171
337
  ...renderInterfaceDeclaration("BrickflowUiStylePaths", options.paths, "BrickflowUiStyleValue"),
172
338
  "}",
173
339
  "",
@@ -175,6 +341,39 @@ const createUiStyleTypeDeclaration = (options) => {
175
341
  ""
176
342
  ].join("\n");
177
343
  };
344
+ const createUiConfigLiteralTypeDeclaration = (paths, config) => [
345
+ "declare global {",
346
+ ...renderInterfaceDeclaration("BrickflowUiConfigLiteralPaths", paths, void 0, (path) => {
347
+ const value = config ? readPath(config, path) : void 0;
348
+ return typeof value === "string" ? toStringLiteral(value) : "string";
349
+ }),
350
+ "}",
351
+ "",
352
+ "export {}",
353
+ ""
354
+ ].join("\n");
355
+ const createUiConfigSchemaTypeDeclaration = (entries) => {
356
+ const schemasByPath = /* @__PURE__ */ new Map();
357
+ for (const { path, schema } of entries) {
358
+ const pathKey = path.join(".");
359
+ const schemas = schemasByPath.get(pathKey) ?? [];
360
+ schemas.push(schema);
361
+ schemasByPath.set(pathKey, schemas);
362
+ }
363
+ return [
364
+ "declare global {",
365
+ " interface BrickflowUiConfigSchema {",
366
+ ...[...schemasByPath.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([path, schemas]) => {
367
+ const [componentName] = path.split(".");
368
+ return ` readonly ${componentName}: ${schemas.map((schema) => `(${schema})`).join(" & ")}`;
369
+ }),
370
+ " }",
371
+ "}",
372
+ "",
373
+ "export {}",
374
+ ""
375
+ ].join("\n");
376
+ };
178
377
  const brickflowUiStylePlugin = (options) => ({
179
378
  buildStart: {
180
379
  handler() {
@@ -197,13 +396,39 @@ const brickflowUiStylePlugin = (options) => ({
197
396
  },
198
397
  name: "brickflow-ui-style",
199
398
  async transform(code, id) {
200
- if (!SCRIPT_FILE_PATTERN.test(id) || !code.includes("UI_STYLE.")) {
399
+ if (!SCRIPT_FILE_PATTERN.test(id) || !code.includes("UI_STYLE.") && !code.includes("UI_CONFIG.") && !code.includes(UI_CONFIG_MACRO)) {
201
400
  return null;
202
401
  }
203
402
  this.addWatchFile?.(options.configPath);
204
403
  const styles = await options.getStyles();
404
+ const config = await options.getConfig();
405
+ const isConfigFile = normalizePath(id.split("?")[0] ?? id) === normalizePath(options.configPath);
406
+ const hasUiConfigMacro = code.includes(UI_CONFIG_MACRO);
205
407
  let changed = false;
206
- const transformedCode = code.replace(UI_STYLE_PATTERN, (match, rawPath) => {
408
+ const codeWithUiConfigMacros = hasUiConfigMacro ? replaceUiConfigMacros(code, config, styles, id, this.error.bind(this)) : code;
409
+ if (codeWithUiConfigMacros !== code) {
410
+ changed = true;
411
+ }
412
+ const transformedCode = codeWithUiConfigMacros.replace(UI_CONFIG_PATTERN, (match, rawPath) => {
413
+ if (hasUiConfigMacro) {
414
+ return match;
415
+ }
416
+ const path = rawPath.slice(1).split(".");
417
+ const value = resolveUiConfigValue(config, id, path);
418
+ changed = true;
419
+ if (value === void 0) {
420
+ return "undefined";
421
+ }
422
+ try {
423
+ const resolvedValue = resolveUiConfigStyleReferences(value, styles, id);
424
+ return typeof resolvedValue === "string" ? toStringLiteral(resolvedValue) : JSON.stringify(resolvedValue);
425
+ } catch (error) {
426
+ this.error(error instanceof Error ? error.message : String(error));
427
+ }
428
+ }).replace(UI_STYLE_PATTERN, (match, rawPath) => {
429
+ if (isConfigFile) {
430
+ return match;
431
+ }
207
432
  const path = rawPath.slice(1).split(".");
208
433
  const value = resolveStyleValue(styles, id, path);
209
434
  if (typeof value === "string") {
@@ -459,8 +684,7 @@ const module$1 = defineNuxtModule({
459
684
  );
460
685
  };
461
686
  await loadUiConfig();
462
- const uiStyleTypePath = resolve(nuxt.options.buildDir, "types/brickflow-ui-style.d.ts");
463
- const generateUiStyleTypes = async () => {
687
+ const getUiStyleTypeContents = async () => {
464
688
  const files = await scanUiStyleFiles(runtimePath);
465
689
  const fileContents = await Promise.all(
466
690
  files.map(async (file) => ({
@@ -468,19 +692,55 @@ const module$1 = defineNuxtModule({
468
692
  file
469
693
  }))
470
694
  );
471
- const paths = fileContents.flatMap(({ content }) => collectUiStylePathsFromCode(content));
695
+ const uiConfig = (await loadUiConfig()).uiConfig;
696
+ const uiConfigStyleReferencePaths = collectUiConfigStyleReferencePaths(uiConfig);
697
+ const paths = [
698
+ ...fileContents.flatMap(({ content }) => collectUiStylePathsFromCode(content)),
699
+ ...uiConfigStyleReferencePaths.map((path) => path.slice(1))
700
+ ];
472
701
  const configPaths = fileContents.flatMap(
473
702
  ({ content, file }) => collectUiStyleConfigPathsFromCode(content, file)
474
703
  );
475
- await mkdir(resolve(nuxt.options.buildDir, "types"), { recursive: true });
476
- await writeFile(
477
- uiStyleTypePath,
478
- createUiStyleTypeDeclaration({
479
- configPaths,
480
- paths
481
- })
704
+ configPaths.push(...uiConfigStyleReferencePaths);
705
+ const uiConfigPaths = fileContents.flatMap(
706
+ ({ content, file }) => collectUiConfigPathsFromCode(content, file, uiConfig)
482
707
  );
708
+ return createUiStyleTypeDeclaration({
709
+ configPaths,
710
+ paths,
711
+ uiConfigPaths
712
+ });
483
713
  };
714
+ const uiStyleTypeTemplate = addTypeTemplate({
715
+ filename: "types/brickflow-ui-style.d.ts",
716
+ getContents: getUiStyleTypeContents
717
+ });
718
+ const uiConfigLiteralTypeTemplate = addTypeTemplate({
719
+ filename: "types/brickflow-ui-config-literals.d.ts",
720
+ getContents: async () => {
721
+ const files = await scanUiStyleFiles(runtimePath);
722
+ const uiConfig = (await loadUiConfig()).uiConfig;
723
+ const paths = await Promise.all(
724
+ files.map(
725
+ async (file) => collectUiConfigComponentPathsFromCode(await readFile(file, "utf8"), file, uiConfig)
726
+ )
727
+ );
728
+ return createUiConfigLiteralTypeDeclaration(paths.flat(), uiConfig);
729
+ }
730
+ });
731
+ const uiConfigSchemaTypeTemplate = addTypeTemplate({
732
+ filename: "types/brickflow-ui-config-contract.d.ts",
733
+ getContents: async () => {
734
+ const files = await scanUiStyleFiles(componentsDirectory);
735
+ const entries = await Promise.all(
736
+ files.map(async (file) => collectUiConfigSchemaEntriesFromCode(await readFile(file, "utf8"), file))
737
+ );
738
+ return createUiConfigSchemaTypeDeclaration(entries.flat());
739
+ }
740
+ });
741
+ nuxt.hook("prepare:types", ({ references }) => {
742
+ references.push({ path: resolver.resolve("./runtime/config.d.ts") });
743
+ });
484
744
  const iconFontTemplate = addTemplate({
485
745
  filename: "brickflow/brickflow-ui-icons.mjs",
486
746
  getContents: async () => {
@@ -495,12 +755,14 @@ const module$1 = defineNuxtModule({
495
755
  const uiConfigTemplate = addTemplate({
496
756
  filename: "brickflow/brickflow-ui-config.mjs",
497
757
  getContents: () => [
498
- `import rawConfig from ${JSON.stringify(resolvedConfigPath.replaceAll("\\", "/"))}`,
499
758
  `import { defineBrickflowUiConfig } from ${JSON.stringify(resolver.resolve("./runtime/tailwind").replaceAll("\\", "/"))}`,
759
+ `import rawConfig from ${JSON.stringify(resolvedConfigPath.replaceAll("\\", "/"))}`,
500
760
  "",
501
761
  "const config = defineBrickflowUiConfig(rawConfig)",
502
762
  "",
503
763
  "export const UI_STYLE = config.uiStyles",
764
+ "export const UI_CONFIG = config.uiConfig",
765
+ "export const uiConfig = config.uiConfig",
504
766
  "export const uiStyles = config.uiStyles",
505
767
  "export default config",
506
768
  ""
@@ -608,21 +870,21 @@ const module$1 = defineNuxtModule({
608
870
  nuxt.hook("pages:extend", (pages) => {
609
871
  pages.push({
610
872
  file: resolver.resolve("./runtime/pages/ui.vue"),
873
+ meta: {
874
+ layout: false
875
+ },
611
876
  name: "brickflow-ui",
612
877
  path: "/ui"
613
878
  });
614
879
  });
615
- await generateUiStyleTypes();
616
- nuxt.hook("prepare:types", async ({ references }) => {
617
- await generateUiStyleTypes();
618
- references.push({ path: uiStyleTypePath });
619
- });
620
880
  nuxt.hook("builder:watch", async (_event, path) => {
621
881
  const absolutePath = resolve(nuxt.options.srcDir, path);
622
882
  if (relative(runtimePath, absolutePath).startsWith("..") || !UI_STYLE_FILE_PATTERN.test(path)) {
623
883
  return;
624
884
  }
625
- await generateUiStyleTypes();
885
+ await updateTemplates({
886
+ filter: (template) => template.filename === uiStyleTypeTemplate.filename || template.filename === uiConfigLiteralTypeTemplate.filename || template.filename === uiConfigSchemaTypeTemplate.filename
887
+ });
626
888
  if (!relative(componentsDirectory, absolutePath).startsWith("..") && (UI_COMPONENT_FILE_PATTERN.test(path) || UI_DEMO_FILE_PATTERN.test(path))) {
627
889
  await updateTemplates({ filter: (template) => template.filename === uiCatalogTemplate.filename });
628
890
  }
@@ -641,6 +903,7 @@ const module$1 = defineNuxtModule({
641
903
  viteConfig.plugins.push(
642
904
  brickflowUiStylePlugin({
643
905
  configPath: resolvedConfigPath,
906
+ getConfig: async () => (await loadUiConfig()).uiConfig,
644
907
  getStyles: async () => (await loadUiConfig()).uiStyles
645
908
  })
646
909
  );
@@ -1,42 +1,48 @@
1
1
  import type { RouteLocationRaw } from 'vue-router';
2
- type __VLS_Props = {
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
3
5
  block?: boolean;
4
- color?: ButtonColor;
6
+ color?: string;
5
7
  disabled?: boolean;
6
8
  icon?: string;
7
9
  loading?: boolean;
8
10
  rounded?: boolean;
9
- size?: ButtonSize;
11
+ size?: string;
10
12
  square?: boolean;
11
13
  to?: RouteLocationRaw;
12
14
  trailingIcon?: string;
13
- type?: 'button' | 'reset' | 'submit';
14
- variant?: ButtonVariant;
15
- };
16
- type ButtonColor = 'alt' | 'danger' | 'info' | 'main' | 'plain' | 'warn' | 'win';
17
- type ButtonSize = 'lg' | 'md' | 'sm' | 'xl' | 'xs';
18
- type ButtonVariant = 'ghost' | 'glass' | 'soft' | 'solid' | 'subtle';
19
- declare var __VLS_10: {}, __VLS_22: {}, __VLS_24: {};
20
- type __VLS_Slots = {} & {
21
- leading?: (props: typeof __VLS_10) => any;
22
- } & {
23
- default?: (props: typeof __VLS_22) => any;
24
- } & {
25
- trailing?: (props: typeof __VLS_24) => any;
26
- };
27
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
28
- size: ButtonSize;
15
+ type?: "button" | "reset" | "submit";
16
+ variant?: string;
17
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
18
+ block?: boolean;
19
+ color?: string;
20
+ disabled?: boolean;
21
+ icon?: string;
22
+ loading?: boolean;
23
+ rounded?: boolean;
24
+ size?: string;
25
+ square?: boolean;
26
+ to?: RouteLocationRaw;
27
+ trailingIcon?: string;
28
+ type?: "button" | "reset" | "submit";
29
+ variant?: string;
30
+ }> & Readonly<{}>, {
31
+ size: string;
29
32
  type: "button" | "reset" | "submit";
33
+ color: string;
30
34
  to: RouteLocationRaw;
31
- color: ButtonColor;
32
35
  icon: string;
33
36
  rounded: boolean;
34
37
  trailingIcon: string;
35
- variant: ButtonVariant;
36
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
38
- declare const _default: typeof __VLS_export;
39
- export default _default;
38
+ variant: string;
39
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
40
+ leading?: (props: {}) => any;
41
+ } & {
42
+ default?: (props: {}) => any;
43
+ } & {
44
+ trailing?: (props: {}) => any;
45
+ }>;
40
46
  type __VLS_WithSlots<T, S> = T & {
41
47
  new (): {
42
48
  $slots: S;
@@ -1,28 +1,27 @@
1
+ <script>
2
+ const UI_CONFIG = defineUiConfig();
3
+ </script>
4
+
1
5
  <script setup>
2
6
  import { computed, shallowRef } from "vue";
3
7
  import Icon from "../Icon/index.vue";
4
8
  import BaseLink from "../Link/index.vue";
5
9
  const props = defineProps({
6
10
  block: { type: Boolean, required: false },
7
- color: { type: String, required: false, default: "main" },
11
+ color: { type: String, required: false, default: UI_CONFIG.colorDefault },
8
12
  disabled: { type: Boolean, required: false },
9
13
  icon: { type: String, required: false, default: void 0 },
10
14
  loading: { type: Boolean, required: false },
11
15
  rounded: { type: Boolean, required: false, default: false },
12
- size: { type: String, required: false, default: "md" },
16
+ size: { type: String, required: false, default: UI_CONFIG.sizeDefault },
13
17
  square: { type: Boolean, required: false },
14
18
  to: { type: null, required: false, default: void 0 },
15
19
  trailingIcon: { type: String, required: false, default: void 0 },
16
20
  type: { type: String, required: false, default: "button" },
17
- variant: { type: String, required: false, default: "solid" }
21
+ variant: { type: String, required: false, default: UI_CONFIG.variantDefault }
18
22
  });
19
- const sizeClasses = {
20
- lg: UI_STYLE.size.lg,
21
- md: UI_STYLE.size.md,
22
- sm: UI_STYLE.size.sm,
23
- xl: UI_STYLE.size.xl,
24
- xs: UI_STYLE.size.xs
25
- };
23
+ const colorClasses = UI_CONFIG.colorClasses;
24
+ const sizeClasses = UI_CONFIG.sizeClasses;
26
25
  const sizeIconClasses = {
27
26
  lg: UI_STYLE.size.lgIcon,
28
27
  md: UI_STYLE.size.mdIcon,
@@ -30,57 +29,6 @@ const sizeIconClasses = {
30
29
  xl: UI_STYLE.size.xlIcon,
31
30
  xs: UI_STYLE.size.xsIcon
32
31
  };
33
- const colorClasses = {
34
- alt: {
35
- ghost: UI_STYLE.color.alt.ghost,
36
- glass: UI_STYLE.color.alt.glass,
37
- soft: UI_STYLE.color.alt.soft,
38
- solid: UI_STYLE.color.alt.solid,
39
- subtle: UI_STYLE.color.alt.subtle
40
- },
41
- danger: {
42
- ghost: UI_STYLE.color.danger.ghost,
43
- glass: UI_STYLE.color.danger.glass,
44
- soft: UI_STYLE.color.danger.soft,
45
- solid: UI_STYLE.color.danger.solid,
46
- subtle: UI_STYLE.color.danger.subtle
47
- },
48
- info: {
49
- ghost: UI_STYLE.color.info.ghost,
50
- glass: UI_STYLE.color.info.glass,
51
- soft: UI_STYLE.color.info.soft,
52
- solid: UI_STYLE.color.info.solid,
53
- subtle: UI_STYLE.color.info.subtle
54
- },
55
- main: {
56
- ghost: UI_STYLE.color.main.ghost,
57
- glass: UI_STYLE.color.main.glass,
58
- soft: UI_STYLE.color.main.soft,
59
- solid: UI_STYLE.color.main.solid,
60
- subtle: UI_STYLE.color.main.subtle
61
- },
62
- plain: {
63
- ghost: UI_STYLE.color.plain.ghost,
64
- glass: UI_STYLE.color.plain.glass,
65
- soft: UI_STYLE.color.plain.soft,
66
- solid: UI_STYLE.color.plain.solid,
67
- subtle: UI_STYLE.color.plain.subtle
68
- },
69
- warn: {
70
- ghost: UI_STYLE.color.warn.ghost,
71
- glass: UI_STYLE.color.warn.glass,
72
- soft: UI_STYLE.color.warn.soft,
73
- solid: UI_STYLE.color.warn.solid,
74
- subtle: UI_STYLE.color.warn.subtle
75
- },
76
- win: {
77
- ghost: UI_STYLE.color.win.ghost,
78
- glass: UI_STYLE.color.win.glass,
79
- soft: UI_STYLE.color.win.soft,
80
- solid: UI_STYLE.color.win.solid,
81
- subtle: UI_STYLE.color.win.subtle
82
- }
83
- };
84
32
  const component = computed(() => props.to === void 0 ? "button" : BaseLink);
85
33
  const disabled = computed(() => props.disabled || props.loading);
86
34
  const isButton = computed(() => props.to === void 0);
@@ -126,7 +74,7 @@ function handleTap() {
126
74
  <slot name="leading">
127
75
  <Icon
128
76
  v-if="props.loading"
129
- :name="UI_STYLE.state.loadingIconName"
77
+ :name="UI_CONFIG.loadingIconName"
130
78
  :class="UI_STYLE.state.loading"
131
79
  aria-hidden="true"
132
80
  />