@fastkit/vui 0.6.38 → 0.6.42

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 (188) hide show
  1. package/dist/tool/index.js +3 -0
  2. package/dist/tool/vite-plugin.d.ts.map +1 -1
  3. package/dist/vui.cjs.js +180 -5
  4. package/dist/vui.cjs.prod.js +180 -5
  5. package/dist/vui.css +24 -14
  6. package/dist/vui.d.ts +3294 -876
  7. package/dist/vui.esm-bundler.js +180 -7
  8. package/dist/vui.min.css +1 -1
  9. package/dist/vui.min.css.map +1 -1
  10. package/package.json +8 -7
  11. package/src/.DS_Store +0 -0
  12. package/src/assets/.DS_Store +0 -0
  13. package/src/assets/builtins/color-scheme.ts +9 -0
  14. package/src/assets/builtins/media-match.ts +3 -0
  15. package/src/components/.DS_Store +0 -0
  16. package/src/components/VAccordion/VAccordion.scss +2 -0
  17. package/src/components/VAccordion/VAccordion.tsx +5 -0
  18. package/src/components/VAccordion/index.ts +1 -0
  19. package/src/components/VApp/VApp.tsx +17 -0
  20. package/src/components/VApp/index.ts +1 -0
  21. package/src/components/VBreadcrumbs/VBreadcrumbs.scss +61 -0
  22. package/src/components/VBreadcrumbs/VBreadcrumbs.tsx +137 -0
  23. package/src/components/VBreadcrumbs/index.ts +1 -0
  24. package/src/components/VButton/.DS_Store +0 -0
  25. package/src/components/VButton/VButton.scss +137 -0
  26. package/src/components/VButton/VButton.tsx +148 -0
  27. package/src/components/VButton/VButtonGroup.scss +23 -0
  28. package/src/components/VButton/VButtonGroup.tsx +81 -0
  29. package/src/components/VButton/index.ts +2 -0
  30. package/src/components/VCard/VCard.scss +3 -0
  31. package/src/components/VCard/VCard.tsx +20 -0
  32. package/src/components/VCard/VCardActions.scss +10 -0
  33. package/src/components/VCard/VCardActions.tsx +16 -0
  34. package/src/components/VCard/VCardContent.scss +3 -0
  35. package/src/components/VCard/VCardContent.tsx +16 -0
  36. package/src/components/VCard/index.ts +3 -0
  37. package/src/components/VCheckable/VCheckable.scss +103 -0
  38. package/src/components/VCheckable/VCheckable.tsx +60 -0
  39. package/src/components/VCheckable/index.ts +1 -0
  40. package/src/components/VCheckbox/VCheckbox.scss +56 -0
  41. package/src/components/VCheckbox/VCheckbox.tsx +63 -0
  42. package/src/components/VCheckbox/index.ts +1 -0
  43. package/src/components/VCheckboxGroup/.DS_Store +0 -0
  44. package/src/components/VCheckboxGroup/VCheckboxGroup.tsx +11 -0
  45. package/src/components/VCheckboxGroup/index.ts +1 -0
  46. package/src/components/VContentSwitcher/VContentSwitcher.scss +73 -0
  47. package/src/components/VContentSwitcher/VContentSwitcher.tsx +156 -0
  48. package/src/components/VContentSwitcher/index.ts +1 -0
  49. package/src/components/VControlField/VControlField.scss +183 -0
  50. package/src/components/VControlField/VControlField.tsx +152 -0
  51. package/src/components/VControlField/index.ts +1 -0
  52. package/src/components/VDataTable/VDataTable.scss +230 -0
  53. package/src/components/VDataTable/VDataTable.tsx +761 -0
  54. package/src/components/VDataTable/index.ts +1 -0
  55. package/src/components/VDrawerLayout/VDrawerLayout.scss +26 -0
  56. package/src/components/VDrawerLayout/VDrawerLayout.tsx +35 -0
  57. package/src/components/VDrawerLayout/index.ts +1 -0
  58. package/src/components/VForm/VForm.tsx +77 -0
  59. package/src/components/VForm/index.ts +1 -0
  60. package/src/components/VFormControl/VFormControl.scss +59 -0
  61. package/src/components/VFormControl/VFormControl.tsx +85 -0
  62. package/src/components/VFormControl/index.ts +1 -0
  63. package/src/components/VGrid/VGridContainer.scss +4 -0
  64. package/src/components/VGrid/VGridContainer.tsx +191 -0
  65. package/src/components/VGrid/VGridItem.scss +3 -0
  66. package/src/components/VGrid/VGridItem.tsx +114 -0
  67. package/src/components/VGrid/index.ts +2 -0
  68. package/src/components/VGrid/schemes.ts +28 -0
  69. package/src/components/VHero/.DS_Store +0 -0
  70. package/src/components/VHero/VHero.scss +26 -0
  71. package/src/components/VHero/VHero.tsx +52 -0
  72. package/src/components/VHero/index.ts +1 -0
  73. package/src/components/VIcon/VIcon.scss +22 -0
  74. package/src/components/VIcon/VIcon.tsx +110 -0
  75. package/src/components/VIcon/index.ts +1 -0
  76. package/src/components/VListTile/VListTile.scss +71 -0
  77. package/src/components/VListTile/VListTile.tsx +121 -0
  78. package/src/components/VListTile/index.ts +1 -0
  79. package/src/components/VNavigation/VNavigation.scss +12 -0
  80. package/src/components/VNavigation/VNavigation.tsx +79 -0
  81. package/src/components/VNavigation/VNavigationItem.scss +14 -0
  82. package/src/components/VNavigation/VNavigationItem.tsx +252 -0
  83. package/src/components/VNavigation/index.ts +2 -0
  84. package/src/components/VOption/VOption.scss +61 -0
  85. package/src/components/VOption/VOption.tsx +52 -0
  86. package/src/components/VOption/index.ts +1 -0
  87. package/src/components/VOptionGroup/VOptionGroup.scss +3 -0
  88. package/src/components/VOptionGroup/VOptionGroup.tsx +55 -0
  89. package/src/components/VOptionGroup/index.ts +1 -0
  90. package/src/components/VPagination/VPagination.scss +100 -0
  91. package/src/components/VPagination/VPagination.tsx +346 -0
  92. package/src/components/VPagination/index.ts +1 -0
  93. package/src/components/VPaper/VPaper.scss +37 -0
  94. package/src/components/VPaper/VPaper.tsx +78 -0
  95. package/src/components/VPaper/index.ts +1 -0
  96. package/src/components/VRadio/.DS_Store +0 -0
  97. package/src/components/VRadio/VRadio.scss +66 -0
  98. package/src/components/VRadio/VRadio.tsx +56 -0
  99. package/src/components/VRadio/index.ts +1 -0
  100. package/src/components/VRadioGroup/.DS_Store +0 -0
  101. package/src/components/VRadioGroup/VRadioGroup.tsx +10 -0
  102. package/src/components/VRadioGroup/index.ts +1 -0
  103. package/src/components/VSelect/VSelect.scss +78 -0
  104. package/src/components/VSelect/VSelect.tsx +204 -0
  105. package/src/components/VSelect/index.ts +1 -0
  106. package/src/components/VSwitch/VSwitch.scss +125 -0
  107. package/src/components/VSwitch/VSwitch.tsx +66 -0
  108. package/src/components/VSwitch/index.ts +1 -0
  109. package/src/components/VSwitchGroup/.DS_Store +0 -0
  110. package/src/components/VSwitchGroup/VSwitchGroup.tsx +11 -0
  111. package/src/components/VSwitchGroup/index.ts +1 -0
  112. package/src/components/VTabs/.DS_Store +0 -0
  113. package/src/components/VTabs/VTab.scss +73 -0
  114. package/src/components/VTabs/VTab.tsx +88 -0
  115. package/src/components/VTabs/VTabs.scss +49 -0
  116. package/src/components/VTabs/VTabs.tsx +315 -0
  117. package/src/components/VTabs/index.ts +1 -0
  118. package/src/components/VTextCounter/VTextCounter.scss +3 -0
  119. package/src/components/VTextCounter/VTextCounter.tsx +21 -0
  120. package/src/components/VTextCounter/index.ts +1 -0
  121. package/src/components/VTextField/VTextField.scss +45 -0
  122. package/src/components/VTextField/VTextField.tsx +96 -0
  123. package/src/components/VTextField/index.ts +1 -0
  124. package/src/components/VTextarea/VTextarea.scss +41 -0
  125. package/src/components/VTextarea/VTextarea.tsx +93 -0
  126. package/src/components/VTextarea/index.ts +1 -0
  127. package/src/components/VToolbar/.DS_Store +0 -0
  128. package/src/components/VToolbar/VToolbar.scss +26 -0
  129. package/src/components/VToolbar/VToolbar.tsx +44 -0
  130. package/src/components/VToolbar/VToolbarEdge.scss +27 -0
  131. package/src/components/VToolbar/VToolbarEdge.tsx +35 -0
  132. package/src/components/VToolbar/VToolbarMenu.scss +7 -0
  133. package/src/components/VToolbar/VToolbarMenu.tsx +26 -0
  134. package/src/components/VToolbar/VToolbarTitle.scss +22 -0
  135. package/src/components/VToolbar/VToolbarTitle.tsx +25 -0
  136. package/src/components/VToolbar/index.ts +4 -0
  137. package/src/components/VWysiwygEditor/.DS_Store +0 -0
  138. package/src/components/VWysiwygEditor/VWysiwygEditor.scss +60 -0
  139. package/src/components/VWysiwygEditor/VWysiwygEditor.tsx +293 -0
  140. package/src/components/VWysiwygEditor/index.ts +2 -0
  141. package/src/components/VWysiwygEditor/schemes.ts +65 -0
  142. package/src/components/VWysiwygEditor/tools/bullet-list.ts +18 -0
  143. package/src/components/VWysiwygEditor/tools/format-bold.ts +19 -0
  144. package/src/components/VWysiwygEditor/tools/format-italic.ts +18 -0
  145. package/src/components/VWysiwygEditor/tools/format-underline.ts +18 -0
  146. package/src/components/VWysiwygEditor/tools/history.ts +26 -0
  147. package/src/components/VWysiwygEditor/tools/index.ts +8 -0
  148. package/src/components/VWysiwygEditor/tools/link.ts +57 -0
  149. package/src/components/VWysiwygEditor/tools/ordered-list.ts +21 -0
  150. package/src/components/VWysiwygEditor/tools/text-color.ts +14 -0
  151. package/src/components/index.ts +32 -0
  152. package/src/components/kits.ts +1 -0
  153. package/src/components/loading.ts +1 -0
  154. package/src/composables/.DS_Store +0 -0
  155. package/src/composables/control.ts +118 -0
  156. package/src/composables/elevation.ts +34 -0
  157. package/src/composables/form-selector.scss +11 -0
  158. package/src/composables/form-selector.tsx +101 -0
  159. package/src/composables/index.ts +4 -0
  160. package/src/composables/vui.ts +9 -0
  161. package/src/index.ts +10 -0
  162. package/src/injections.ts +61 -0
  163. package/src/logger.ts +7 -0
  164. package/src/plugin.tsx +76 -0
  165. package/src/schemes/control.ts +7 -0
  166. package/src/schemes/elevation.ts +26 -0
  167. package/src/schemes/index.ts +2 -0
  168. package/src/service.tsx +242 -0
  169. package/src/styles/.DS_Store +0 -0
  170. package/src/styles/after-effects/display-flow.scss +346 -0
  171. package/src/styles/after-effects/spacing.scss +155 -0
  172. package/src/styles/after-effects/text.scss +90 -0
  173. package/src/styles/after-effects.scss +3 -0
  174. package/src/styles/base.scss +14 -0
  175. package/src/styles/control.scss +11 -0
  176. package/src/styles/core/functions.scss +62 -0
  177. package/src/styles/core/typo.scss +56 -0
  178. package/src/styles/core.scss +2 -0
  179. package/src/styles/elevation.scss +9 -0
  180. package/src/styles/group.scss +57 -0
  181. package/src/styles/index.scss +9 -0
  182. package/src/styles/transition.scss +11 -0
  183. package/src/styles/typo.scss +11 -0
  184. package/src/styles/variables.scss +320 -0
  185. package/src/styles/wysiwyg.scss +24 -0
  186. package/src/tool/.DS_Store +0 -0
  187. package/src/tool/index.ts +2 -0
  188. package/src/tool/vite-plugin.ts +281 -0
