frappe-ui 1.0.2 → 1.1.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/experimental/Calendar/calendarUtils.ts +33 -21
  2. package/experimental/MultiEmailInput/MultiEmailInput.vue +64 -12
  3. package/experimental/MultiEmailInput/types.ts +12 -3
  4. package/experimental/Stepper/StepIndicator.vue +129 -0
  5. package/experimental/Stepper/Stepper.api.md +117 -0
  6. package/experimental/Stepper/Stepper.md +95 -0
  7. package/experimental/Stepper/Stepper.vue +82 -0
  8. package/experimental/Stepper/StepperHorizontal.vue +93 -0
  9. package/experimental/Stepper/StepperVertical.vue +291 -0
  10. package/experimental/Stepper/index.ts +11 -0
  11. package/experimental/Stepper/resolve.ts +87 -0
  12. package/experimental/Stepper/types.ts +89 -0
  13. package/experimental.ts +2 -0
  14. package/package.json +1 -1
  15. package/src/charts/CalendarHeatmapChart.vue +353 -0
  16. package/src/charts/DonutChart.vue +34 -58
  17. package/src/charts/HeatmapChart.vue +26 -64
  18. package/src/charts/NumberCard.vue +62 -7
  19. package/src/charts/PercentageBarChart.vue +243 -0
  20. package/src/charts/SankeyChart.vue +14 -11
  21. package/src/charts/ScatterChart.vue +24 -20
  22. package/src/charts/axisChartCommon.ts +182 -18
  23. package/src/charts/axisFormat.ts +8 -3
  24. package/src/charts/calendarHeatmapOptions.ts +604 -0
  25. package/src/charts/colorMath.ts +26 -0
  26. package/src/charts/components/ChartContainer.vue +63 -53
  27. package/src/charts/components/ChartLegend.vue +216 -24
  28. package/src/charts/components/ChartScale.vue +85 -0
  29. package/src/charts/core/dataLabelFit.ts +45 -6
  30. package/src/charts/core/useAxisChart.ts +36 -19
  31. package/src/charts/core/useChart.ts +6 -1
  32. package/src/charts/core/usePlotKeyboard.ts +13 -2
  33. package/src/charts/docs/BarChart.md +11 -3
  34. package/src/charts/docs/CalendarHeatmapChart.api.md +165 -0
  35. package/src/charts/docs/CalendarHeatmapChart.md +33 -0
  36. package/src/charts/docs/ChartContainer.api.md +6 -0
  37. package/src/charts/docs/ChartLegend.api.md +1 -1
  38. package/src/charts/docs/ChartLegend.md +25 -3
  39. package/src/charts/docs/DonutChart.api.md +12 -0
  40. package/src/charts/docs/DonutChart.md +17 -0
  41. package/src/charts/docs/HeatmapChart.api.md +1 -1
  42. package/src/charts/docs/LineChart.md +5 -3
  43. package/src/charts/docs/NumberCard.api.md +6 -0
  44. package/src/charts/docs/NumberCard.md +6 -0
  45. package/src/charts/docs/Overview.md +13 -6
  46. package/src/charts/docs/PercentageBarChart.api.md +148 -0
  47. package/src/charts/docs/PercentageBarChart.md +42 -0
  48. package/src/charts/docs/ScatterChart.md +2 -3
  49. package/src/charts/donutChartOptions.ts +22 -130
  50. package/src/charts/format.ts +4 -1
  51. package/src/charts/heatmapOptions.ts +17 -12
  52. package/src/charts/hiddenSeries.ts +8 -3
  53. package/src/charts/index.ts +12 -0
  54. package/src/charts/legendOverflow.ts +40 -0
  55. package/src/charts/numberCardFormat.ts +19 -13
  56. package/src/charts/referenceLines.ts +2 -1
  57. package/src/charts/scatterOptions.ts +16 -3
  58. package/src/charts/seriesData.ts +8 -3
  59. package/src/charts/slices.ts +228 -0
  60. package/src/charts/tokens.ts +99 -0
  61. package/src/charts/types.ts +318 -9
  62. package/src/components/Avatar/Avatar.md +27 -2
  63. package/src/components/Avatar/Avatar.vue +29 -12
  64. package/src/components/Combobox/Combobox.vue +9 -2
  65. package/src/components/Combobox/ComboboxResults.vue +6 -1
  66. package/src/components/Combobox/utils.ts +2 -1
  67. package/src/components/Dialog/Dialog.md +3 -1
  68. package/src/components/Duration/Duration.api.md +16 -3
  69. package/src/components/Duration/Duration.md +21 -0
  70. package/src/components/Duration/Duration.vue +29 -8
  71. package/src/components/Duration/duration.ts +105 -44
  72. package/src/components/Duration/index.ts +1 -0
  73. package/src/components/Duration/types.ts +30 -1
  74. package/src/components/Menu/utils.ts +3 -2
  75. package/src/components/MultiSelect/MultiSelect.api.md +5 -0
  76. package/src/components/MultiSelect/MultiSelect.vue +34 -0
  77. package/src/components/MultiSelect/MultiSelectResults.vue +3 -4
  78. package/src/components/MultiSelect/types.ts +6 -0
  79. package/src/components/Select/Select.vue +4 -4
  80. package/src/components/Select/utils.ts +1 -0
  81. package/src/components/Switch/Switch.vue +3 -3
  82. package/src/components/shared/selection/utils.ts +8 -1
  83. package/src/data-fetching/useCall/useCall.ts +25 -26
  84. package/src/data-fetching/useFrappeFetch.ts +48 -2
  85. package/src/data-fetching/useList/useList.ts +11 -3
  86. package/src/data-fetching/utils.ts +15 -1
  87. package/src/molecules/editor/components/MediaNodeView.vue +10 -1
  88. package/src/molecules/editor/components/MediaResizeGuide.vue +71 -0
  89. package/src/molecules/editor/components/media-node-view-utils.ts +7 -0
  90. package/src/molecules/editor/composables/useNodeViewResize.ts +142 -10
  91. package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +3 -1
  92. package/src/molecules/editor/useEditor.ts +12 -6
  93. package/src/utils/dialog.ts +37 -14
  94. package/tailwind/content.js +1 -0
  95. package/vite/README.md +5 -3
  96. package/vite/codeLanguages.js +41 -17
