@brickflow/ui 0.0.57 → 0.0.58

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 (31) hide show
  1. package/dist/module.d.mts +3 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +33 -7
  4. package/dist/runtime/brickflow-ui.d.ts +1 -0
  5. package/dist/runtime/components/Button/index.vue +5 -3
  6. package/dist/runtime/components/Dialog/DemoContent.vue +33 -0
  7. package/dist/runtime/components/Dialog/DemoForm.vue +54 -0
  8. package/dist/runtime/components/Dialog/DemoSimple.vue +23 -0
  9. package/dist/runtime/components/Dialog/DemoStack.vue +41 -0
  10. package/dist/runtime/components/Dialog/Host.vue +654 -0
  11. package/dist/runtime/components/Dialog/basic.demo.vue +27 -0
  12. package/dist/runtime/components/Dialog/form.demo.vue +34 -0
  13. package/dist/runtime/components/Dialog/index.vue +53 -0
  14. package/dist/runtime/components/Dialog/scroll.demo.vue +27 -0
  15. package/dist/runtime/components/Dialog/stack.demo.vue +19 -0
  16. package/dist/runtime/components/Form/rules.demo.vue +108 -0
  17. package/dist/runtime/components/Icon/gallery.demo.vue +1 -1
  18. package/dist/runtime/components/Icon/index.vue +3 -1
  19. package/dist/runtime/components/Input/index.vue +7 -5
  20. package/dist/runtime/components/InputNumber/controls.demo.vue +145 -0
  21. package/dist/runtime/components/InputNumber/index.vue +4 -3
  22. package/dist/runtime/composables/useDialog.d.ts +38 -0
  23. package/dist/runtime/composables/useDialog.js +40 -0
  24. package/dist/runtime/composables/useScreen.d.ts +8 -0
  25. package/dist/runtime/plugins/dialog.d.ts +3 -0
  26. package/dist/runtime/plugins/dialog.js +22 -0
  27. package/dist/runtime/tailwind.d.ts +1 -1
  28. package/dist/runtime/tailwind.js +2 -2
  29. package/dist/types.d.mts +2 -0
  30. package/package.json +6 -6
  31. package/dist/runtime/icon-font.d.ts +0 -4
package/dist/module.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
1
+ import * as nuxt_schema from 'nuxt/schema';
2
2
  export { BrickflowConfig } from '../dist/runtime/composables/useBrickflow.js';
3
+ export { DialogController, DialogHandle, DialogOptions } from '../dist/runtime/composables/useDialog.js';
3
4
  export { BrickflowI18n, BrickflowRouteLocationParam } from '../dist/runtime/composables/useTranslate.js';
4
5
  export { Rule, RuleMessages, rule } from '../dist/runtime/utils/rules.js';
5
6
 
@@ -10,7 +11,7 @@ interface ModuleOptions {
10
11
  theme?: boolean;
11
12
  }
12
13
 
13
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
14
+ declare const _default: nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
14
15
 
15
16
  export { _default as default };
16
17
  export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "configKey": "brickflowUi",
6
6
  "name": "@brickflow/ui",
7
- "version": "0.0.57",
7
+ "version": "0.0.58",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, resolvePath, addTypeTemplate, addTemplate, updateTemplates, addImports, addComponentsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, resolvePath, addTypeTemplate, addTemplate, updateTemplates, addImports, addPlugin, addComponentsDir } from '@nuxt/kit';
2
2
  import tailwindcss from '@tailwindcss/vite';
3
3
  import { createJiti } from 'jiti';
4
4
  import { mkdir, access, readFile, writeFile, readdir } from 'node:fs/promises';
@@ -151,7 +151,9 @@ const resolveUiStyleConfigPath = (id, path) => {
151
151
  return path;
152
152
  }
153
153
  const componentName = basename(cleanId, extname(cleanId));
154
- const configName = componentName === "index" || componentName.endsWith(".demo") ? basename(dirname(cleanId)) : componentName;
154
+ const parentName = basename(dirname(cleanId));
155
+ const isComponentFile = basename(dirname(dirname(cleanId))) === "components";
156
+ const configName = isComponentFile || componentName === "index" || componentName.endsWith(".demo") ? parentName : componentName;
155
157
  return [toCamelCase(configName), ...path];
156
158
  };
157
159
  const resolveStyleValue = (styles, id, path) => {
@@ -178,7 +180,7 @@ const resolveUiConfigStyleReferences = (value, styles, id) => {
178
180
  }
179
181
  return styleValue;
180
182
  }