@@ -0,0 +1,57 @@
1
+ import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
2
+ import { Link, LinkOptions } from '@tiptap/extension-link';
3
+ import { validateIf, url } from '@fastkit/rules';
4
+
5
+ export const WysiwygLinkTool: WysiwygEditorToolFactory<LinkOptions> = (
6
+ vui,
7
+ options,
8
+ ) => {
9
+ const tool: WysiwygEditorTool = {
10
+ key: 'link',
11
+ // icon: ({ editor }) => {
12
+ // return vui.icon(editor.isActive('link') ? 'editorLinkOff' : 'editorLink');
13
+ // },
14
+ icon: vui.icon('editorLink'),
15
+ active: ({ editor }) => editor.isActive('link'),
16
+ // disabled: ({ editor }) => {
17
+ // const { $from, $to } = editor.view.state.selection;
18
+ // return $to.pos - $from.pos === 0;
19
+ // },
20
+ onClick: async ({ vui, editor }) => {
21
+ const { href = '' } = editor.getAttributes('link');
22
+ const result = await vui.prompt({
23
+ input: {
24
+ label: 'Link URL',
25
+ rules: [validateIf, url],
26
+ initialValue: href,
27
+ size: 'sm',
28
+ autofocus: true,
29
+ },
30
+ });
31
+
32
+ if (result === undefined || result === false) {
33
+ return;
34
+ }
35
+
36
+ const range = editor.chain().focus().extendMarkRange('link');
37
+
38
+ if (!result) {
39
+ range.unsetLink().run();
40
+ } else {
41
+ range
42
+ .setLink({
43
+ href: result,
44
+ })
45
+ .run();
46
+ }
47
+ },
48
+ floating: true,
49
+ extensions: [
50
+ Link.configure({
51
+ openOnClick: false,
52
+ ...options,
53
+ }),
54
+ ],
55
+ };
56
+ return tool;
57
+ };
@@ -0,0 +1,21 @@
1
+ import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
2
+ import {
3
+ OrderedList,
4
+ OrderedListOptions,
5
+ } from '@tiptap/extension-ordered-list';
6
+
7
+ export const WysiwygOrderedListTool: WysiwygEditorToolFactory<
8
+ OrderedListOptions
9
+ > = (vui, options) => {
10
+ const tool: WysiwygEditorTool = {
11
+ key: 'orderedList',
12
+ icon: vui.icon('editorformatListNumbered'),
13
+ active: ({ editor }) => editor.isActive('orderedList'),
14
+ onClick: ({ editor }) => {
15
+ editor.chain().focus().toggleOrderedList().run();
16
+ },
17
+ floating: true,
18
+ extensions: [OrderedList.configure(options)],
19
+ };
20
+ return tool;
21
+ };
@@ -0,0 +1,14 @@
1
+ import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
2
+
3
+ export const WysiwygTextColorTool: WysiwygEditorToolFactory = (vui) => {
4
+ const tool: WysiwygEditorTool = {
5
+ key: 'textColor',
6
+ icon: vui.icon('editorTextColor'),
7
+ // icon: (gen) => vui.icon('editorTextColor'),
8
+ onClick: (ctx) => {
9
+ ctx.vui.alert('ok');
10
+ },
11
+ floating: true,
12
+ };
13
+ return tool;
14
+ };
@@ -0,0 +1,32 @@
1
+ export * from './loading';
2
+ export * from './kits';
3
+ export * from './VGrid';
4
+ export * from './VPaper';
5
+ export * from './VCard';
6
+ export * from './VIcon';
7
+ export * from './VButton';
8
+ export * from './VPagination';
9
+ export * from './VListTile';
10
+ export * from './VDrawerLayout';
11
+ export * from './VHero';
12
+ // export * from './VAccordion';
13
+ export * from './VNavigation';
14
+ export * from './VCheckbox';
15
+ export * from './VCheckboxGroup';
16
+ export * from './VRadio';
17
+ export * from './VRadioGroup';
18
+ export * from './VSwitch';
19
+ export * from './VSwitchGroup';
20
+ export * from './VOption';
21
+ export * from './VOptionGroup';
22
+ export * from './VSelect';
23
+ export * from './VTextField';
24
+ export * from './VTextarea';
25
+ export * from './VWysiwygEditor';
26
+ export * from './VForm';
27
+ export * from './VTabs';
28
+ export * from './VBreadcrumbs';
29
+ export * from './VContentSwitcher';
30
+ export * from './VDataTable';
31
+ export * from './VApp';
32
+ export * from './VToolbar';
@@ -0,0 +1 @@
1
+ export { VDialog, VMenu, VSnackbar } from '@fastkit/vue-kit';
@@ -0,0 +1 @@
1
+ export * from '@fastkit/vue-loading';
Binary file
@@ -0,0 +1,118 @@
1
+ import {
2
+ PropType,
3
+ ExtractPropTypes,
4
+ computed,
5
+ ComputedRef,
6
+ provide,
7
+ inject,
8
+ } from 'vue';
9
+ import {
10
+ ControlSize,
11
+ CONTROL_SIZES,
12
+ ControlFieldVariant,
13
+ CONTROL_FIELD_VARIANTS,
14
+ } from '../schemes';
15
+ import { createPropsOptions } from '@fastkit/vue-kit';
16
+ import {
17
+ VuiControlInjectionKey,
18
+ VuiControlFieldInjectionKey,
19
+ } from '../injections';
20
+
21
+ export function createControlProps() {
22
+ return createPropsOptions({
23
+ size: {
24
+ type: String as PropType<ControlSize>,
25
+ validator: (value: any) => {
26
+ if (value == null) return true;
27
+ return CONTROL_SIZES.includes(value);
28
+ },
29
+ },
30
+ });
31
+ }
32
+
33
+ export type ControlProps = ExtractPropTypes<
34
+ ReturnType<typeof createControlProps>
35
+ >;
36
+
37
+ export interface ControlProvider {
38
+ parentControl: ControlProvider | null;
39
+ size: ComputedRef<ControlSize>;
40
+ classes: ComputedRef<any>;
41
+ }
42
+
43
+ export interface UseControlProviderOptions {
44
+ defaultSize?: ControlSize;
45
+ }
46
+
47
+ export function useControl(
48
+ props: ControlProps,
49
+ opts: UseControlProviderOptions = {},
50
+ ) {
51
+ const { defaultSize = 'md' } = opts;
52
+ const parentControl = inject(VuiControlInjectionKey, null);
53
+ const size = computed(() => {
54
+ const psize = props.size;
55
+ return psize
56
+ ? psize
57
+ : parentControl
58
+ ? parentControl.size.value
59
+ : defaultSize;
60
+ });
61
+ const classes = computed(() => {
62
+ return ['v-control', `v-control--${size.value}`];
63
+ });
64
+ const provider: ControlProvider = {
65
+ parentControl,
66
+ size,
67
+ classes,
68
+ };
69
+ provide(VuiControlInjectionKey, provider);
70
+ return provider;
71
+ }
72
+
73
+ export function createControlFieldProviderProps() {
74
+ return createPropsOptions({
75
+ variant: {
76
+ type: String as PropType<ControlFieldVariant>,
77
+ validator: (value: any) => {
78
+ if (value == null) return true;
79
+ return CONTROL_FIELD_VARIANTS.includes(value);
80
+ },
81
+ },
82
+ });
83
+ }
84
+
85
+ export type ControlFieldProviderProps = ExtractPropTypes<
86
+ ReturnType<typeof createControlFieldProviderProps>
87
+ >;
88
+
89
+ export interface ControlFieldProvider {
90
+ parentControlField: ControlFieldProvider | null;
91
+ variant: ComputedRef<ControlFieldVariant>;
92
+ }
93
+
94
+ export interface UseControlFieldProviderOptions {
95
+ defaultVariant?: ControlFieldVariant;
96
+ }
97
+
98
+ export function useControlField(
99
+ props: ControlFieldProviderProps,
100
+ opts: UseControlFieldProviderOptions = {},
101
+ ) {
102
+ const { defaultVariant = 'flat' } = opts;
103
+ const parentControlField = inject(VuiControlFieldInjectionKey, null);
104
+ const variant = computed(() => {
105
+ const pvariant = props.variant;
106
+ return pvariant
107
+ ? pvariant
108
+ : parentControlField
109
+ ? parentControlField.variant.value
110
+ : defaultVariant;
111
+ });
112
+ const provider: ControlFieldProvider = {
113
+ parentControlField,
114
+ variant,
115
+ };
116
+ provide(VuiControlFieldInjectionKey, provider);
117
+ return provider;
118
+ }
@@ -0,0 +1,34 @@
1
+ import { PropType, ExtractPropTypes, computed } from 'vue';
2
+ import { createPropsOptions } from '@fastkit/vue-utils';
3
+ import { VuiElevationValue } from '../schemes';
4
+
5
+ export function createElevationProps() {
6
+ return createPropsOptions({
7
+ elevation: Number as PropType<VuiElevationValue>,
8
+ });
9
+ }
10
+
11
+ export type ElevationProps = ExtractPropTypes<
12
+ ReturnType<typeof createElevationProps>
13
+ >;
14
+
15
+ export interface UseElevationOptions {
16
+ defaultValue?: VuiElevationValue;
17
+ }
18
+
19
+ export function useElevation(
20
+ props: ElevationProps,
21
+ opts: UseElevationOptions = {},
22
+ ) {
23
+ const elevationValue = computed(() =>
24
+ props.elevation == null ? opts.defaultValue : props.elevation,
25
+ );
26
+ const elevationClassName = computed(() => {
27
+ const v = elevationValue.value;
28
+ return v == null ? undefined : `elevation-${v}`;
29
+ });
30
+ return {
31
+ elevationValue,
32
+ elevationClassName,
33
+ };
34
+ }
@@ -0,0 +1,11 @@
1
+ .v-form-selector {
2
+ &__body {
3
+ display: block;
4
+ }
5
+
6
+ &--stacked &__body {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: flex-start;
10
+ }
11
+ }
@@ -0,0 +1,101 @@
1
+ import './form-selector.scss';
2
+ import { VNodeChild, defineComponent } from 'vue';
3
+ import {
4
+ defineSlotsProps,
5
+ TypedSlot,
6
+ createFormControlProps,
7
+ createFormSelectorSettings,
8
+ FormControlSlots,
9
+ useFormSelectorControl,
10
+ ResolvedFormSelectorItemData,
11
+ FormNodeControl,
12
+ renderSlotOrEmpty,
13
+ } from '@fastkit/vue-kit';
14
+ import { createControlProps, useControl } from './control';
15
+ import { VFormControl } from '../components/VFormControl';
16
+
17
+ export interface DefineFormSelectorComponentOptions {
18
+ name: string;
19
+ defaultMultiple?: boolean;
20
+ nodeType: string;
21
+ className: string;
22
+ itemRenderer: (ctx: {
23
+ attrs: ResolvedFormSelectorItemData & { key: string | number };
24
+ slots: {
25
+ default: TypedSlot<FormNodeControl>;
26
+ };
27
+ }) => VNodeChild;
28
+ }
29
+
30
+ export function defineFormSelectorComponent(
31
+ opts: DefineFormSelectorComponentOptions,
32
+ ) {
33
+ const { itemRenderer, defaultMultiple, nodeType, className } = opts;
34
+ const { props, emits } = createFormSelectorSettings({
35
+ defaultMultiple,
36
+ });
37
+
38
+ return defineComponent({
39
+ name: opts.name,
40
+ props: {
41
+ ...props,
42
+ ...createFormControlProps(),
43
+ ...createControlProps(),
44
+ stacked: {
45
+ type: Boolean,
46
+ default: true,
47
+ },
48
+ ...defineSlotsProps<FormControlSlots>(),
49
+ },
50
+ emits,
51
+ setup(props, ctx) {
52
+ const selectorControl = useFormSelectorControl(props, ctx, {
53
+ nodeType,
54
+ defaultMultiple,
55
+ });
56
+ const control = useControl(props);
57
+ return {
58
+ ...selectorControl.expose(),
59
+ ...control,
60
+ };
61
+ },
62
+ render() {
63
+ return (
64
+ <VFormControl
65
+ nodeControl={this.nodeControl}
66
+ focused={this.nodeControl.focused}
67
+ hiddenInfo={this.hiddenInfo}
68
+ class={[
69
+ 'v-form-selector',
70
+ className,
71
+ {
72
+ ...this.classes,
73
+ 'v-form-selector--stacked': this.stacked,
74
+ },
75
+ ]}
76
+ label={this.label}
77
+ hint={this.hint}
78
+ v-slots={{
79
+ ...this.$slots,
80
+ default: () => (
81
+ <div class="v-form-selector__body">
82
+ {this.propItems.map((attrs) =>
83
+ itemRenderer({
84
+ attrs: {
85
+ ...attrs,
86
+ key: attrs.value,
87
+ },
88
+ slots: {
89
+ default: () => attrs.label(this.selectorControl),
90
+ },
91
+ }),
92
+ )}
93
+ {renderSlotOrEmpty(this.$slots, 'default')}
94
+ </div>
95
+ ),
96
+ }}
97
+ />
98
+ );
99
+ },
100
+ });
101
+ }
@@ -0,0 +1,4 @@
1
+ export * from './control';
2
+ export * from './form-selector';
3
+ export * from './elevation';
4
+ export * from './vui';
@@ -0,0 +1,9 @@
1
+ import { ComputedRef } from 'vue';
2
+ export type { VuiService } from '../service';
3
+ import { ScopeName } from '@fastkit/color-scheme';
4
+
5
+ export interface VuiColorProvider {
6
+ primary: ComputedRef<ScopeName>;
7
+ error: ComputedRef<ScopeName>;
8
+ className: (type: 'primary' | 'error') => string;
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from '@fastkit/vue-kit';
2
+
3
+ import './styles/index.scss';
4
+
5
+ export * from './schemes';
6
+ export * from './composables';
7
+ export * from './components';
8
+ export * from './service';
9
+ export * from './plugin';
10
+ export * from './injections';
@@ -0,0 +1,61 @@
1
+ import { InjectionKey, inject, computed, provide } from 'vue';
2
+ import type { VuiService } from './service';
3
+ import type {
4
+ ControlProvider,
5
+ ControlFieldProvider,
6
+ VuiColorProvider,
7
+ } from './composables';
8
+
9
+ export const VuiInjectionKey: InjectionKey<VuiService> = Symbol();
10
+
11
+ export const VuiControlInjectionKey: InjectionKey<ControlProvider> = Symbol();
12
+
13
+ export const VuiControlFieldInjectionKey: InjectionKey<ControlFieldProvider> =
14
+ Symbol();
15
+
16
+ export const VuiColorProviderInjectionKey: InjectionKey<VuiColorProvider> =
17
+ Symbol();
18
+
19
+ export const VUI_TEXT_FIELD_SYMBOL = 'vui-text-field';
20
+ export const VUI_TEXTAREA_SYMBOL = 'vui-textarea';
21
+ export const VUI_WYSIWYG_EDITOR_SYMBOL = 'vui-wysiwyg-editor';
22
+ export const VUI_SELECT_SYMBOL = 'vui-select';
23
+ export const VUI_OPTION_SYMBOL = 'vui-option';
24
+ export const VUI_CHECKBOX_GROUP_SYMBOL = 'vui-checkbox-group';
25
+ export const VUI_CHECKBOX_SYMBOL = 'vui-checkbox';
26
+ export const VUI_RADIO_GROUP_SYMBOL = 'vui-radio-group';
27
+ export const VUI_RADIO_SYMBOL = 'vui-radio';
28
+ export const VUI_SWITCH_GROUP_SYMBOL = 'vui-switch-group';
29
+ export const VUI_SWITCH_SYMBOL = 'vui-switch';
30
+ export const VUI_FORM_SYMBOL = 'vui-form';
31
+
32
+ export function useVui() {
33
+ const vui = inject(VuiInjectionKey);
34
+ if (!vui) {
35
+ throw new Error('missing vui service');
36
+ }
37
+ return vui;
38
+ }
39
+
40
+ export function useVuiColorProvider(): VuiColorProvider {
41
+ const parent = inject(VuiColorProviderInjectionKey, null);
42
+ if (parent) {
43
+ return parent;
44
+ }
45
+
46
+ const vui = useVui();
47
+ const primary = computed(() => vui.setting('primaryScope'));
48
+ const error = computed(() => vui.setting('errorScope'));
49
+ const provider: VuiColorProvider = {
50
+ primary,
51
+ error,
52
+ className: (type) => {
53
+ const scope = provider[type].value;
54
+ return `${scope}-scope`;
55
+ },
56
+ };
57
+
58
+ provide(VuiColorProviderInjectionKey, provider);
59
+
60
+ return provider;
61
+ }
package/src/logger.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { TinyLogger, createTinyError } from '@fastkit/tiny-logger';
2
+
3
+ const name = 'vui';
4
+
5
+ export const logger = new TinyLogger(name);
6
+
7
+ export const VuiError = createTinyError(name);
package/src/plugin.tsx ADDED
@@ -0,0 +1,76 @@
1
+ import { App } from 'vue';
2
+ import { VuiService, VuiServiceOptions, VuiInjectionKey } from './service';
3
+ import {
4
+ installVueStackPlugin,
5
+ VueStackServiceOptions,
6
+ VueColorSchemePlugin,
7
+ } from '@fastkit/vue-kit';
8
+ import { VButton } from './components/VButton';
9
+
10
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
+ export interface VuiPluginStackOptions extends VueStackServiceOptions {}
12
+
13
+ export interface VuiPluginOptions extends VuiServiceOptions {
14
+ stack?: VuiPluginStackOptions;
15
+ }
16
+
17
+ declare module '@vue/runtime-core' {
18
+ export interface ComponentCustomProperties {
19
+ $vui: VuiService;
20
+ }
21
+ }
22
+
23
+ export class VuiPlugin {
24
+ static readonly installedApps = new Set<App>();
25
+
26
+ static install(app: App, opts: VuiPluginOptions) {
27
+ const { installedApps } = this;
28
+ if (installedApps.has(app)) return;
29
+ const unmountApp = app.unmount;
30
+ installedApps.add(app);
31
+
32
+ const { colorScheme, stack, uiSettings } = opts;
33
+
34
+ // ColorScheme
35
+ const vueColorSchemePlugin = new VueColorSchemePlugin(colorScheme);
36
+ app.use(vueColorSchemePlugin);
37
+
38
+ // Stack
39
+ installVueStackPlugin(app, {
40
+ actions: {
41
+ ok: ({ bindings }) => (
42
+ <VButton {...uiSettings.dialogOk} {...bindings}>
43
+ OK
44
+ </VButton>
45
+ ),
46
+ cancel: ({ bindings }) => (
47
+ <VButton {...uiSettings.dialogCancel} {...bindings}>
48
+ CANCEL
49
+ </VButton>
50
+ ),
51
+ close: ({ bindings }) => (
52
+ <VButton {...uiSettings.dialogClose} {...bindings}>
53
+ CLOSE
54
+ </VButton>
55
+ ),
56
+ ...(stack ? stack.actions : {}),
57
+ },
58
+ ...stack,
59
+ });
60
+
61
+ // Vui
62
+ const $vui = new VuiService(opts, app.config.globalProperties.$vstack);
63
+ app.provide(VuiInjectionKey, $vui);
64
+ app.config.globalProperties.$vui = $vui;
65
+
66
+ app.unmount = function () {
67
+ installedApps.delete(app);
68
+ delete app.config.globalProperties.$vui;
69
+ unmountApp();
70
+ };
71
+ }
72
+ }
73
+
74
+ export function installVuiPlugin(app: App, opts: VuiPluginOptions) {
75
+ return app.use(VuiPlugin, opts);
76
+ }
@@ -0,0 +1,7 @@
1
+ export const CONTROL_SIZES = ['sm', 'md', 'lg'] as const;
2
+
3
+ export type ControlSize = typeof CONTROL_SIZES[number];
4
+
5
+ export const CONTROL_FIELD_VARIANTS = ['outlined', 'filled', 'flat'] as const;
6
+
7
+ export type ControlFieldVariant = typeof CONTROL_FIELD_VARIANTS[number];
@@ -0,0 +1,26 @@
1
+ export type VuiElevationValue =
2
+ | 0
3
+ | 1
4
+ | 2
5
+ | 3
6
+ | 4
7
+ | 5
8
+ | 6
9
+ | 7
10
+ | 8
11
+ | 9
12
+ | 10
13
+ | 11
14
+ | 12
15
+ | 13
16
+ | 14
17
+ | 15
18
+ | 16
19
+ | 17
20
+ | 18
21
+ | 19
22
+ | 20
23
+ | 21
24
+ | 22
25
+ | 23
26
+ | 24;
@@ -0,0 +1,2 @@
1
+ export * from './control';
2
+ export * from './elevation';