@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,9 @@
1
+ import type { FluxFormSelectGroup, FluxFormSelectOption } from '@flux-ui/types';
2
+
3
+ export function isFluxFormSelectGroup(item: unknown): item is FluxFormSelectGroup {
4
+ return item !== null && typeof item === 'object' && !('value' in item);
5
+ }
6
+
7
+ export function isFluxFormSelectOption(item: unknown): item is FluxFormSelectOption {
8
+ return item !== null && typeof item === 'object' && 'value' in item;
9
+ }
@@ -0,0 +1,55 @@
1
+ export type FluxTranslate = (key: FluxTranslation, params?: Record<string, string | number>) => string;
2
+ export type FluxTranslation = keyof typeof english;
3
+
4
+ export const english = {
5
+ 'flux.back': 'Back',
6
+ 'flux.cancel': 'Cancel',
7
+ 'flux.comingSoon': 'Coming soon',
8
+ 'flux.continue': 'Continue',
9
+ 'flux.customPeriod': 'Custom period',
10
+ 'flux.filter': 'Filter',
11
+ 'flux.filterReset': 'Reset filters',
12
+ 'flux.justNow': 'Just now',
13
+ 'flux.max': 'Max',
14
+ 'flux.min': 'Min',
15
+ 'flux.nSelected': '{n} selected',
16
+ 'flux.ok': 'Ok',
17
+ 'flux.optional': 'Optional',
18
+ 'flux.preview': 'Preview',
19
+ 'flux.previewClose': 'Close preview',
20
+ 'flux.displayingOf': '{from}–{to} of {total}',
21
+ 'flux.rowsPerPage': 'Rows per page',
22
+ 'flux.next': 'Next',
23
+ 'flux.noItems': 'There are no items (left).',
24
+ 'flux.pagination': 'Pagination',
25
+ 'flux.paginationNavigateTitle': 'Navigate',
26
+ 'flux.paginationNavigateMessage': 'Please provide the desired page number you wish to navigate to.',
27
+ 'flux.paginationNavigatePage': 'Page',
28
+ 'flux.previous': 'Previous',
29
+ 'flux.search': 'Search...',
30
+ 'flux.sort': 'Sort',
31
+ 'flux.sortAscending': 'Ascending',
32
+ 'flux.sortDescending': 'Descending',
33
+ 'flux.sortRemove': 'Remove sorting',
34
+ 'flux.today': 'Today',
35
+ 'flux.galleryPlaceholderButton': 'Pick image',
36
+ 'flux.galleryPlaceholderMessage': 'Drop an image here or click the button to upload...',
37
+ 'flux.galleryPlaceholderTitle': 'Gallery',
38
+ 'flux.timezoneEurope': 'Europe',
39
+ 'flux.timezoneAmerica': 'America',
40
+ 'flux.timezoneUs': 'United States',
41
+ 'flux.timezoneAustralia': 'Australia',
42
+ 'flux.timezoneCanada': 'Canada',
43
+ 'flux.timezoneMexico': 'Mexico',
44
+ 'flux.timezoneAfrica': 'Africa',
45
+ 'flux.timezoneAntarctica': 'Antarctica',
46
+ 'flux.timezoneArctic': 'Arctic',
47
+ 'flux.timezoneAsia': 'Asia',
48
+ 'flux.timezoneAtlantic': 'Atlantic',
49
+ 'flux.timezoneBrazil': 'Brazil',
50
+ 'flux.timezoneChile': 'Chile',
51
+ 'flux.timezoneEtc': 'ETC',
52
+ 'flux.timezoneOther': 'Other',
53
+ 'flux.timezoneIndian': 'Indian',
54
+ 'flux.timezonePacific': 'Pacific'
55
+ } as const;
@@ -0,0 +1,21 @@
1
+ import type { FluxIconName } from '@flux-ui/types';
2
+ import type { IconDefinition, IconPathData } from '@fortawesome/fontawesome-common-types';
3
+
4
+ type Icon = [number, number, string[], string, IconPathData];
5
+ type IconRegistry = Partial<{ [key in FluxIconName]: Icon; }>;
6
+ type Icons = Record<string, IconDefinition>;
7
+
8
+ export let iconRegistry: IconRegistry = {};
9
+
10
+ export function fluxRegisterIcons(icons: Icons): void {
11
+ iconRegistry = Object.keys(icons).reduce((acc: IconRegistry, key: string) => {
12
+ const {icon, iconName} = icons[key];
13
+ acc[iconName] = icon;
14
+
15
+ if (Array.isArray(icon[2])) {
16
+ icon[2].forEach((iconName: string) => acc[iconName as FluxIconName] = icon);
17
+ }
18
+
19
+ return acc;
20
+ }, {});
21
+ }
@@ -0,0 +1,8 @@
1
+ export * from './di';
2
+ export * from './filter';
3
+ export * from './helper';
4
+ export * from './i18n';
5
+ export * from './iconRegistry';
6
+ export * from './store';
7
+
8
+ export * as inputMask from './inputMask';
@@ -0,0 +1,34 @@
1
+ import type { InputMask } from 'imask';
2
+ import imask from 'imask/holder';
3
+
4
+ import 'imask/masked/pattern';
5
+
6
+ export function bic(element: HTMLInputElement): InputMask<{}> {
7
+ return imask(element, {
8
+ definitions: {
9
+ '#': /[A-Z0-9]/
10
+ },
11
+ mask: 'aaaaaa##[000]',
12
+ prepareChar: (str: string) => str.toUpperCase()
13
+ });
14
+ }
15
+
16
+ export function iban(element: HTMLInputElement): InputMask<{}> {
17
+ return imask(element, {
18
+ definitions: {
19
+ '#': /[A-Z0-9]/
20
+ },
21
+ mask: 'aa00 #### 0000 0000[ 0000 0000 0000 0000]',
22
+ prepareChar: (str: string) => str.toUpperCase()
23
+ });
24
+ }
25
+
26
+ export function vat(element: HTMLInputElement): InputMask<{}> {
27
+ return imask(element, {
28
+ definitions: {
29
+ '#': /[A-Z0-9]/
30
+ },
31
+ mask: 'aa########[#####]',
32
+ prepareChar: (str: string) => str.toUpperCase()
33
+ });
34
+ }
@@ -0,0 +1,233 @@
1
+ import type { FluxAlertObject, FluxConfirmObject, FluxPromptObject, FluxSnackbarObject, FluxTooltipObject } from '@flux-ui/types';
2
+ import type { ComputedRef } from 'vue';
3
+ import { computed, reactive } from 'vue';
4
+
5
+ export type FluxState = {
6
+ dialogCount: number;
7
+ readonly alerts: FluxAlertObject[];
8
+ readonly confirms: FluxConfirmObject[];
9
+ readonly prompts: FluxPromptObject[];
10
+ readonly snackbars: FluxSnackbarObject[];
11
+ readonly tooltips: FluxTooltipObject[];
12
+ };
13
+
14
+ export type FluxStore = FluxState & {
15
+ readonly inertMain: ComputedRef<boolean>;
16
+ readonly tooltip: ComputedRef<FluxTooltipObject | null>;
17
+
18
+ addAlert(spec: Omit<FluxAlertObject, 'id'>): number;
19
+ addConfirm(spec: Omit<FluxConfirmObject, 'id'>): number;
20
+ addPrompt(spec: Omit<FluxPromptObject, 'id'>): number;
21
+ addSnackbar(spec: Omit<FluxSnackbarObject, 'id'>): number;
22
+ addTooltip(spec: Omit<FluxTooltipObject, 'id'>): number;
23
+ registerDialog(): VoidFunction;
24
+ removeAlert(id: number): void;
25
+ removeConfirm(id: number): void;
26
+ removePrompt(id: number): void;
27
+ removeSnackbar(id: number): void;
28
+ removeTooltip(id: number): void;
29
+ showAlert(spec: Omit<FluxAlertObject, 'id' | 'onClose'>): Promise<void>;
30
+ showConfirm(spec: Omit<FluxConfirmObject, 'id' | 'onCancel' | 'onConfirm'>): Promise<boolean>;
31
+ showPrompt(spec: Omit<FluxPromptObject, 'id' | 'onCancel' | 'onConfirm'>): Promise<string | false>;
32
+ showSnackbar({duration, ...spec}: Omit<FluxSnackbarObject, 'id'> & { readonly duration?: number; }): Promise<void> | void;
33
+ updateSnackbar(id: number, spec: Partial<Omit<FluxSnackbarObject, 'id'>>): void;
34
+ updateTooltip(id: number, spec: Partial<Omit<FluxTooltipObject, 'id'>>): void;
35
+ showSnackbarSync({duration, ...spec}: Omit<FluxSnackbarObject, 'id'> & { readonly duration?: number; }): void;
36
+ };
37
+
38
+ const DEFAULT_SNACKBAR_DURATION = 6000;
39
+
40
+ const state = reactive<FluxState>({
41
+ dialogCount: 0,
42
+ alerts: [],
43
+ confirms: [],
44
+ prompts: [],
45
+ snackbars: [],
46
+ tooltips: []
47
+ });
48
+
49
+ let alertId: number = 0;
50
+ let tooltipId: number = 0;
51
+
52
+ export function addAlert(spec: Omit<FluxAlertObject, 'id'>): number {
53
+ const id = ++alertId;
54
+
55
+ state.alerts.push({
56
+ id,
57
+ ...spec
58
+ });
59
+
60
+ return id;
61
+ }
62
+
63
+ export function addConfirm(spec: Omit<FluxConfirmObject, 'id'>): number {
64
+ const id = ++alertId;
65
+
66
+ state.confirms.push({
67
+ id,
68
+ ...spec
69
+ });
70
+
71
+ return id;
72
+ }
73
+
74
+ export function addPrompt(spec: Omit<FluxPromptObject, 'id'>): number {
75
+ const id = ++alertId;
76
+
77
+ state.prompts.push({
78
+ id,
79
+ ...spec
80
+ });
81
+
82
+ return id;
83
+ }
84
+
85
+ export function addSnackbar(spec: Omit<FluxSnackbarObject, 'id'>): number {
86
+ const id = ++alertId;
87
+
88
+ state.snackbars.unshift({
89
+ id,
90
+ ...spec
91
+ });
92
+
93
+ return id;
94
+ }
95
+
96
+ export function addTooltip(spec: Omit<FluxTooltipObject, 'id'>): number {
97
+ const id = ++tooltipId;
98
+
99
+ state.tooltips.push({
100
+ id,
101
+ ...spec
102
+ });
103
+
104
+ return id;
105
+ }
106
+
107
+ export function registerDialog(): VoidFunction {
108
+ ++state.dialogCount;
109
+ return () => --state.dialogCount;
110
+ }
111
+
112
+ export function removeAlert(id: number): void {
113
+ const index = state.alerts.findIndex(a => a.id === id);
114
+ state.alerts.splice(index, 1);
115
+ }
116
+
117
+ export function removeConfirm(id: number): void {
118
+ const index = state.confirms.findIndex(c => c.id === id);
119
+ state.confirms.splice(index, 1);
120
+ }
121
+
122
+ export function removePrompt(id: number): void {
123
+ const index = state.prompts.findIndex(c => c.id === id);
124
+ state.prompts.splice(index, 1);
125
+ }
126
+
127
+ export function removeSnackbar(id: number): void {
128
+ const index = state.snackbars.findIndex(s => s.id === id);
129
+ state.snackbars.splice(index, 1);
130
+ }
131
+
132
+ export function removeTooltip(id: number): void {
133
+ const index = state.tooltips.findIndex(t => t.id === id);
134
+ state.tooltips.splice(index, 1);
135
+ }
136
+
137
+ export function updateSnackbar(id: number, spec: Partial<Omit<FluxSnackbarObject, 'id'>>): void {
138
+ const index = state.snackbars.findIndex(s => s.id === id);
139
+ Object.assign(state.snackbars[index], spec);
140
+ }
141
+
142
+ export function updateTooltip(id: number, spec: Partial<Omit<FluxTooltipObject, 'id'>>): void {
143
+ const index = state.tooltips.findIndex(s => s.id === id);
144
+ Object.assign(state.tooltips[index], spec);
145
+ }
146
+
147
+ export async function showAlert(spec: Omit<FluxAlertObject, 'id' | 'onClose'>): Promise<void> {
148
+ return new Promise(resolve => {
149
+ const id = addAlert({
150
+ ...spec,
151
+ onClose(): void {
152
+ resolve();
153
+ removeAlert(id);
154
+ }
155
+ });
156
+ });
157
+ }
158
+
159
+ export async function showConfirm(spec: Omit<FluxConfirmObject, 'id' | 'onCancel' | 'onConfirm'>): Promise<boolean> {
160
+ return new Promise(resolve => {
161
+ const id = addConfirm({
162
+ ...spec,
163
+ onCancel(): void {
164
+ resolve(false);
165
+ removeConfirm(id);
166
+ },
167
+ onConfirm(): void {
168
+ resolve(true);
169
+ removeConfirm(id);
170
+ }
171
+ });
172
+ });
173
+ }
174
+
175
+ export async function showPrompt(spec: Omit<FluxPromptObject, 'id' | 'onCancel' | 'onConfirm'>): Promise<string | false> {
176
+ return new Promise(resolve => {
177
+ const id = addPrompt({
178
+ ...spec,
179
+ onCancel(): void {
180
+ resolve(false);
181
+ removePrompt(id);
182
+ },
183
+ onConfirm(text: string): void {
184
+ resolve(text);
185
+ removePrompt(id);
186
+ }
187
+ });
188
+ });
189
+ }
190
+
191
+ export function showSnackbar({duration, ...spec}: Omit<FluxSnackbarObject, 'id'> & { readonly duration?: number; }): void;
192
+
193
+ export async function showSnackbar({duration, ...spec}: Omit<FluxSnackbarObject, 'id'> & { readonly duration?: number; }): Promise<void> {
194
+ const id = addSnackbar(spec);
195
+ await new Promise(resolve => setTimeout(() => requestAnimationFrame(resolve), duration ?? DEFAULT_SNACKBAR_DURATION));
196
+ removeSnackbar(id);
197
+ }
198
+
199
+ export function useFluxStore(): FluxStore {
200
+ const inertMain = computed(() => state.dialogCount > 0);
201
+ const tooltip = computed(() => state.tooltips[state.tooltips.length - 1] || null);
202
+
203
+ return {
204
+ ...state,
205
+ inertMain,
206
+ tooltip,
207
+ addAlert,
208
+ addConfirm,
209
+ addPrompt,
210
+ addSnackbar,
211
+ addTooltip,
212
+ registerDialog,
213
+ removeAlert,
214
+ removeConfirm,
215
+ removePrompt,
216
+ removeSnackbar,
217
+ removeTooltip,
218
+ showAlert,
219
+ showConfirm,
220
+ showPrompt,
221
+ showSnackbar,
222
+ updateSnackbar,
223
+ updateTooltip,
224
+ showSnackbarSync: promiseToVoidFunction(showSnackbar)
225
+ };
226
+ }
227
+
228
+ type Fn = (...args: any[]) => any;
229
+ type FnSync<T extends Fn> = (...args: Parameters<T>) => void;
230
+
231
+ function promiseToVoidFunction<T extends Fn>(fn: T): FnSync<T> {
232
+ return (...args: any[]) => fn(...args);
233
+ }
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42">
2
+ <path d="M40.4 29a21 21 0 0 0 1.6-8 21 21 0 1 0-13 19.4A8 8 0 0 1 40.5 29Z"/>
3
+ </svg>
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ import './css/index.scss';
2
+
3
+ export * from './component';
4
+ export * from './composable';
5
+ export * from './transition';
6
+
7
+ export {
8
+ fluxRegisterIcons,
9
+ isFluxFormSelectGroup,
10
+ isFluxFormSelectOption,
11
+ showAlert,
12
+ showConfirm,
13
+ showPrompt,
14
+ showSnackbar,
15
+ useFluxStore
16
+ } from './data';
17
+
18
+ export type {
19
+ FluxExpandableGroupInjection,
20
+ FluxFilterInjection,
21
+ FluxFlyoutInjection,
22
+ FluxFormFieldInjection,
23
+ FluxState,
24
+ FluxStore
25
+ } from './data';
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <Transition
3
+ @after-enter="afterEnter"
4
+ @enter="enter"
5
+ @leave="leave">
6
+ <slot/>
7
+ </Transition>
8
+ </template>
9
+
10
+ <script
11
+ lang="ts"
12
+ setup>
13
+ import { isHtmlElement } from '@basmilius/utils';
14
+
15
+ function afterEnter(elm: Element): void {
16
+ if (!isHtmlElement(elm)) {
17
+ return;
18
+ }
19
+
20
+ elm.style.height = 'auto';
21
+ }
22
+
23
+ function enter(elm: Element): void {
24
+ if (!isHtmlElement(elm)) {
25
+ return;
26
+ }
27
+
28
+ const {width} = getComputedStyle(elm);
29
+ elm.style.position = 'absolute';
30
+ elm.style.width = width;
31
+ elm.style.height = 'auto';
32
+ elm.style.visibility = 'hidden';
33
+
34
+ const {height} = getComputedStyle(elm);
35
+ elm.style.removeProperty('position');
36
+ elm.style.removeProperty('width');
37
+ elm.style.removeProperty('visibility');
38
+ elm.style.height = '0';
39
+
40
+ // note: force repaint.
41
+ getComputedStyle(elm);
42
+
43
+ requestAnimationFrame(() => requestAnimationFrame(() => elm.style.height = height));
44
+ }
45
+
46
+ function leave(elm: Element): void {
47
+ if (!isHtmlElement(elm)) {
48
+ return;
49
+ }
50
+
51
+ const {height} = getComputedStyle(elm);
52
+ elm.style.height = height;
53
+
54
+ // note: force repaint.
55
+ getComputedStyle(elm);
56
+
57
+ requestAnimationFrame(() => requestAnimationFrame(() => elm.style.height = '0'));
58
+ }
59
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <Transition
3
+ @after-enter="afterEnter"
4
+ @enter="enter"
5
+ @leave="leave">
6
+ <slot/>
7
+ </Transition>
8
+ </template>
9
+
10
+ <script
11
+ lang="ts"
12
+ setup>
13
+ import { isHtmlElement } from '@basmilius/utils';
14
+
15
+ function afterEnter(elm: Element): void {
16
+ if (!isHtmlElement(elm)) {
17
+ return;
18
+ }
19
+
20
+ elm.style.width = 'auto';
21
+ }
22
+
23
+ function enter(elm: Element): void {
24
+ if (!isHtmlElement(elm)) {
25
+ return;
26
+ }
27
+
28
+ const {height} = getComputedStyle(elm);
29
+ elm.style.position = 'absolute';
30
+ elm.style.height = height;
31
+ elm.style.width = 'auto';
32
+ elm.style.visibility = 'hidden';
33
+
34
+ const {width} = getComputedStyle(elm);
35
+ elm.style.removeProperty('position');
36
+ elm.style.removeProperty('height');
37
+ elm.style.removeProperty('visibility');
38
+ elm.style.width = '0';
39
+
40
+ // note: force repaint.
41
+ getComputedStyle(elm);
42
+
43
+ requestAnimationFrame(() => requestAnimationFrame(() => elm.style.width = width));
44
+ }
45
+
46
+ function leave(elm: Element): void {
47
+ if (!isHtmlElement(elm)) {
48
+ return;
49
+ }
50
+
51
+ const {width} = getComputedStyle(elm);
52
+ elm.style.width = width;
53
+
54
+ // note: force repaint.
55
+ getComputedStyle(elm);
56
+
57
+ requestAnimationFrame(() => requestAnimationFrame(() => elm.style.width = '0'));
58
+ }
59
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="isBack ? $style.breakthroughTransitionBackEnterActive : $style.breakthroughTransitionEnterActive"
5
+ :enter-from-class="isBack ? $style.breakthroughTransitionBackEnterFrom : $style.breakthroughTransitionEnterFrom"
6
+ :leave-active-class="isBack ? $style.breakthroughTransitionBackLeaveActive : $style.breakthroughTransitionLeaveActive"
7
+ :leave-to-class="isBack ? $style.breakthroughTransitionBackLeaveTo : $style.breakthroughTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Transition.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly isBack?: boolean;
21
+ readonly mode?: 'in-out' | 'out-in';
22
+ }>();
23
+ </script>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="$style.fadeTransitionEnterActive"
5
+ :enter-from-class="$style.fadeTransitionEnterFrom"
6
+ :enter-to-class="$style.fadeTransitionEnterTo"
7
+ :leave-active-class="$style.fadeTransitionLeaveActive"
8
+ :leave-from-class="$style.fadeTransitionLeaveFrom"
9
+ :leave-to-class="$style.fadeTransitionLeaveTo">
10
+ <slot/>
11
+ </Transition>
12
+ </template>
13
+
14
+ <script
15
+ lang="ts"
16
+ setup>
17
+ import $style from '$flux/css/component/Transition.module.scss';
18
+
19
+ const {
20
+ mode = 'out-in'
21
+ } = defineProps<{
22
+ readonly mode?: 'in-out' | 'out-in';
23
+ }>();
24
+ </script>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="$style.overlayTransitionEnterActive"
5
+ :enter-from-class="$style.overlayTransitionEnterFrom"
6
+ :leave-active-class="$style.overlayTransitionLeaveActive"
7
+ :leave-to-class="$style.overlayTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Overlay.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly mode?: 'in-out' | 'out-in';
21
+ }>();
22
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="isBack ? $style.routeTransitionBackEnterActive : $style.routeTransitionEnterActive"
5
+ :enter-from-class="isBack ? $style.routeTransitionBackEnterFrom : $style.routeTransitionEnterFrom"
6
+ :leave-active-class="isBack ? $style.routeTransitionBackLeaveActive : $style.routeTransitionLeaveActive"
7
+ :leave-to-class="isBack ? $style.routeTransitionBackLeaveTo : $style.routeTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Transition.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly isBack?: boolean;
21
+ readonly mode?: 'in-out' | 'out-in';
22
+ }>();
23
+ </script>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="$style.slideOverTransitionEnterActive"
5
+ :enter-from-class="$style.slideOverTransitionEnterFrom"
6
+ :leave-active-class="$style.slideOverTransitionLeaveActive"
7
+ :leave-to-class="$style.slideOverTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Overlay.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly mode?: 'in-out' | 'out-in';
21
+ }>();
22
+ </script>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="$style.tooltipTransitionEnterActive"
5
+ :enter-from-class="$style.tooltipTransitionEnterFrom"
6
+ :leave-active-class="$style.tooltipTransitionLeaveActive"
7
+ :leave-to-class="$style.tooltipTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Transition.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly mode?: 'in-out' | 'out-in';
21
+ }>();
22
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <Transition
3
+ :mode="mode"
4
+ :enter-active-class="isBack ? $style.verticalWindowTransitionBackEnterActive : $style.verticalWindowTransitionEnterActive"
5
+ :enter-from-class="isBack ? $style.verticalWindowTransitionBackEnterFrom : $style.verticalWindowTransitionEnterFrom"
6
+ :leave-active-class="isBack ? $style.verticalWindowTransitionBackLeaveActive : $style.verticalWindowTransitionLeaveActive"
7
+ :leave-to-class="isBack ? $style.verticalWindowTransitionBackLeaveTo : $style.verticalWindowTransitionLeaveTo">
8
+ <slot/>
9
+ </Transition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import $style from '$flux/css/component/Transition.module.scss';
16
+
17
+ const {
18
+ mode = 'out-in'
19
+ } = defineProps<{
20
+ readonly isBack?: boolean;
21
+ readonly mode?: 'in-out' | 'out-in';
22
+ }>();
23
+ </script>