@flux-ui/components 3.0.0-next.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 (261) hide show
  1. package/README.md +45 -0
  2. package/package.json +77 -0
  3. package/src/component/FluxAction.vue +27 -0
  4. package/src/component/FluxActionBar.vue +94 -0
  5. package/src/component/FluxActionPane.vue +40 -0
  6. package/src/component/FluxActions.vue +27 -0
  7. package/src/component/FluxAlert.vue +37 -0
  8. package/src/component/FluxAnimatedColors.vue +141 -0
  9. package/src/component/FluxAspectRatio.vue +21 -0
  10. package/src/component/FluxAutoGrid.vue +27 -0
  11. package/src/component/FluxAvatar.vue +119 -0
  12. package/src/component/FluxBadge.vue +84 -0
  13. package/src/component/FluxBadgeStack.vue +18 -0
  14. package/src/component/FluxBorderShine.vue +36 -0
  15. package/src/component/FluxBoxedIcon.vue +36 -0
  16. package/src/component/FluxButton.vue +110 -0
  17. package/src/component/FluxButtonGroup.vue +15 -0
  18. package/src/component/FluxButtonStack.vue +28 -0
  19. package/src/component/FluxCalendar.vue +254 -0
  20. package/src/component/FluxCalendarEvent.vue +41 -0
  21. package/src/component/FluxCheckbox.vue +60 -0
  22. package/src/component/FluxChip.vue +57 -0
  23. package/src/component/FluxClickablePane.vue +61 -0
  24. package/src/component/FluxColorPicker.vue +265 -0
  25. package/src/component/FluxColorSelect.vue +81 -0
  26. package/src/component/FluxComment.vue +71 -0
  27. package/src/component/FluxConfirm.vue +42 -0
  28. package/src/component/FluxContainer.vue +23 -0
  29. package/src/component/FluxDataTable.vue +96 -0
  30. package/src/component/FluxDatePicker.vue +353 -0
  31. package/src/component/FluxDestructiveButton.vue +28 -0
  32. package/src/component/FluxDisabled.vue +22 -0
  33. package/src/component/FluxDivider.vue +37 -0
  34. package/src/component/FluxDotPattern.vue +72 -0
  35. package/src/component/FluxDropZone.vue +202 -0
  36. package/src/component/FluxDynamicView.vue +16 -0
  37. package/src/component/FluxExpandable.vue +119 -0
  38. package/src/component/FluxExpandableGroup.vue +53 -0
  39. package/src/component/FluxFader.vue +64 -0
  40. package/src/component/FluxFaderItem.vue +15 -0
  41. package/src/component/FluxFilter.vue +133 -0
  42. package/src/component/FluxFilterDate.vue +58 -0
  43. package/src/component/FluxFilterDateRange.vue +59 -0
  44. package/src/component/FluxFilterOption.vue +49 -0
  45. package/src/component/FluxFilterOptionAsync.vue +103 -0
  46. package/src/component/FluxFilterOptions.vue +62 -0
  47. package/src/component/FluxFilterOptionsAsync.vue +113 -0
  48. package/src/component/FluxFilterRange.vue +91 -0
  49. package/src/component/FluxFlickeringGrid.vue +141 -0
  50. package/src/component/FluxFlyout.vue +205 -0
  51. package/src/component/FluxFocalPointEditor.vue +137 -0
  52. package/src/component/FluxFocalPointImage.vue +29 -0
  53. package/src/component/FluxForm.vue +35 -0
  54. package/src/component/FluxFormColumn.vue +15 -0
  55. package/src/component/FluxFormDateInput.vue +92 -0
  56. package/src/component/FluxFormDateRangeInput.vue +87 -0
  57. package/src/component/FluxFormDateTimeInput.vue +120 -0
  58. package/src/component/FluxFormField.vue +98 -0
  59. package/src/component/FluxFormFieldAddition.vue +37 -0
  60. package/src/component/FluxFormInput.vue +223 -0
  61. package/src/component/FluxFormInputAddition.vue +31 -0
  62. package/src/component/FluxFormInputGroup.vue +25 -0
  63. package/src/component/FluxFormPinInput.vue +135 -0
  64. package/src/component/FluxFormRangeSlider.vue +179 -0
  65. package/src/component/FluxFormRow.vue +15 -0
  66. package/src/component/FluxFormSection.vue +23 -0
  67. package/src/component/FluxFormSelect.vue +59 -0
  68. package/src/component/FluxFormSelectAsync.vue +118 -0
  69. package/src/component/FluxFormSlider.vue +123 -0
  70. package/src/component/FluxFormTextArea.vue +53 -0
  71. package/src/component/FluxFormTimeZonePicker.vue +713 -0
  72. package/src/component/FluxGallery.vue +99 -0
  73. package/src/component/FluxGalleryItem.vue +49 -0
  74. package/src/component/FluxGrid.vue +28 -0
  75. package/src/component/FluxGridColumn.vue +31 -0
  76. package/src/component/FluxGridPattern.vue +60 -0
  77. package/src/component/FluxIcon.vue +79 -0
  78. package/src/component/FluxInfo.vue +28 -0
  79. package/src/component/FluxInfoStack.vue +17 -0
  80. package/src/component/FluxLegend.vue +27 -0
  81. package/src/component/FluxLink.vue +35 -0
  82. package/src/component/FluxMenu.vue +31 -0
  83. package/src/component/FluxMenuGroup.vue +21 -0
  84. package/src/component/FluxMenuItem.vue +84 -0
  85. package/src/component/FluxMenuOptions.vue +38 -0
  86. package/src/component/FluxMenuSubHeader.vue +33 -0
  87. package/src/component/FluxMenuTitle.vue +17 -0
  88. package/src/component/FluxNotice.vue +79 -0
  89. package/src/component/FluxNoticeStack.vue +17 -0
  90. package/src/component/FluxOverlay.vue +31 -0
  91. package/src/component/FluxPagination.vue +148 -0
  92. package/src/component/FluxPaginationBar.vue +81 -0
  93. package/src/component/FluxPane.vue +45 -0
  94. package/src/component/FluxPaneBody.vue +15 -0
  95. package/src/component/FluxPaneDeck.vue +24 -0
  96. package/src/component/FluxPaneFooter.vue +15 -0
  97. package/src/component/FluxPaneGroup.vue +15 -0
  98. package/src/component/FluxPaneHeader.vue +44 -0
  99. package/src/component/FluxPaneIllustration.vue +68 -0
  100. package/src/component/FluxPaneMedia.vue +31 -0
  101. package/src/component/FluxPercentageBar.vue +45 -0
  102. package/src/component/FluxPersona.vue +48 -0
  103. package/src/component/FluxPlaceholder.vue +56 -0
  104. package/src/component/FluxPressable.vue +77 -0
  105. package/src/component/FluxPrimaryButton.vue +28 -0
  106. package/src/component/FluxProgressBar.vue +75 -0
  107. package/src/component/FluxPrompt.vue +77 -0
  108. package/src/component/FluxPublishButton.vue +59 -0
  109. package/src/component/FluxQuantitySelector.vue +109 -0
  110. package/src/component/FluxRemove.vue +34 -0
  111. package/src/component/FluxRoot.vue +60 -0
  112. package/src/component/FluxSecondaryButton.vue +28 -0
  113. package/src/component/FluxSegmentedControl.vue +77 -0
  114. package/src/component/FluxSegmentedView.vue +15 -0
  115. package/src/component/FluxSeparator.vue +19 -0
  116. package/src/component/FluxSlideOver.vue +25 -0
  117. package/src/component/FluxSnackbar.vue +154 -0
  118. package/src/component/FluxSnackbarProvider.vue +34 -0
  119. package/src/component/FluxSpacer.vue +9 -0
  120. package/src/component/FluxSpacing.vue +32 -0
  121. package/src/component/FluxSpinner.vue +48 -0
  122. package/src/component/FluxSplitButton.vue +61 -0
  123. package/src/component/FluxStack.vue +40 -0
  124. package/src/component/FluxStatistic.vue +68 -0
  125. package/src/component/FluxStepper.vue +69 -0
  126. package/src/component/FluxStepperStep.vue +15 -0
  127. package/src/component/FluxStepperSteps.vue +62 -0
  128. package/src/component/FluxTab.vue +23 -0
  129. package/src/component/FluxTabBar.vue +87 -0
  130. package/src/component/FluxTabBarItem.vue +104 -0
  131. package/src/component/FluxTable.vue +68 -0
  132. package/src/component/FluxTableActions.vue +16 -0
  133. package/src/component/FluxTableCell.vue +47 -0
  134. package/src/component/FluxTableHeader.vue +111 -0
  135. package/src/component/FluxTableRow.vue +15 -0
  136. package/src/component/FluxTabs.vue +91 -0
  137. package/src/component/FluxTag.vue +85 -0
  138. package/src/component/FluxTagStack.vue +18 -0
  139. package/src/component/FluxTicks.vue +44 -0
  140. package/src/component/FluxTimeline.vue +17 -0
  141. package/src/component/FluxTimelineItem.vue +73 -0
  142. package/src/component/FluxToggle.vue +64 -0
  143. package/src/component/FluxToolbar.vue +32 -0
  144. package/src/component/FluxToolbarGroup.vue +18 -0
  145. package/src/component/FluxTooltip.vue +56 -0
  146. package/src/component/FluxTooltipProvider.vue +176 -0
  147. package/src/component/FluxWindow.vue +47 -0
  148. package/src/component/index.ts +142 -0
  149. package/src/component/primitive/Anchor.vue +17 -0
  150. package/src/component/primitive/AnchorPopup.vue +194 -0
  151. package/src/component/primitive/CoordinatePicker.vue +155 -0
  152. package/src/component/primitive/CoordinatePickerThumb.vue +71 -0
  153. package/src/component/primitive/FilterItem.vue +44 -0
  154. package/src/component/primitive/FilterMenuRenderer.ts +233 -0
  155. package/src/component/primitive/FilterOptionBase.vue +67 -0
  156. package/src/component/primitive/SelectBase.vue +340 -0
  157. package/src/component/primitive/SliderBase.vue +89 -0
  158. package/src/component/primitive/SliderThumb.vue +64 -0
  159. package/src/component/primitive/SliderTrack.vue +22 -0
  160. package/src/component/primitive/VNodeRenderer.ts +11 -0
  161. package/src/component/primitive/index.ts +10 -0
  162. package/src/composable/index.ts +9 -0
  163. package/src/composable/private/index.ts +3 -0
  164. package/src/composable/private/useFormSelect.ts +66 -0
  165. package/src/composable/private/useLoaded.ts +21 -0
  166. package/src/composable/private/useTranslate.ts +35 -0
  167. package/src/composable/useBreakpoints.ts +54 -0
  168. package/src/composable/useDisabled.ts +9 -0
  169. package/src/composable/useDisabledInjection.ts +6 -0
  170. package/src/composable/useExpandableGroupInjection.ts +10 -0
  171. package/src/composable/useFilterInjection.ts +22 -0
  172. package/src/composable/useFlyoutInjection.ts +10 -0
  173. package/src/composable/useFormFieldInjection.ts +8 -0
  174. package/src/composable/useTableInjection.ts +11 -0
  175. package/src/css/base.scss +33 -0
  176. package/src/css/component/Action.module.scss +107 -0
  177. package/src/css/component/Avatar.module.scss +177 -0
  178. package/src/css/component/Badge.module.scss +189 -0
  179. package/src/css/component/Button.module.scss +293 -0
  180. package/src/css/component/Calendar.module.scss +171 -0
  181. package/src/css/component/Chip.module.scss +58 -0
  182. package/src/css/component/Color.module.scss +184 -0
  183. package/src/css/component/Comment.module.scss +123 -0
  184. package/src/css/component/DatePicker.module.scss +193 -0
  185. package/src/css/component/Divider.module.scss +79 -0
  186. package/src/css/component/DropZone.module.scss +99 -0
  187. package/src/css/component/Expandable.module.scss +112 -0
  188. package/src/css/component/Fader.module.scss +38 -0
  189. package/src/css/component/Filter.module.scss +80 -0
  190. package/src/css/component/Flyout.module.scss +63 -0
  191. package/src/css/component/FocalPoint.module.scss +84 -0
  192. package/src/css/component/Form.module.scss +812 -0
  193. package/src/css/component/Gallery.module.scss +64 -0
  194. package/src/css/component/Grid.module.scss +24 -0
  195. package/src/css/component/Icon.module.scss +104 -0
  196. package/src/css/component/Info.module.scss +15 -0
  197. package/src/css/component/Layout.module.scss +63 -0
  198. package/src/css/component/Legend.module.scss +32 -0
  199. package/src/css/component/Menu.module.scss +314 -0
  200. package/src/css/component/Notice.module.scss +279 -0
  201. package/src/css/component/Overlay.module.scss +149 -0
  202. package/src/css/component/Pagination.module.scss +59 -0
  203. package/src/css/component/Pane.module.scss +218 -0
  204. package/src/css/component/PercentageBar.module.scss +31 -0
  205. package/src/css/component/Placeholder.module.scss +72 -0
  206. package/src/css/component/Progress.module.scss +84 -0
  207. package/src/css/component/Remove.module.scss +29 -0
  208. package/src/css/component/Root.module.scss +8 -0
  209. package/src/css/component/SegmentedControl.module.scss +82 -0
  210. package/src/css/component/Snackbar.module.scss +227 -0
  211. package/src/css/component/Spinner.module.scss +36 -0
  212. package/src/css/component/Statistic.module.scss +118 -0
  213. package/src/css/component/Stepper.module.scss +103 -0
  214. package/src/css/component/Tab.module.scss +162 -0
  215. package/src/css/component/Table.module.scss +164 -0
  216. package/src/css/component/Timeline.module.scss +173 -0
  217. package/src/css/component/Toolbar.module.scss +82 -0
  218. package/src/css/component/Tooltip.module.scss +62 -0
  219. package/src/css/component/Transition.module.scss +142 -0
  220. package/src/css/component/Visual.module.scss +70 -0
  221. package/src/css/component/base/Button.module.scss +87 -0
  222. package/src/css/component/base/Effect.module.scss +139 -0
  223. package/src/css/component/base/Grid.module.scss +8 -0
  224. package/src/css/component/base/Pane.module.scss +54 -0
  225. package/src/css/component/primitive/CoordinatePicker.module.scss +24 -0
  226. package/src/css/component/primitive/Slider.module.scss +116 -0
  227. package/src/css/index.scss +5 -0
  228. package/src/css/layers.scss +1 -0
  229. package/src/css/mixin/breakpoints.scss +112 -0
  230. package/src/css/mixin/focus-ring.scss +56 -0
  231. package/src/css/mixin/hover.scss +7 -0
  232. package/src/css/mixin/index.scss +3 -0
  233. package/src/css/reset.scss +169 -0
  234. package/src/css/typography.scss +87 -0
  235. package/src/css/variables.scss +214 -0
  236. package/src/data/di.ts +42 -0
  237. package/src/data/filter.ts +9 -0
  238. package/src/data/helper.ts +9 -0
  239. package/src/data/i18n.ts +55 -0
  240. package/src/data/iconRegistry.ts +21 -0
  241. package/src/data/index.ts +8 -0
  242. package/src/data/inputMask.ts +34 -0
  243. package/src/data/store.ts +233 -0
  244. package/src/image/avatar-mask.svg +3 -0
  245. package/src/index.ts +25 -0
  246. package/src/transition/FluxAutoHeightTransition.vue +59 -0
  247. package/src/transition/FluxAutoWidthTransition.vue +59 -0
  248. package/src/transition/FluxBreakthroughTransition.vue +23 -0
  249. package/src/transition/FluxFadeTransition.vue +24 -0
  250. package/src/transition/FluxOverlayTransition.vue +22 -0
  251. package/src/transition/FluxRouteTransition.vue +23 -0
  252. package/src/transition/FluxSlideOverTransition.vue +22 -0
  253. package/src/transition/FluxTooltipTransition.vue +22 -0
  254. package/src/transition/FluxVerticalWindowTransition.vue +23 -0
  255. package/src/transition/FluxWindowTransition.vue +23 -0
  256. package/src/transition/index.ts +10 -0
  257. package/src/util/createDialogRenderer.ts +64 -0
  258. package/src/util/createLabelForDateRange.ts +61 -0
  259. package/src/util/index.ts +2 -0
  260. package/src/vite.d.ts +13 -0
  261. package/tsconfig.json +45 -0
