@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,59 @@
1
+ <template>
2
+ <FluxDatePicker
3
+ :class="$style.filterDatePicker"
4
+ :max="max"
5
+ :min="min"
6
+ :model-value="currentValue"
7
+ :range-mode="rangeMode"
8
+ @update:model-value="onDatePicked"/>
9
+ </template>
10
+
11
+ <script
12
+ lang="ts"
13
+ setup>
14
+ import type { FluxIconName } from '@flux-ui/types';
15
+ import { DateTime } from 'luxon';
16
+ import { computed, unref } from 'vue';
17
+ import { useFilterInjection } from '$flux/composable';
18
+ import FluxDatePicker from './FluxDatePicker.vue';
19
+ import $style from '$flux/css/component/Filter.module.scss';
20
+
21
+ const {
22
+ name,
23
+ rangeMode = 'range'
24
+ } = defineProps<{
25
+ readonly icon?: FluxIconName;
26
+ readonly label: string;
27
+ readonly max?: DateTime;
28
+ readonly min?: DateTime;
29
+ readonly name: string;
30
+ readonly rangeMode?: 'range' | 'week' | 'month';
31
+ }>();
32
+
33
+ const {back, state, setValue} = useFilterInjection();
34
+
35
+ const currentValue = computed(() => {
36
+ const value = unref(state)[name];
37
+
38
+ if (!value || !Array.isArray(value)) {
39
+ return null;
40
+ }
41
+
42
+ const [start, end] = value;
43
+
44
+ if (!DateTime.isDateTime(start) || !DateTime.isDateTime(end)) {
45
+ return null;
46
+ }
47
+
48
+ return [start, end];
49
+ });
50
+
51
+ function onDatePicked(date: DateTime | DateTime[] | null): void {
52
+ if (date === null || !Array.isArray(date)) {
53
+ return;
54
+ }
55
+
56
+ setValue(name, date);
57
+ back();
58
+ }
59
+ </script>
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <FilterOptionBase
3
+ v-model:search-query="modelSearch"
4
+ :is-searchable="isSearchable"
5
+ :options="filteredOptions"
6
+ :selected="[currentValue]"
7
+ :search-placeholder="searchPlaceholder"
8
+ @select="onSelect"/>
9
+ </template>
10
+
11
+ <script
12
+ lang="ts"
13
+ setup>
14
+ import type { FluxFilterOptionRow, FluxFilterValue, FluxFilterValueSingle, FluxIconName } from '@flux-ui/types';
15
+ import { computed, unref } from 'vue';
16
+ import { useFilterInjection } from '$flux/composable';
17
+ import { isFluxFilterOptionHeader } from '$flux/data';
18
+ import { FilterOptionBase } from './primitive';
19
+
20
+ const modelSearch = defineModel<string>('searchQuery', {default: ''});
21
+
22
+ const {
23
+ name,
24
+ options
25
+ } = defineProps<{
26
+ readonly icon?: FluxIconName;
27
+ readonly isSearchable?: boolean;
28
+ readonly label: string;
29
+ readonly name: string;
30
+ readonly options: FluxFilterOptionRow[];
31
+ readonly searchPlaceholder?: string;
32
+ }>();
33
+
34
+ const {back, state, setValue} = useFilterInjection();
35
+
36
+ const currentValue = computed(() => unref(state)[name] as FluxFilterValueSingle);
37
+ const filteredOptions = computed(() => options
38
+ .filter(o => isFluxFilterOptionHeader(o) || unref(modelSearch).length === 0 || o.label.toLowerCase().includes(unref(modelSearch).toLowerCase())));
39
+
40
+ function onSelect(value: FluxFilterValue): void {
41
+ if (unref(currentValue) === value) {
42
+ setValue(name, null);
43
+ } else {
44
+ setValue(name, value);
45
+ }
46
+
47
+ back();
48
+ }
49
+ </script>
@@ -0,0 +1,103 @@
1
+ <template>
2
+ <FilterOptionBase
3
+ v-model:search-query="modelSearch"
4
+ :is-loading="isLoading"
5
+ is-searchable
6
+ :options="options"
7
+ :selected="[currentValue]"
8
+ :search-placeholder="searchPlaceholder"
9
+ @select="onSelect"/>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import { useDebouncedRef } from '@flux-ui/internals';
16
+ import type { FluxFilterOptionRow, FluxFilterValue, FluxFilterValueSingle, FluxIconName } from '@flux-ui/types';
17
+ import { computed, ref, unref, watch } from 'vue';
18
+ import { useFilterInjection } from '$flux/composable';
19
+ import { useLoaded } from '$flux/composable/private';
20
+ import { isFluxFilterOptionItem } from '$flux/data';
21
+ import { FilterOptionBase } from './primitive';
22
+
23
+ const modelSearch = defineModel<string>('searchQuery', {
24
+ default: ''
25
+ });
26
+
27
+ const {
28
+ fetchOptions: fetchOptionsProp,
29
+ fetchRelevant: fetchRelevantProp,
30
+ fetchSearch: fetchSearchProp,
31
+ name
32
+ } = defineProps<{
33
+ fetchOptions(ids: FluxFilterValue[]): Promise<FluxFilterOptionRow[]>;
34
+ fetchRelevant(): Promise<FluxFilterOptionRow[]>;
35
+ fetchSearch(searchQuery: string): Promise<FluxFilterOptionRow[]>;
36
+
37
+ readonly icon?: FluxIconName;
38
+ readonly label: string;
39
+ readonly name: string;
40
+ readonly searchPlaceholder?: string;
41
+ }>();
42
+
43
+ const {back, state, setValue} = useFilterInjection();
44
+ const {isLoading, loaded} = useLoaded();
45
+ const debouncedModelSearch = useDebouncedRef(modelSearch, 150);
46
+ const fetchOptions = computed(() => loaded(fetchOptionsProp));
47
+ const fetchRelevant = computed(() => loaded(fetchRelevantProp));
48
+ const fetchSearch = computed(() => loaded(fetchSearchProp));
49
+
50
+ const selectedOptions = ref<FluxFilterOptionRow[]>([]);
51
+ const visibleOptions = ref<FluxFilterOptionRow[]>([]);
52
+
53
+ const currentValue = computed(() => unref(state)[name] as FluxFilterValueSingle);
54
+
55
+ const options = computed(() => {
56
+ const options: FluxFilterOptionRow[] = [];
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 (isFluxFilterOptionItem(so) && visible.find(vo => isFluxFilterOptionItem(vo) && vo.value === so.value)) {
65
+ return;
66
+ }
67
+
68
+ if (isFluxFilterOptionItem(so) && !so.label.toLowerCase().includes(search.toLowerCase())) {
69
+ return;
70
+ }
71
+
72
+ options.push(so);
73
+ });
74
+
75
+ return options;
76
+ });
77
+
78
+ function onSelect(value: FluxFilterValue): void {
79
+ if (unref(currentValue) === value) {
80
+ setValue(name, null);
81
+ } else {
82
+ setValue(name, value);
83
+ }
84
+
85
+ back();
86
+ }
87
+
88
+ watch(currentValue, async value => {
89
+ if (!value && value !== 0) {
90
+ return;
91
+ }
92
+
93
+ selectedOptions.value = await unref(fetchOptions)([value]);
94
+ }, {immediate: true});
95
+
96
+ watch(debouncedModelSearch, async searchQuery => {
97
+ if (searchQuery.length > 0) {
98
+ visibleOptions.value = await unref(fetchSearch)(searchQuery);
99
+ } else {
100
+ visibleOptions.value = await unref(fetchRelevant)();
101
+ }
102
+ }, {immediate: true});
103
+ </script>
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <FilterOptionBase
3
+ v-model:search-query="modelSearch"
4
+ :is-searchable="isSearchable"
5
+ :options="filteredOptions"
6
+ :selected="currentValue"
7
+ :search-placeholder="searchPlaceholder"
8
+ @select="onSelect"/>
9
+ </template>
10
+
11
+ <script
12
+ lang="ts"
13
+ setup>
14
+ import type { FluxFilterOptionRow, FluxFilterValueSingle, FluxIconName } from '@flux-ui/types';
15
+ import { computed, unref } from 'vue';
16
+ import { useFilterInjection } from '$flux/composable';
17
+ import { isFluxFilterOptionHeader } from '$flux/data';
18
+ import { FilterOptionBase } from './primitive';
19
+
20
+ const modelSearch = defineModel<string>('searchQuery', {
21
+ default: ''
22
+ });
23
+
24
+ const {
25
+ name,
26
+ options
27
+ } = defineProps<{
28
+ readonly icon?: FluxIconName;
29
+ readonly isSearchable?: boolean;
30
+ readonly label: string;
31
+ readonly name: string;
32
+ readonly options: FluxFilterOptionRow[];
33
+ readonly searchPlaceholder?: string;
34
+ }>();
35
+
36
+ const {state, setValue} = useFilterInjection();
37
+
38
+ const currentValue = computed(() => {
39
+ const value = unref(state)[name];
40
+
41
+ if (Array.isArray(value)) {
42
+ return value;
43
+ }
44
+
45
+ return [];
46
+ });
47
+
48
+ const filteredOptions = computed(() => options
49
+ .filter(o => isFluxFilterOptionHeader(o) || unref(modelSearch).length === 0 || o.label.toLowerCase().includes(unref(modelSearch).toLowerCase())));
50
+
51
+ function onSelect(value: FluxFilterValueSingle): void {
52
+ let values = Array.from(unref(currentValue));
53
+
54
+ if (values.includes(value)) {
55
+ values = values.filter(v => v !== value);
56
+ } else {
57
+ values.push(value);
58
+ }
59
+
60
+ setValue(name, values);
61
+ }
62
+ </script>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <FilterOptionBase
3
+ v-model:search-query="modelSearch"
4
+ :is-loading="isLoading"
5
+ is-searchable
6
+ :options="options"
7
+ :selected="currentValue"
8
+ :search-placeholder="searchPlaceholder"
9
+ @select="onSelect"/>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import { useDebouncedRef } from '@flux-ui/internals';
16
+ import type { FluxFilterOptionRow, FluxFilterValue, FluxFilterValueSingle, FluxIconName } from '@flux-ui/types';
17
+ import { computed, ref, unref, watch } from 'vue';
18
+ import { useFilterInjection } from '$flux/composable';
19
+ import { useLoaded } from '$flux/composable/private';
20
+ import { isFluxFilterOptionItem } from '$flux/data';
21
+ import { FilterOptionBase } from './primitive';
22
+
23
+ const modelSearch = defineModel<string>('searchQuery', {
24
+ default: ''
25
+ });
26
+
27
+ const {
28
+ fetchOptions: fetchOptionsProp,
29
+ fetchRelevant: fetchRelevantProp,
30
+ fetchSearch: fetchSearchProp,
31
+ name
32
+ } = defineProps<{
33
+ fetchOptions(ids: FluxFilterValue[]): Promise<FluxFilterOptionRow[]>;
34
+ fetchRelevant(): Promise<FluxFilterOptionRow[]>;
35
+ fetchSearch(searchQuery: string): Promise<FluxFilterOptionRow[]>;
36
+
37
+ readonly icon?: FluxIconName;
38
+ readonly label: string;
39
+ readonly name: string;
40
+ readonly searchPlaceholder?: string;
41
+ }>();
42
+
43
+ const {state, setValue} = useFilterInjection();
44
+ const {isLoading, loaded} = useLoaded();
45
+ const debouncedModelSearch = useDebouncedRef(modelSearch, 150);
46
+ const fetchOptions = computed(() => loaded(fetchOptionsProp));
47
+ const fetchRelevant = computed(() => loaded(fetchRelevantProp));
48
+ const fetchSearch = computed(() => loaded(fetchSearchProp));
49
+
50
+ const selectedOptions = ref<FluxFilterOptionRow[]>([]);
51
+ const visibleOptions = ref<FluxFilterOptionRow[]>([]);
52
+
53
+ const currentValue = computed(() => {
54
+ const value = unref(state)[name];
55
+
56
+ if (Array.isArray(value)) {
57
+ return value;
58
+ }
59
+
60
+ return [];
61
+ });
62
+
63
+ const options = computed(() => {
64
+ const options: FluxFilterOptionRow[] = [];
65
+ const search = unref(modelSearch);
66
+ const selected = unref(selectedOptions);
67
+ const visible = unref(visibleOptions);
68
+
69
+ visible.forEach(vo => options.push(vo));
70
+
71
+ selected.forEach(so => {
72
+ if (isFluxFilterOptionItem(so) && visible.find(vo => isFluxFilterOptionItem(vo) && vo.value === so.value)) {
73
+ return;
74
+ }
75
+
76
+ if (isFluxFilterOptionItem(so) && !so.label.toLowerCase().includes(search.toLowerCase())) {
77
+ return;
78
+ }
79
+
80
+ options.push(so);
81
+ });
82
+
83
+ return options;
84
+ });
85
+
86
+ function onSelect(value: FluxFilterValueSingle): void {
87
+ let values = Array.from(unref(currentValue));
88
+
89
+ if (values.includes(value)) {
90
+ values = values.filter(v => v !== value);
91
+ } else {
92
+ values.push(value);
93
+ }
94
+
95
+ setValue(name, values);
96
+ }
97
+
98
+ watch(currentValue, async value => {
99
+ if (value.length === 0) {
100
+ return;
101
+ }
102
+
103
+ selectedOptions.value = await unref(fetchOptions)(value);
104
+ }, {immediate: true});
105
+
106
+ watch(debouncedModelSearch, async searchQuery => {
107
+ if (searchQuery.length > 0) {
108
+ visibleOptions.value = await unref(fetchSearch)(searchQuery);
109
+ } else {
110
+ visibleOptions.value = await unref(fetchRelevant)();
111
+ }
112
+ }, {immediate: true});
113
+ </script>
@@ -0,0 +1,91 @@
1
+ <template>
2
+ <FluxPaneBody>
3
+ <FluxFormColumn>
4
+ <FluxFormField :label="translate('flux.min')">
5
+ <FluxFormSlider
6
+ :formatter="formatter"
7
+ :is-ticks-visible="isTicksVisible"
8
+ :model-value="currentValue[0]"
9
+ :max="max"
10
+ :min="min"
11
+ :step="step"
12
+ @update:model-value="update({lower: $event})"/>
13
+
14
+ <template #value>
15
+ {{ formatter ? formatter(currentValue[0]) : currentValue[0] }}
16
+ </template>
17
+ </FluxFormField>
18
+
19
+ <FluxFormField :label="translate('flux.max')">
20
+ <FluxFormSlider
21
+ :formatter="formatter"
22
+ :is-ticks-visible="isTicksVisible"
23
+ :model-value="currentValue[1]"
24
+ :max="max"
25
+ :min="min"
26
+ :step="step"
27
+ @update:model-value="update({upper: $event})"/>
28
+
29
+ <template #value>
30
+ {{ formatter ? formatter(currentValue[1]) : currentValue[1] }}
31
+ </template>
32
+ </FluxFormField>
33
+ </FluxFormColumn>
34
+ </FluxPaneBody>
35
+ </template>
36
+
37
+ <script
38
+ lang="ts"
39
+ setup>
40
+ import { formatNumber } from '@basmilius/utils';
41
+ import type { FluxIconName } from '@flux-ui/types';
42
+ import { computed, unref } from 'vue';
43
+ import { useFilterInjection } from '$flux/composable';
44
+ import { useTranslate } from '$flux/composable/private';
45
+ import FluxFormColumn from './FluxFormColumn.vue';
46
+ import FluxFormField from './FluxFormField.vue';
47
+ import FluxFormSlider from './FluxFormSlider.vue';
48
+ import FluxPaneBody from './FluxPaneBody.vue';
49
+
50
+ const {
51
+ formatter = formatNumber,
52
+ max,
53
+ min,
54
+ name,
55
+ step = 1
56
+ } = defineProps<{
57
+ readonly icon?: FluxIconName;
58
+ readonly isTicksVisible?: boolean;
59
+ readonly label: string;
60
+ readonly name: string;
61
+ readonly max: number;
62
+ readonly min: number;
63
+ readonly step?: number;
64
+ readonly formatter?: (value: number) => string;
65
+ }>();
66
+
67
+ const {state, setValue} = useFilterInjection();
68
+ const translate = useTranslate();
69
+
70
+ const currentValue = computed(() => (unref(state)[name] ?? [min, max]) as number[]);
71
+
72
+ function update({lower, upper}: { lower?: number, upper?: number }): void {
73
+ if (lower || lower === 0) {
74
+ upper ??= unref(currentValue)[1];
75
+
76
+ if (lower > upper) {
77
+ upper = lower;
78
+ }
79
+ }
80
+
81
+ if (upper || upper === 0) {
82
+ lower ??= unref(currentValue)[0];
83
+
84
+ if (lower > upper) {
85
+ lower = upper;
86
+ }
87
+ }
88
+
89
+ setValue(name, [lower!, upper!]);
90
+ }
91
+ </script>
@@ -0,0 +1,141 @@
1
+ <template>
2
+ <canvas
3
+ ref="canvas"
4
+ :class="$style.flickeringGrid"/>
5
+ </template>
6
+
7
+ <script
8
+ lang="ts"
9
+ setup>
10
+ import { mulberry32 } from '@basmilius/utils';
11
+ import { useInView } from '@flux-ui/internals';
12
+ import { computed, unref, useTemplateRef, watch } from 'vue';
13
+ import $style from '$flux/css/component/Visual.module.scss';
14
+
15
+ const {
16
+ color = '#1d4ed8',
17
+ flickerChance = 0.15,
18
+ gap = 6,
19
+ maxOpacity = 0.3,
20
+ size = 3
21
+ } = defineProps<{
22
+ readonly color?: string;
23
+ readonly flickerChance?: number;
24
+ readonly gap?: number;
25
+ readonly maxOpacity?: number;
26
+ readonly size?: number;
27
+ }>();
28
+
29
+ const canvasRef = useTemplateRef('canvas');
30
+
31
+ const inView = useInView(canvasRef);
32
+
33
+ const mulberry = mulberry32(13);
34
+
35
+ const rgb = computed(() => {
36
+ const canvas = document.createElement('canvas');
37
+ canvas.width = canvas.height = 1;
38
+
39
+ const context = canvas.getContext('2d');
40
+
41
+ if (!context) {
42
+ return [0, 0, 0];
43
+ }
44
+
45
+ context.fillStyle = color;
46
+ context.fillRect(0, 0, 1, 1);
47
+
48
+ return context.getImageData(0, 0, 1, 1).data;
49
+ });
50
+
51
+ function draw(context: CanvasRenderingContext2D, width: number, height: number, columns: number, rows: number, squares: Float32Array, dpr: number): void {
52
+ context.clearRect(0, 0, width * dpr, height * dpr);
53
+
54
+ const [r, g, b] = unref(rgb);
55
+
56
+ for (let i = 0; i < columns; ++i) {
57
+ for (let j = 0; j < rows; ++j) {
58
+ const opacity = squares[i * rows + j];
59
+ context.fillStyle = `rgb(${r} ${g} ${b} / ${opacity})`;
60
+ context.fillRect(
61
+ (i * (size + gap) + width / 2 - (columns / 2 * (size + gap) - gap / 2)) * dpr,
62
+ (j * (size + gap) + height / 2 - (rows / 2 * (size + gap) - gap / 2)) * dpr,
63
+ size * dpr,
64
+ size * dpr
65
+ );
66
+ }
67
+ }
68
+ }
69
+
70
+ function setup(canvas: HTMLCanvasElement) {
71
+ const width = canvas.clientWidth;
72
+ const height = canvas.clientHeight;
73
+ const dpr = window.devicePixelRatio || 1;
74
+ canvas.width = width * dpr;
75
+ canvas.height = height * dpr;
76
+ canvas.style.width = `${width}px`;
77
+ canvas.style.height = `${height}px`;
78
+
79
+ const columns = Math.ceil(width / (size + gap));
80
+ const rows = Math.ceil(height / (size + gap));
81
+ const squares = new Float32Array(columns * rows);
82
+
83
+ for (let i = 0; i < squares.length; ++i) {
84
+ squares[i] = mulberry.next() * maxOpacity;
85
+ }
86
+
87
+ return {
88
+ width,
89
+ height,
90
+ columns,
91
+ rows,
92
+ squares,
93
+ dpr
94
+ };
95
+ }
96
+
97
+ function tick(squares: Float32Array, delta: number): void {
98
+ for (let i = 0; i < squares.length; ++i) {
99
+ if (mulberry.next() < flickerChance * delta) {
100
+ squares[i] = mulberry.next() * maxOpacity;
101
+ }
102
+ }
103
+ }
104
+
105
+ watch([canvasRef, inView], ([canvas, inView], _, onCleanup) => {
106
+ if (!canvas || !inView) {
107
+ return;
108
+ }
109
+
110
+ const context = canvas.getContext('2d');
111
+
112
+ if (!context) {
113
+ return;
114
+ }
115
+
116
+ let frame = 0;
117
+ let lastTime = 0;
118
+ let {width, height, columns, rows, squares, dpr} = setup(canvas);
119
+
120
+ const animate = (time: number): void => {
121
+ const delta = (time - lastTime) / 1000;
122
+ lastTime = time;
123
+
124
+ tick(squares, delta);
125
+ draw(context, width, height, columns, rows, squares, dpr);
126
+ frame = requestAnimationFrame(animate);
127
+ };
128
+
129
+ const onResize = () => {
130
+ ({width, height, columns, rows, squares, dpr} = setup(canvas));
131
+ };
132
+
133
+ window.addEventListener('resize', onResize, {passive: true});
134
+ requestAnimationFrame(animate);
135
+
136
+ onCleanup(() => {
137
+ window.removeEventListener('resize', onResize);
138
+ cancelAnimationFrame(frame);
139
+ });
140
+ }, {immediate: true});
141
+ </script>