181
- if (typeof value === "string") {
183
+ if (typeof value === "string" || typeof value === "boolean" || typeof value === "number") {
182
184
  return value;
183
185
  }
184
186
  return Object.fromEntries(
@@ -267,7 +269,7 @@ const collectUiStylePathsFromCode = (code) => {
267
269
  return paths.filter((path) => path.length > 0);
268
270
  };
269
271
  const collectUiConfigValuePaths = (value, prefix) => {
270
- if (typeof value === "string" || isBrickflowUiStyleReference(value)) {
272
+ if (typeof value === "string" || typeof value === "boolean" || typeof value === "number" || isBrickflowUiStyleReference(value)) {
271
273
  return [prefix];
272
274
  }
273
275
  return Object.entries(value).flatMap(
@@ -358,7 +360,7 @@ const collectUiStylePathsWithConfig = (code, id, config) => {
358
360
  const requiredPath = [...referencePath.slice(0, prefixLength), ...configPath.slice(1)];
359
361
  configReferences.push(`UI_STYLE.${requiredPath.join(".")}`);
360
362
  }
361
- } else if (typeof value !== "string") {
363
+ } else if (typeof value === "object") {
362
364
  for (const [key, childValue] of Object.entries(value)) {
363
365
  addConfigReferences(childValue, [...configPath, key]);
364
366
  }
@@ -395,7 +397,16 @@ const createUiConfigLiteralTypeDeclaration = (paths, config) => [
395
397
  "declare global {",
396
398
  ...renderInterfaceDeclaration("BrickflowUiConfigLiteralPaths", paths, void 0, (path) => {
397
399
  const value = config ? readPath(config, path) : void 0;
398
- return typeof value === "string" ? toStringLiteral(value) : "string";
400
+ if (typeof value === "string") {
401
+ return toStringLiteral(value);
402
+ }
403
+ if (typeof value === "boolean") {
404
+ return String(value);
405
+ }
406
+ if (typeof value === "number") {
407
+ return String(value);
408
+ }
409
+ return "string";
399
410
  }),
400
411
  "}",
401
412
  "",
@@ -806,6 +817,19 @@ const module$1 = defineNuxtModule({
806
817
  ].join("\n");
807
818
  }
808
819
  });
820
+ addTemplate({
821
+ filename: "brickflow/brickflow-ui-icons.d.mts",
822
+ getContents: async () => {
823
+ const iconNames = iconFont ? await getIconFontNames(iconFont.inputDir) : [];
824
+ const iconNameType = iconNames.length ? iconNames.map((name) => JSON.stringify(name)).join(" | ") : "never";
825
+ return [
826
+ `export type IconName = ${iconNameType}`,
827
+ "export const firstIconName: IconName",
828
+ "export const iconNames: readonly IconName[]",
829
+ ""
830
+ ].join("\n");
831
+ }
832
+ });
809
833
  const uiConfigTemplate = addTemplate({
810
834
  filename: "brickflow/brickflow-ui-config.mjs",
811
835
  getContents: () => [
@@ -978,6 +1002,7 @@ const module$1 = defineNuxtModule({
978
1002
  viteConfig.plugins.push(tailwindcss());
979
1003
  });
980
1004
  addImports([
1005
+ { as: "useDialog", from: resolver.resolve("./runtime/composables/useDialog"), name: "useDialog" },
981
1006
  { from: resolver.resolve("./runtime/utils/rules"), name: "rule" },
982
1007
  ...["provideBrickflow", "useBrickflow", "BrickflowConfig"].map((name) => ({
983
1008
  from: resolver.resolve("./runtime/composables/useBrickflow"),
@@ -994,8 +1019,9 @@ const module$1 = defineNuxtModule({
994
1019
  type: name !== "useTheme"
995
1020
  }))
996
1021
  ]);
1022
+ addPlugin({ mode: "all", src: resolver.resolve("./runtime/plugins/dialog.ts") });
997
1023
  addComponentsDir({
998
- ignore: ["**/*.demo.vue"],
1024
+ ignore: ["**/*.demo.vue", "**/Dialog/Host.vue", "**/Dialog/DemoContent.vue"],
999
1025
  path: resolver.resolve("./runtime/components"),
1000
1026
  pathPrefix: false,
1001
1027
  prefix: options.componentPrefix ?? "Brick"
@@ -1,4 +1,5 @@
1
1
  declare module '#brickflow-ui' {
2
2
  export { UI_CONFIG, UI_STYLE, uiConfig, uiStyles } from '#brickflow-ui-config'
3
3
  export { firstIconName, iconNames } from '#brickflow-ui-icons'
4
+ export type { IconName } from '#brickflow-ui-icons'
4
5
  }
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
+ import type { IconName } from '#brickflow-ui'
3
+
2
4
  const UI_CONFIG = defineUiConfig<{
3
5
  colorClasses: Record<string, Record<string, string>>
4
6
  colorDefault: string
5
- loadingIconName: string
7
+ loadingIconName: IconName
6
8
  loadingIconTransition: string
7
9
  sizeClasses: Record<string, string>
8
10
  sizeDefault: string
@@ -28,14 +30,14 @@
28
30
  block?: boolean
29
31
  color?: ButtonColor
30
32
  disabled?: boolean
31
- icon?: string
33
+ icon?: IconName
32
34
  loading?: boolean
33
35
  rounded?: boolean
34
36
  size?: ButtonSize
35
37
  square?: boolean
36
38
  target?: '_blank' | '_parent' | '_self' | '_top' | null | (Record<string, never> & string)
37
39
  to?: RouteLocationRaw
38
- trailingIcon?: string
40
+ trailingIcon?: IconName
39
41
  type?: 'button' | 'reset' | 'submit'
40
42
  variant?: ButtonVariant
41
43
  }>(),
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import { useDialog } from '../../composables/useDialog'
3
+ import Button from '../Button/index.vue'
4
+
5
+ defineProps<{ text: string }>()
6
+
7
+ const dialog = useDialog()
8
+ </script>
9
+
10
+ <template>
11
+ <div class="min-h-0 space-y-4 overflow-y-auto bg-linear-to-tr from-violet-900 to-gray-800 p-5">
12
+ <div class="flex flex-wrap items-center justify-between gap-3">
13
+ <p class="font-semibold">{{ text }}</p>
14
+ <Button
15
+ color="plain"
16
+ @click="dialog.close()"
17
+ >
18
+ Close
19
+ </Button>
20
+ </div>
21
+ <p class="text-sm text-zinc-200">Scroll this content, then swipe down from the top edge to move the sheet.</p>
22
+ <ul class="divide-y divide-white/10">
23
+ <li
24
+ v-for="i in 40"
25
+ :key="i"
26
+ class="flex items-center justify-between gap-4 py-2 text-sm"
27
+ >
28
+ <span>Activity {{ i }}</span>
29
+ <span class="text-zinc-300">{{ i % 2 ? 'Updated' : 'Created' }}</span>
30
+ </li>
31
+ </ul>
32
+ </div>
33
+ </template>
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+
4
+ import { useDialog } from '../../composables/useDialog'
5
+ import Button from '../Button/index.vue'
6
+ import Input from '../Input/index.vue'
7
+
8
+ const props = defineProps<{ onSave: (name: string) => void }>()
9
+ const dialog = useDialog()
10
+ const name = ref('')
11
+
12
+ function save(): void {
13
+ const value = name.value.trim()
14
+ if (!value) {
15
+ return
16
+ }
17
+ props.onSave(value)
18
+ dialog.close()
19
+ }
20
+ </script>
21
+
22
+ <template>
23
+ <form
24
+ class="space-y-4 p-5"
25
+ @submit.prevent="save"
26
+ >
27
+ <div class="space-y-1">
28
+ <h2 class="font-semibold">Create a project</h2>
29
+ <p class="text-sm text-zinc-300">Form state belongs to the dialog content.</p>
30
+ </div>
31
+ <Input
32
+ :value="name"
33
+ label="Project name"
34
+ placeholder="My project"
35
+ autocomplete="off"
36
+ @input="name = $event"
37
+ />
38
+ <div class="flex flex-wrap gap-2">
39
+ <Button
40
+ type="submit"
41
+ :disabled="!name.trim()"
42
+ >
43
+ Save project
44
+ </Button>
45
+ <Button
46
+ color="plain"
47
+ type="button"
48
+ @click="dialog.close()"
49
+ >
50
+ Cancel
51
+ </Button>
52
+ </div>
53
+ </form>
54
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ import { useDialog } from '../../composables/useDialog'
3
+ import Button from '../Button/index.vue'
4
+
5
+ defineProps<{ title: string }>()
6
+
7
+ const dialog = useDialog()
8
+ </script>
9
+
10
+ <template>
11
+ <div class="space-y-4 p-5">
12
+ <div class="space-y-1">
13
+ <h2 class="font-semibold">{{ title }}</h2>
14
+ <p class="text-sm text-zinc-300">The placement changes; this content component stays the same.</p>
15
+ </div>
16
+ <Button
17
+ color="plain"
18
+ @click="dialog.close()"
19
+ >
20
+ Close
21
+ </Button>
22
+ </div>
23
+ </template>
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ import { defineAsyncComponent } from 'vue'
3
+
4
+ import { useDialog } from '../../composables/useDialog'
5
+ import Button from '../Button/index.vue'
6
+
7
+ const props = defineProps<{ level: number }>()
8
+ const dialog = useDialog()
9
+ const LazyDemoStack = defineAsyncComponent(() => import('./DemoStack.vue'))
10
+
11
+ function openNext(): void {
12
+ dialog.open(LazyDemoStack, { level: props.level + 1 })
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <div class="space-y-4 p-5">
18
+ <div class="space-y-1">
19
+ <h2 class="font-semibold">Dialog {{ level }}</h2>
20
+ <p class="text-sm text-zinc-300">
21
+ Stack depth: {{ dialog.stack.length }}. Closing the top reveals the previous one.
22
+ </p>
23
+ </div>
24
+ <div class="flex flex-wrap gap-2">
25
+ <Button @click="openNext">Open on top</Button>
26
+ <Button
27
+ color="plain"
28
+ @click="dialog.close()"
29
+ >
30
+ Close top
31
+ </Button>
32
+ <Button
33
+ color="plain"
34
+ variant="ghost"
35
+ @click="dialog.closeAll()"
36
+ >
37
+ Close all
38
+ </Button>
39
+ </div>
40
+ </div>
41
+ </template>