@@ -0,0 +1,179 @@
1
+ <template>
2
+ <SliderBase
3
+ :disabled="disabled"
4
+ :is-dragging="isDraggingLower || isDraggingUpper"
5
+ :is-ticks-visible="isTicksVisible"
6
+ :max="max"
7
+ :min="min"
8
+ :step="step"
9
+ @dragging="onDragging"
10
+ @update="onUpdate">
11
+ <SliderTrack
12
+ :percentage-lower="percentageLower"
13
+ :percentage-upper="percentageUpper">
14
+ <SliderThumb
15
+ ref="lowerThumb"
16
+ :disabled="disabled"
17
+ :is-dragging="isDraggingLower"
18
+ :position="percentageLower"
19
+ @grab="!disabled && (isDraggingLower = true)"
20
+ @decrement="onDecrement('lower')"
21
+ @increment="onIncrement('lower')"/>
22
+
23
+ <SliderThumb
24
+ ref="upperThumb"
25
+ :disabled="disabled"
26
+ :is-dragging="isDraggingUpper"
27
+ :position="percentageUpper"
28
+ @grab="!disabled && (isDraggingUpper = true)"
29
+ @decrement="onDecrement('upper')"
30
+ @increment="onIncrement('upper')"/>
31
+ </SliderTrack>
32
+ </SliderBase>
33
+ </template>
34
+
35
+ <script
36
+ lang="ts"
37
+ setup>
38
+ import { clampWithStepPrecision, countDecimals, formatNumber } from '@basmilius/utils';
39
+ import { computed, ref, toRef, unref, useTemplateRef, watch } from 'vue';
40
+ import { useDisabled } from '$flux/composable';
41
+ import { addTooltip, removeTooltip, updateTooltip } from '$flux/data';
42
+ import { SliderBase, SliderThumb, SliderTrack } from './primitive';
43
+
44
+ const modelValue = defineModel<[number, number]>({
45
+ required: true
46
+ });
47
+
48
+ const {
49
+ formatter = formatNumber,
50
+ disabled: componentDisabled,
51
+ isTooltipDisabled,
52
+ max = 100,
53
+ min = 0,
54
+ step = 1
55
+ } = defineProps<{
56
+ formatter?(value: number, decimals?: number): string;
57
+
58
+ readonly disabled?: boolean;
59
+ readonly isTicksVisible?: boolean;
60
+ readonly isTooltipDisabled?: boolean;
61
+ readonly max?: number;
62
+ readonly min?: number;
63
+ readonly step?: number;
64
+ }>();
65
+
66
+ const disabled = useDisabled(toRef(() => componentDisabled));
67
+ const lowerThumbRef = useTemplateRef('lowerThumb');
68
+ const upperThumbRef = useTemplateRef('upperThumb');
69
+
70
+ const isDraggingLower = ref(false);
71
+ const isDraggingUpper = ref(false);
72
+ const percentageLower = ref(0);
73
+ const percentageUpper = ref(0);
74
+ const lowerValue = ref(0);
75
+ const upperValue = ref(0);
76
+ const tooltipId = ref<number | null>(null);
77
+
78
+ const tooltipContent = computed(() => formatter(modelValue.value[isDraggingLower.value ? 0 : 1], countDecimals(step)));
79
+
80
+ function onDragging(is: boolean): void {
81
+ if (is) {
82
+ return;
83
+ }
84
+
85
+ isDraggingLower.value = is;
86
+ isDraggingUpper.value = is;
87
+ }
88
+
89
+ function onUpdate(value: number): void {
90
+ let lower = clampWithStepPrecision(lowerValue.value, min, max, step);
91
+ let upper = clampWithStepPrecision(upperValue.value, min, max, step);
92
+
93
+ if (isDraggingLower.value) {
94
+ lower = clampWithStepPrecision(value, min, max, step);
95
+ }
96
+
97
+ if (isDraggingUpper.value) {
98
+ upper = clampWithStepPrecision(value, min, max, step);
99
+ }
100
+
101
+ if (lower >= upper) {
102
+ return;
103
+ }
104
+
105
+ if (tooltipId.value) {
106
+ updateTooltip(tooltipId.value, {
107
+ content: unref(tooltipContent),
108
+ origin: unref(isDraggingLower.value ? lowerThumbRef : upperThumbRef)?.$el
109
+ });
110
+ }
111
+
112
+ lowerValue.value = (lower - min) / (max - min);
113
+ upperValue.value = (upper - min) / (max - min);
114
+ }
115
+
116
+ function onDecrement(which: 'lower' | 'upper'): void {
117
+ let lower = clampWithStepPrecision(lowerValue.value, min, max, step);
118
+ let upper = clampWithStepPrecision(upperValue.value, min, max, step);
119
+
120
+ if (which === 'lower') {
121
+ lower = Math.max(min, lower - step);
122
+ } else {
123
+ upper = Math.max(min, upper - step);
124
+ }
125
+
126
+ if (lower >= upper) {
127
+ return;
128
+ }
129
+
130
+ modelValue.value = [lower, upper];
131
+ }
132
+
133
+ function onIncrement(which: 'lower' | 'upper'): void {
134
+ let lower = clampWithStepPrecision(lowerValue.value, min, max, step);
135
+ let upper = clampWithStepPrecision(upperValue.value, min, max, step);
136
+
137
+ if (which === 'lower') {
138
+ lower = Math.min(max, lower + step);
139
+ } else {
140
+ upper = Math.min(max, upper + step);
141
+ }
142
+
143
+ if (lower >= upper) {
144
+ return;
145
+ }
146
+
147
+ modelValue.value = [lower, upper];
148
+ }
149
+
150
+ watch(modelValue, modelValue => {
151
+ lowerValue.value = (modelValue[0] - min) / (max - min);
152
+ upperValue.value = (modelValue[1] - min) / (max - min);
153
+ }, {immediate: true});
154
+
155
+ watch(([() => max, () => min, () => step, lowerValue, upperValue]), () => {
156
+ const lower = clampWithStepPrecision(unref(lowerValue), min, max, step);
157
+ const upper = clampWithStepPrecision(unref(upperValue), min, max, step);
158
+
159
+ percentageLower.value = (lower - min) / (max - min);
160
+ percentageUpper.value = (upper - min) / (max - min);
161
+
162
+ modelValue.value = [lower, upper];
163
+ }, {immediate: true});
164
+
165
+ watch(([isDraggingLower, isDraggingUpper]), ([isDraggingLower, isDraggingUpper]) => {
166
+ const is = isDraggingLower || isDraggingUpper;
167
+
168
+ if (is && !tooltipId.value && !isTooltipDisabled) {
169
+ tooltipId.value = addTooltip({
170
+ content: unref(tooltipContent),
171
+ direction: 'vertical',
172
+ origin: unref(isDraggingLower ? lowerThumbRef : upperThumbRef)?.$el
173
+ });
174
+ } else if (!is && tooltipId.value) {
175
+ removeTooltip(tooltipId.value);
176
+ tooltipId.value = null;
177
+ }
178
+ });
179
+ </script>
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <div :class="$style.formRow">
3
+ <slot/>
4
+ </div>
5
+ </template>
6
+
7
+ <script
8
+ lang="ts"
9
+ setup>
10
+ import $style from '$flux/css/component/Form.module.scss';
11
+
12
+ defineSlots<{
13
+ default(): any;
14
+ }>();
15
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div :class="$style.formSection">
3
+ <div :class="$style.formSectionTitle">
4
+ {{ title }}
5
+ </div>
6
+
7
+ <slot/>
8
+ </div>
9
+ </template>
10
+
11
+ <script
12
+ lang="ts"
13
+ setup>
14
+ import $style from '$flux/css/component/Form.module.scss';
15
+
16
+ defineProps<{
17
+ readonly title: string;
18
+ }>();
19
+
20
+ defineSlots<{
21
+ default(): any;
22
+ }>();
23
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <SelectBase
3
+ v-model:searchQuery="modelSearch"
4
+ :disabled="disabled"
5
+ :is-multiple="isMultiple"
6
+ :is-searchable="isSearchable"
7
+ :options="groups"
8
+ :placeholder="placeholder"
9
+ :selected="selected"
10
+ @deselect="onDeselect"
11
+ @select="onSelect"/>
12
+ </template>
13
+
14
+ <script
15
+ lang="ts"
16
+ setup>
17
+ import type { FluxFormSelectEntry, FluxFormSelectValue } from '@flux-ui/types';
18
+ import { toRef, unref } from 'vue';
19
+ import { SelectBase } from '$flux/component/primitive';
20
+ import { useDisabled } from '$flux/composable';
21
+ import { useFormSelect } from '$flux/composable/private';
22
+
23
+ const modelSearch = defineModel<string>('searchQuery', {
24
+ default: ''
25
+ });
26
+
27
+ const modelValue = defineModel<FluxFormSelectValue>({
28
+ required: true
29
+ });
30
+
31
+ const {
32
+ disabled: componentDisabled,
33
+ isMultiple,
34
+ options
35
+ } = defineProps<{
36
+ readonly disabled?: boolean;
37
+ readonly isMultiple?: boolean;
38
+ readonly placeholder?: string;
39
+ readonly isSearchable?: boolean;
40
+ readonly options: FluxFormSelectEntry[];
41
+ }>();
42
+
43
+ const disabled = useDisabled(toRef(() => componentDisabled));
44
+ const {groups, selected, values} = useFormSelect(modelValue, isMultiple, options, modelSearch);
45
+
46
+ function onDeselect(id: string | number | null): void {
47
+ if (unref(isMultiple)) {
48
+ modelValue.value = unref(values).filter(v => v !== id);
49
+ }
50
+ }
51
+
52
+ function onSelect(id: string | number | null): void {
53
+ if (unref(isMultiple)) {
54
+ modelValue.value = [...unref(values), id];
55
+ } else {
56
+ modelValue.value = id;
57
+ }
58
+ }
59
+ </script>
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <SelectBase
3
+ v-model:search-query="modelSearch"
4
+ :disabled="disabled"
5
+ :is-loading="isLoading"
6
+ :is-multiple="isMultiple"
7
+ is-searchable
8
+ :options="groups"
9
+ :placeholder="placeholder"
10
+ :selected="selected"
11
+ @deselect="onDeselect"
12
+ @open="onOpen()"
13
+ @select="onSelect"/>
14
+ </template>
15
+
16
+ <script
17
+ lang="ts"
18
+ setup>
19
+ import { useDebouncedRef } from '@flux-ui/internals';
20
+ import type { FluxFormSelectEntry, FluxFormSelectValue, FluxFormSelectValueSingle } from '@flux-ui/types';
21
+ import { computed, ref, toRef, unref, watch } from 'vue';
22
+ import { SelectBase } from '$flux/component/primitive';
23
+ import { useDisabled } from '$flux/composable';
24
+ import { useFormSelect, useLoaded } from '$flux/composable/private';
25
+ import { isFluxFormSelectOption } from '$flux/data';
26
+
27
+ const modelSearch = defineModel<string>('searchQuery', {
28
+ default: ''
29
+ });
30
+
31
+ const modelValue = defineModel<FluxFormSelectValue>({
32
+ required: true
33
+ });
34
+
35
+ const {
36
+ fetchOptions: fetchOptionsProp,
37
+ fetchRelevant: fetchRelevantProp,
38
+ fetchSearch: fetchSearchProp,
39
+ disabled: componentDisabled,
40
+ isMultiple
41
+ } = defineProps<{
42
+ fetchOptions(ids: FluxFormSelectValueSingle[]): Promise<FluxFormSelectEntry[]>;
43
+ fetchRelevant(): Promise<FluxFormSelectEntry[]>;
44
+ fetchSearch(searchQuery: string): Promise<FluxFormSelectEntry[]>;
45
+
46
+ readonly disabled?: boolean;
47
+ readonly isMultiple?: boolean;
48
+ readonly placeholder?: string;
49
+ }>();
50
+
51
+ const disabled = useDisabled(toRef(() => componentDisabled));
52
+ const selectedOptions = ref<FluxFormSelectEntry[]>([]);
53
+ const visibleOptions = ref<FluxFormSelectEntry[]>([]);
54
+
55
+ const options = computed(() => {
56
+ const options: FluxFormSelectEntry[] = [];
57
+ const search = unref(modelSearch);
58
+ const selected = unref(selectedOptions);
59
+ const visible = unref(visibleOptions);
60
+
61
+ visible.forEach(vo => options.push(vo));
62
+
63
+ selected.forEach(so => {
64
+ if (isFluxFormSelectOption(so) && visible.find(vo => isFluxFormSelectOption(vo) && vo.value === so.value)) {
65
+ return;
66
+ }
67
+
68
+ if (isFluxFormSelectOption(so) && !so.label.toLowerCase().includes(search.toLowerCase())) {
69
+ return;
70
+ }
71
+
72
+ options.push(so);
73
+ });
74
+
75
+ return options;
76
+ });
77
+
78
+ const {groups, selected, values} = useFormSelect(modelValue, isMultiple, options);
79
+ const {isLoading, loaded} = useLoaded();
80
+ const debouncedModelSearch = useDebouncedRef(modelSearch, 300);
81
+ const fetchOptions = computed(() => loaded(fetchOptionsProp));
82
+ const fetchRelevant = computed(() => loaded(fetchRelevantProp));
83
+ const fetchSearch = computed(() => loaded(fetchSearchProp));
84
+
85
+ function onDeselect(id: string | number | null): void {
86
+ if (isMultiple) {
87
+ modelValue.value = unref(values).filter(v => v !== id);
88
+ }
89
+ }
90
+
91
+ async function onOpen(): Promise<void> {
92
+ visibleOptions.value = await unref(fetchRelevant)();
93
+ }
94
+
95
+ function onSelect(id: string | number | null): void {
96
+ if (isMultiple) {
97
+ modelValue.value = [...unref(values), id];
98
+ } else {
99
+ modelValue.value = id;
100
+ }
101
+ }
102
+
103
+ watch(values, async values => {
104
+ if (values.length === 0) {
105
+ return;
106
+ }
107
+
108
+ selectedOptions.value = await unref(fetchOptions)(values);
109
+ }, {immediate: true});
110
+
111
+ watch(debouncedModelSearch, async searchQuery => {
112
+ if (searchQuery.length > 0) {
113
+ visibleOptions.value = await unref(fetchSearch)(searchQuery);
114
+ } else {
115
+ visibleOptions.value = await unref(fetchRelevant)();
116
+ }
117
+ });
118
+ </script>
@@ -0,0 +1,123 @@
1
+ <template>
2
+ <SliderBase
3
+ :disabled="disabled"
4
+ :is-dragging="isDragging"
5
+ :is-ticks-visible="isTicksVisible"
6
+ :max="max"
7
+ :min="min"
8
+ :step="step"
9
+ @dragging="onDragging"
10
+ @update="onUpdate">
11
+ <SliderTrack
12
+ :percentage-lower="0"
13
+ :percentage-upper="percentage">
14
+ <SliderThumb
15
+ ref="thumb"
16
+ :disabled="disabled"
17
+ :is-dragging="isDragging"
18
+ :position="percentage"
19
+ @decrement="onDecrement"
20
+ @increment="onIncrement"/>
21
+ </SliderTrack>
22
+ </SliderBase>
23
+ </template>
24
+
25
+ <script
26
+ lang="ts"
27
+ setup>
28
+ import { clampWithStepPrecision, countDecimals, formatNumber } from '@basmilius/utils';
29
+ import { computed, ref, toRef, unref, useTemplateRef, watch, watchEffect } from 'vue';
30
+ import { useDisabled } from '$flux/composable';
31
+ import { addTooltip, removeTooltip, updateTooltip } from '$flux/data';
32
+ import { SliderBase, SliderThumb, SliderTrack } from './primitive';
33
+
34
+ const modelValue = defineModel<number>({
35
+ required: true
36
+ });
37
+
38
+ const {
39
+ formatter = formatNumber,
40
+ disabled: componentDisabled = false,
41
+ isTooltipDisabled,
42
+ max = 100,
43
+ min = 0,
44
+ step = 1
45
+ } = defineProps<{
46
+ formatter?(value: number, decimals?: number): string;
47
+
48
+ readonly disabled?: boolean;
49
+ readonly isTicksVisible?: boolean;
50
+ readonly isTooltipDisabled?: boolean;
51
+ readonly max?: number;
52
+ readonly min?: number;
53
+ readonly step?: number;
54
+ }>();
55
+
56
+ const disabled = useDisabled(toRef(() => componentDisabled));
57
+ const thumbRef = useTemplateRef('thumb');
58
+
59
+ const isDragging = ref(false);
60
+ const localValue = ref(0);
61
+ const percentage = ref(0);
62
+ const tooltipId = ref<number | null>(null);
63
+
64
+ const tooltipContent = computed(() => formatter(modelValue.value, countDecimals(step)));
65
+
66
+ function onDragging(is: boolean): void {
67
+ isDragging.value = is;
68
+
69
+ if (is && !tooltipId.value && !isTooltipDisabled) {
70
+ tooltipId.value = addTooltip({
71
+ content: unref(tooltipContent),
72
+ direction: 'vertical',
73
+ origin: unref(thumbRef)?.$el
74
+ });
75
+ } else if (!is && tooltipId.value) {
76
+ removeTooltip(tooltipId.value);
77
+ tooltipId.value = null;
78
+ }
79
+ }
80
+
81
+ function onUpdate(value: number): void {
82
+ localValue.value = value;
83
+
84
+ requestAnimationFrame(() => {
85
+ if (!tooltipId.value) {
86
+ return;
87
+ }
88
+
89
+ updateTooltip(tooltipId.value, {
90
+ content: formatter(modelValue.value, countDecimals(step)),
91
+ origin: unref(thumbRef)?.$el
92
+ });
93
+ });
94
+ }
95
+
96
+ function onDecrement(): void {
97
+ if (unref(disabled)) {
98
+ return;
99
+ }
100
+
101
+ const value = clampWithStepPrecision(localValue.value, min, max, step);
102
+ modelValue.value = Math.max(min, value - step);
103
+ }
104
+
105
+ function onIncrement(): void {
106
+ if (unref(disabled)) {
107
+ return;
108
+ }
109
+
110
+ const value = clampWithStepPrecision(localValue.value, min, max, step);
111
+ modelValue.value = Math.min(max, value + step);
112
+ }
113
+
114
+ watchEffect(() => {
115
+ localValue.value = (unref(modelValue) - min) / (max - min);
116
+ });
117
+
118
+ watch(([() => max, () => min, localValue, () => step]), () => {
119
+ const value = clampWithStepPrecision(unref(localValue), min, max, step);
120
+ modelValue.value = value;
121
+ percentage.value = (value - min) / (max - min);
122
+ }, {immediate: true});
123
+ </script>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <textarea
3
+ v-model="modelValue"
4
+ ref="input"
5
+ :class="disabled ? $style.formTextAreaDisabled : $style.formTextAreaEnabled"
6
+ :id="id"
7
+ :autocomplete="autoComplete"
8
+ :autofocus="autoFocus"
9
+ :disabled="disabled"
10
+ :maxlength="maxLength"
11
+ :placeholder="placeholder"
12
+ :style="{
13
+ '--rows': rows
14
+ }"
15
+ :aria-disabled="disabled ? true : undefined"
16
+ @blur="emit('blur')"
17
+ @focus="emit('focus')"/>
18
+ </template>
19
+
20
+ <script
21
+ lang="ts"
22
+ setup>
23
+ import type { FluxAutoCompleteType } from '@flux-ui/types';
24
+ import { toRef } from 'vue';
25
+ import { useDisabled, useFormFieldInjection } from '$flux/composable';
26
+ import $style from '$flux/css/component/Form.module.scss';
27
+
28
+ const emit = defineEmits<{
29
+ blur: [];
30
+ focus: [];
31
+ }>();
32
+
33
+ const modelValue = defineModel<string>({
34
+ default: ''
35
+ });
36
+
37
+ const {
38
+ autoFocus = false,
39
+ disabled: componentDisabled,
40
+ rows = 3
41
+ } = defineProps<{
42
+ readonly autoComplete?: FluxAutoCompleteType;
43
+ readonly autoFocus?: boolean;
44
+ readonly disabled?: boolean;
45
+ readonly isReadonly?: boolean;
46
+ readonly maxLength?: number;
47
+ readonly placeholder?: string;
48
+ readonly rows?: number;
49
+ }>();
50
+
51
+ const disabled = useDisabled(toRef(() => componentDisabled));
52
+ const {id} = useFormFieldInjection();
53
+ </script>