@@ -7,6 +7,7 @@ import {
7
7
  type Ref,
8
8
  } from 'vue'
9
9
  import { moduleSingleton } from './moduleSingleton'
10
+ import { useId } from './useId'
10
11
  import Dialog from '../components/Dialog/Dialog.vue'
11
12
  import { Button } from '../components/Button'
12
13
  import FormControl from '../components/FormControl/FormControl.vue'
@@ -551,8 +552,8 @@ export function prompt(args: PromptArgs): DialogHandle {
551
552
  if (state.loading) return
552
553
  const missing = checkRequired()
553
554
  if (missing) {
554
- // Match the previous behavior — silently no-op so HTML5 required UI
555
- // can take over via the underlying FormControl.
555
+ // Required fields are checked here because the form is `novalidate`.
556
+ // An empty required field blocks submit without a message.
556
557
  return
557
558
  }
558
559
  state.loading = true
@@ -580,6 +581,11 @@ export function prompt(args: PromptArgs): DialogHandle {
580
581
  const resolvedIcon = resolveIcon(args.theme, args.icon)
581
582
  const buttonTheme = themeToButtonTheme(args.theme)
582
583
 
584
+ const autofocusField = args.fields.find(
585
+ (field) =>
586
+ !field.type || field.type === 'text' || field.type === 'textarea',
587
+ )
588
+
583
589
  const renderField = (field: PromptField) => {
584
590
  const onUpdate = (val: any) => {
585
591
  values[field.name] = val
@@ -609,6 +615,7 @@ export function prompt(args: PromptArgs): DialogHandle {
609
615
  label: field.label,
610
616
  description: field.description,
611
617
  type: (field.type as any) || 'text',
618
+ autofocus: field === autofocusField || undefined,
612
619
  required: field.required,
613
620
  placeholder: field.placeholder,
614
621
  options,
@@ -637,6 +644,7 @@ export function prompt(args: PromptArgs): DialogHandle {
637
644
  const component = defineComponent({
638
645
  name: 'ImperativePromptDialog',
639
646
  setup() {
647
+ const formId = useId()
640
648
  return () =>
641
649
  h(
642
650
  Dialog,
@@ -655,17 +663,31 @@ export function prompt(args: PromptArgs): DialogHandle {
655
663
  },
656
664
  {
657
665
  default: () =>
658
- h('div', { class: 'space-y-3' }, [
659
- args.message
660
- ? h(
661
- 'p',
662
- { class: 'text-p-base text-ink-gray-7' },
663
- args.message,
664
- )
665
- : null,
666
- ...args.fields.map(renderField),
667
- state.error ? h(ErrorMessage, { message: state.error }) : null,
668
- ]),
666
+ h(
667
+ 'form',
668
+ {
669
+ id: formId,
670
+ class: 'space-y-3',
671
+ novalidate: true,
672
+ onSubmit: (event: Event) => {
673
+ event.preventDefault()
674
+ onSubmit()
675
+ },
676
+ },
677
+ [
678
+ args.message
679
+ ? h(
680
+ 'p',
681
+ { class: 'text-p-base text-ink-gray-7' },
682
+ args.message,
683
+ )
684
+ : null,
685
+ ...args.fields.map(renderField),
686
+ state.error
687
+ ? h(ErrorMessage, { message: state.error })
688
+ : null,
689
+ ],
690
+ ),
669
691
  actions: () =>
670
692
  h('div', { class: 'flex flex-row-reverse gap-2' }, [
671
693
  h(Button, {
@@ -673,7 +695,8 @@ export function prompt(args: PromptArgs): DialogHandle {
673
695
  variant: 'solid',
674
696
  theme: buttonTheme,
675
697
  loading: state.loading,
676
- onClick: onSubmit,
698
+ type: 'submit',
699
+ form: formId,
677
700
  }),
678
701
  h(Button, {
679
702
  label: args.cancelLabel || 'Cancel',
@@ -49,6 +49,7 @@ export const content = [
49
49
  glob('experimental/Accordion/**/*.{vue,js,ts,jsx,tsx}'),
50
50
  glob('experimental/FloatingWindow/**/*.{vue,js,ts,jsx,tsx}'),
51
51
  glob('experimental/MultiEmailInput/**/*.{vue,js,ts,jsx,tsx}'),
52
+ glob('experimental/Stepper/**/*.{vue,js,ts,jsx,tsx}'),
52
53
  glob('experimental/Calendar/**/*.{vue,js,ts,jsx,tsx}'),
53
54
  glob('experimental/Charts/**/*.{vue,js,ts,jsx,tsx}'),
54
55
  glob('experimental/CommandPalette/**/*.{vue,js,ts,jsx,tsx}'),
package/vite/README.md CHANGED
@@ -241,9 +241,11 @@ Error during dependency optimization:
241
241
 
242
242
  The plugin replaces an absent package with a stub that throws when
243
243
  `loadLanguage` reaches it. It covers both paths: a Rollup `resolveId` hook for
244
- the build, and an esbuild twin through `optimizeDeps.esbuildOptions.plugins` for
245
- dependency pre-bundling, which runs no Rollup hooks. The build and the dev
246
- server both succeed, and the error names the package to install:
244
+ the build, and a twin for dependency pre-bundling, which runs no user plugin
245
+ hooks. On Vite 8 the twin goes through `optimizeDeps.rolldownOptions.plugins`;
246
+ on older Vite it is an esbuild plugin through
247
+ `optimizeDeps.esbuildOptions.plugins`. The build and the dev server both
248
+ succeed, and the error names the package to install:
247
249
 
248
250
  ```
249
251
  [frappe-ui] loadLanguage('sql') could not load @codemirror/lang-sql: Cannot find module '@codemirror/lang-sql'. If it is not installed: yarn add @codemirror/lang-sql
@@ -25,18 +25,23 @@
25
25
  *
26
26
  * The same job has to be done twice. `resolveId` covers the Rollup graph, which
27
27
  * is the production build and every dev request the server transforms. It
28
- * cannot cover Vite's dependency pre-bundling: that step is esbuild, and it
29
- * resolves through `vite:resolve` alone, with no user plugin hooks. `frappe-ui`
30
- * is a bare specifier, so `frappe-ui/code-editor` is pre-bundled, and an absent
31
- * language there does not degrade — esbuild fails the optimize step and the dev
32
- * server exits:
28
+ * cannot cover Vite's dependency pre-bundling: that step is a separate esbuild
29
+ * or Rolldown build, and it runs no user plugin hooks. `frappe-ui` is a bare
30
+ * specifier, so `frappe-ui/code-editor` is pre-bundled, and an absent language
31
+ * there does not degrade. Before Vite 8, esbuild fails the optimize step and
32
+ * the dev server exits:
33
33
  *
34
34
  * Error during dependency optimization:
35
35
  * ✘ [ERROR] Could not resolve "@codemirror/lang-json"
36
36
  *
37
- * So the plugin also contributes an esbuild twin through
38
- * `optimizeDeps.esbuildOptions.plugins`, which does the same resolve-then-stub
39
- * with esbuild's hooks.
37
+ * So the plugin also hands the optimizer a twin. Vite 8 pre-bundles with
38
+ * Rolldown, which runs Rollup-style hooks, so the twin there is the same
39
+ * `resolveId` and `load` through `optimizeDeps.rolldownOptions.plugins`. Older
40
+ * Vite pre-bundles with esbuild, so the twin there does the same
41
+ * resolve-then-stub with esbuild's hooks through
42
+ * `optimizeDeps.esbuildOptions.plugins`. Vite 8 only imitates part of
43
+ * esbuild's plugin API, and the esbuild twin needs the parts it leaves out, so
44
+ * each Vite gets its own.
40
45
  */
41
46
 
42
47
  import { dirname, join } from 'node:path'
@@ -85,6 +90,31 @@ function moduleKey(id) {
85
90
  }
86
91
 
87
92
  export function codeLanguages() {
93
+ return {
94
+ ...stubPlugin(),
95
+ // `pre`, so the hook runs before Vite's resolver and can ask for it by
96
+ // hand. `this.resolve` reports the absence instead of throwing it.
97
+ enforce: 'pre',
98
+
99
+ config() {
100
+ // Vite 8 and rolldown-vite set `rolldownVersion`; esbuild Vite does not.
101
+ if (this?.meta?.rolldownVersion) {
102
+ return {
103
+ optimizeDeps: { rolldownOptions: { plugins: [stubPlugin()] } },
104
+ }
105
+ }
106
+ return { optimizeDeps: { esbuildOptions: { plugins: [esbuildTwin()] } } }
107
+ },
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Stub a language package that does not resolve, but only for frappe-ui's own
113
+ * `languages` module. Rollup and Rolldown share these hooks, so Vite 8's
114
+ * pre-bundling reuses them. It gets its own copy because `languagesModule` is
115
+ * cached per build.
116
+ */
117
+ function stubPlugin() {
88
118
  // `frappe-ui/code-editor`'s own directory, resolved once per build. A path
89
119
  // test would be wrong: an app is free to keep its own
90
120
  // `src/code-editor/languages.ts`, and stubbing a package that file needs
@@ -111,9 +141,6 @@ export function codeLanguages() {
111
141
 
112
142
  return {
113
143
  name: 'frappeui-code-languages',
114
- // `pre`, so the hook runs before Vite's resolver and can ask for it by
115
- // hand. `this.resolve` reports the absence instead of throwing it.
116
- enforce: 'pre',
117
144
 
118
145
  buildStart() {
119
146
  languagesModule = null
@@ -138,16 +165,13 @@ export function codeLanguages() {
138
165
  if (!id.startsWith(VIRTUAL_PREFIX)) return null
139
166
  return stub(id.slice(VIRTUAL_PREFIX.length))
140
167
  },
141
-
142
- config() {
143
- return { optimizeDeps: { esbuildOptions: { plugins: [esbuildTwin()] } } }
144
- },
145
168
  }
146
169
  }
147
170
 
148
171
  /**
149
- * The pre-bundling half. Same rule, esbuild's hooks: stub a language package
150
- * that does not resolve, but only for frappe-ui's own `languages` module.
172
+ * The pre-bundling half before Vite 8. Same rule, esbuild's hooks: stub a
173
+ * language package that does not resolve, but only for frappe-ui's own
174
+ * `languages` module.
151
175
  */
152
176
  function esbuildTwin() {
153
177
  return {