@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,85 @@
1
+ <template>
2
+ <FluxPressable
3
+ :class="clsx(
4
+ color === 'gray' && $style.tagGray,
5
+ color === 'primary' && $style.tagPrimary,
6
+ color === 'danger' && $style.tagDanger,
7
+ color === 'info' && $style.tagInfo,
8
+ color === 'success' && $style.tagSuccess,
9
+ color === 'warning' && $style.tagWarning
10
+ )"
11
+ :component-type="type"
12
+ :tabindex="tabindex"
13
+ :href="href"
14
+ :rel="rel"
15
+ :target="target"
16
+ :to="to"
17
+ @click="$emit('click', $event)"
18
+ @mouseenter="$emit('mouseenter', $event)"
19
+ @mouseleave="$emit('mouseleave', $event)">
20
+ <FluxSpinner
21
+ v-if="isLoading"
22
+ :class="$style.tagIcon"
23
+ :size="16"/>
24
+
25
+ <span
26
+ v-else-if="dot"
27
+ :class="$style.tagDot"/>
28
+
29
+ <FluxIcon
30
+ v-else-if="icon"
31
+ :class="$style.tagIcon"
32
+ :name="icon"
33
+ :size="16"/>
34
+
35
+ <span :class="$style.tagLabel">
36
+ {{ label }}
37
+ </span>
38
+
39
+ <button
40
+ v-if="!isClickable && isDeletable"
41
+ :class="$style.tagClose"
42
+ type="button"
43
+ @click="onDeleteClick()">
44
+ <FluxIcon name="xmark"/>
45
+ </button>
46
+ </FluxPressable>
47
+ </template>
48
+
49
+ <script
50
+ lang="ts"
51
+ setup>
52
+ import type { FluxButtonEmits, FluxColor, FluxIconName, FluxPressableType, FluxTo } from '@flux-ui/types';
53
+ import { clsx } from 'clsx';
54
+ import FluxIcon from './FluxIcon.vue';
55
+ import FluxPressable from './FluxPressable.vue';
56
+ import FluxSpinner from './FluxSpinner.vue';
57
+ import $style from '$flux/css/component/Badge.module.scss';
58
+
59
+ const emit = defineEmits<FluxButtonEmits & {
60
+ delete: [];
61
+ }>();
62
+
63
+ const {
64
+ color = 'gray',
65
+ isClickable
66
+ } = defineProps<{
67
+ readonly color?: FluxColor;
68
+ readonly dot?: boolean;
69
+ readonly icon?: FluxIconName;
70
+ readonly isClickable?: boolean;
71
+ readonly isDeletable?: boolean;
72
+ readonly isLoading?: boolean;
73
+ readonly label: string;
74
+ readonly type?: FluxPressableType;
75
+ readonly tabindex?: string | number;
76
+ readonly href?: string;
77
+ readonly rel?: string;
78
+ readonly target?: string;
79
+ readonly to?: FluxTo;
80
+ }>();
81
+
82
+ function onDeleteClick(): void {
83
+ emit('delete');
84
+ }
85
+ </script>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <FluxStack
3
+ direction="horizontal"
4
+ :gap="6"
5
+ is-wrapping>
6
+ <slot/>
7
+ </FluxStack>
8
+ </template>
9
+
10
+ <script
11
+ lang="ts"
12
+ setup>
13
+ import FluxStack from './FluxStack.vue';
14
+
15
+ defineSlots<{
16
+ default(): any;
17
+ }>();
18
+ </script>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <div :class="$style.ticks">
3
+ <template
4
+ v-for="tick of ticks"
5
+ :key="tick">
6
+ <div
7
+ :class="$style.tickLarge"
8
+ :style="{
9
+ '--position': (tick - lower) / (upper - lower)
10
+ }">
11
+ <span>{{ tick }}</span>
12
+ </div>
13
+ </template>
14
+
15
+ <template
16
+ v-for="tick of smallTicks"
17
+ :key="tick">
18
+ <div
19
+ :class="$style.tickSmall"
20
+ :style="{
21
+ '--position': (tick - lower) / (upper - lower)
22
+ }"/>
23
+ </template>
24
+ </div>
25
+ </template>
26
+
27
+ <script
28
+ lang="ts"
29
+ setup>
30
+ import { generateStepTicks } from '@basmilius/utils';
31
+ import { computed } from 'vue';
32
+ import $style from '$flux/css/component/primitive/Slider.module.scss';
33
+
34
+ const {
35
+ lower,
36
+ upper
37
+ } = defineProps<{
38
+ readonly lower: number;
39
+ readonly upper: number;
40
+ }>();
41
+
42
+ const smallTicks = computed(() => generateStepTicks(lower, upper, 50, true).filter(s => !ticks.value.includes(s)));
43
+ const ticks = computed(() => generateStepTicks(lower, upper, 5));
44
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div
3
+ :class="$style.timeline"
4
+ role="feed">
5
+ <slot/>
6
+ </div>
7
+ </template>
8
+
9
+ <script
10
+ lang="ts"
11
+ setup>
12
+ import $style from '$flux/css/component/Timeline.module.scss';
13
+
14
+ defineSlots<{
15
+ default(): any;
16
+ }>();
17
+ </script>
@@ -0,0 +1,73 @@
1
+ <template>
2
+ <div
3
+ :class="clsx(
4
+ color === 'gray' && $style.timelineItemGray,
5
+ color === 'primary' && $style.timelineItemPrimary,
6
+ color === 'danger' && $style.timelineItemDanger,
7
+ color === 'info' && $style.timelineItemInfo,
8
+ color === 'success' && $style.timelineItemSuccess,
9
+ color === 'warning' && $style.timelineItemWarning
10
+ )"
11
+ role="article">
12
+ <div :class="$style.timelineItemLine"/>
13
+
14
+ <div
15
+ v-if="photo"
16
+ :class="$style.timelineItemPhoto">
17
+ <img
18
+ :class="$style.timelineItemPhotoImage"
19
+ :src="photo"
20
+ alt="">
21
+
22
+ <div
23
+ v-if="icon"
24
+ :class="$style.timelineItemPhotoIcon">
25
+ <FluxIcon
26
+ :name="icon"
27
+ :size="16"/>
28
+ </div>
29
+ </div>
30
+
31
+ <div
32
+ v-else-if="icon"
33
+ :class="$style.timelineItemIcon">
34
+ <FluxIcon
35
+ :name="icon"
36
+ :size="20"/>
37
+ </div>
38
+
39
+ <div :class="$style.timelineItemBody">
40
+ <div
41
+ v-if="title || when"
42
+ :class="$style.timelineItemHeader">
43
+ <strong v-if="title">{{ title }}</strong>
44
+ <span v-if="when">{{ when }}</span>
45
+ </div>
46
+
47
+ <slot/>
48
+ </div>
49
+ </div>
50
+ </template>
51
+
52
+ <script
53
+ lang="ts"
54
+ setup>
55
+ import type { FluxColor, FluxIconName } from '@flux-ui/types';
56
+ import { clsx } from 'clsx';
57
+ import FluxIcon from './FluxIcon.vue';
58
+ import $style from '$flux/css/component/Timeline.module.scss';
59
+
60
+ const {
61
+ color = 'gray'
62
+ } = defineProps<{
63
+ readonly color?: FluxColor;
64
+ readonly icon?: FluxIconName;
65
+ readonly photo?: string;
66
+ readonly title?: string;
67
+ readonly when?: string;
68
+ }>();
69
+
70
+ defineSlots<{
71
+ default(): any;
72
+ }>();
73
+ </script>
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <label
3
+ :class="clsx(
4
+ $style.toggle,
5
+ modelValue && $style.isChecked,
6
+ disabled && $style.isDisabled,
7
+ isSwitch && $style.isSwitch
8
+ )"
9
+ :for="id"
10
+ :aria-disabled="disabled ? true : undefined">
11
+ <FluxIcon
12
+ v-if="iconOff"
13
+ :class="$style.toggleIconOff"
14
+ :name="iconOff"
15
+ :size="14"/>
16
+
17
+ <FluxIcon
18
+ v-if="iconOn"
19
+ :class="$style.toggleIconOn"
20
+ :name="iconOn"
21
+ :size="14"/>
22
+
23
+ <input
24
+ :class="$style.toggleInput"
25
+ :id="id"
26
+ :disabled="disabled"
27
+ type="checkbox"
28
+ :checked="modelValue"
29
+ role="switch"
30
+ :aria-checked="modelValue"
31
+ @input="toggle"/>
32
+ </label>
33
+ </template>
34
+
35
+ <script
36
+ lang="ts"
37
+ setup>
38
+ import type { FluxIconName } from '@flux-ui/types';
39
+ import { clsx } from 'clsx';
40
+ import { toRef } from 'vue';
41
+ import { useDisabled, useFormFieldInjection } from '$flux/composable';
42
+ import FluxIcon from './FluxIcon.vue';
43
+ import $style from '$flux/css/component/Form.module.scss';
44
+
45
+ const modelValue = defineModel<boolean>({
46
+ default: false
47
+ });
48
+
49
+ const {
50
+ disabled: componentDisabled
51
+ } = defineProps<{
52
+ readonly iconOff?: FluxIconName;
53
+ readonly iconOn?: FluxIconName;
54
+ readonly disabled?: boolean;
55
+ readonly isSwitch?: boolean;
56
+ }>();
57
+
58
+ const disabled = useDisabled(toRef(() => componentDisabled));
59
+ const {id} = useFormFieldInjection();
60
+
61
+ function toggle(evt: Event): void {
62
+ modelValue.value = (evt.target as HTMLInputElement).checked;
63
+ }
64
+ </script>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <FluxStack
3
+ :class="clsx(
4
+ !!floatingMode ? $style.toolbarFloating : $style.toolbarFlat,
5
+ floatingMode === 'free' && $style.isFree,
6
+ floatingMode === 'top-end' && $style.isTopEnd,
7
+ floatingMode === 'top-start' && $style.isTopStart,
8
+ floatingMode === 'bottom-end' && $style.isBottomEnd,
9
+ floatingMode === 'bottom-start' && $style.isBottomStart,
10
+ )"
11
+ direction="horizontal"
12
+ :gap="6"
13
+ tag="nav">
14
+ <slot/>
15
+ </FluxStack>
16
+ </template>
17
+
18
+ <script
19
+ lang="ts"
20
+ setup>
21
+ import { clsx } from 'clsx';
22
+ import FluxStack from './FluxStack.vue';
23
+ import $style from '$flux/css/component/Toolbar.module.scss';
24
+
25
+ defineProps<{
26
+ readonly floatingMode?: 'free' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
27
+ }>();
28
+
29
+ defineSlots<{
30
+ default(): any;
31
+ }>();
32
+ </script>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <FluxStack
3
+ direction="horizontal"
4
+ :gap="3"
5
+ tag="nav">
6
+ <slot/>
7
+ </FluxStack>
8
+ </template>
9
+
10
+ <script
11
+ lang="ts"
12
+ setup>
13
+ import FluxStack from './FluxStack.vue';
14
+
15
+ defineSlots<{
16
+ default(): any;
17
+ }>();
18
+ </script>
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { defineComponent, getCurrentInstance, onMounted, onUnmounted, PropType, ref, SlotsType, VNode } from 'vue';
3
+ import { addTooltip, removeTooltip } from '$flux/data';
4
+
5
+ export default defineComponent({
6
+ props: {
7
+ content: String as PropType<string | undefined>,
8
+ direction: String as PropType<'horizontal' | 'vertical'>
9
+ },
10
+ slots: Object as SlotsType<{
11
+ content: () => VNode[],
12
+ default: () => VNode[],
13
+ }>,
14
+ setup(props, {slots}) {
15
+ const instance = getCurrentInstance()!;
16
+
17
+ const tooltipId = ref<number | null>(null);
18
+
19
+ onMounted(() => {
20
+ const elm = instance.proxy!.$el;
21
+ elm.addEventListener('mouseenter', onHover, {passive: true});
22
+ elm.addEventListener('mouseleave', onLeave, {passive: true});
23
+ });
24
+
25
+ onUnmounted(() => {
26
+ const elm = instance.proxy!.$el;
27
+ elm.removeEventListener('mouseenter', onHover);
28
+ elm.removeEventListener('mouseleave', onLeave);
29
+ onLeave();
30
+ });
31
+
32
+ function onHover(): void {
33
+ onLeave();
34
+
35
+ if ((props.content?.trim().length ?? 0) === 0 && !slots.content) {
36
+ return;
37
+ }
38
+
39
+ tooltipId.value = addTooltip({
40
+ content: props.content,
41
+ contentSlot: slots.content,
42
+ direction: props.direction || 'vertical',
43
+ origin: instance.proxy?.$el
44
+ });
45
+ }
46
+
47
+ function onLeave(): void {
48
+ if (tooltipId.value) {
49
+ removeTooltip(tooltipId.value);
50
+ }
51
+ }
52
+
53
+ return () => (slots.default?.() ?? [])[0] ?? null;
54
+ }
55
+ });
56
+ </script>
@@ -0,0 +1,176 @@
1
+ <script lang="ts">
2
+ import { unrefTemplateElement } from '@flux-ui/internals';
3
+ import { clsx } from 'clsx';
4
+ import { computed, defineComponent, h, ref, unref, watch } from 'vue';
5
+ import { useFluxStore } from '$flux/data';
6
+ import { FluxTooltipTransition } from '$flux/transition';
7
+ import $style from '$flux/css/component/Tooltip.module.scss';
8
+
9
+ type Transition = 'above' | 'below' | 'end' | 'start';
10
+
11
+ type PositionData = {
12
+ readonly x: number;
13
+ readonly y: number;
14
+ readonly arrowAngle: string;
15
+ readonly arrowX: string;
16
+ readonly arrowY: string;
17
+ readonly transition: Transition;
18
+ };
19
+
20
+ export default defineComponent(() => {
21
+ const {tooltip} = useFluxStore();
22
+
23
+ const elementRef = ref<HTMLElement | null>(null);
24
+ const position = ref<PositionData | null>(null);
25
+
26
+ const content = computed(() => unref(tooltip) ? unref(tooltip)!.contentSlot?.() ?? [unref(tooltip)!.content] : null);
27
+ const has = computed(() => !!unref(tooltip));
28
+
29
+ function calculate(): void {
30
+ const element = unrefTemplateElement(elementRef);
31
+ const spec = unref(tooltip);
32
+
33
+ if (!spec || !element || !unref(content)) {
34
+ position.value = null;
35
+ return;
36
+ }
37
+
38
+ const {direction, origin} = spec;
39
+ const margin = 9;
40
+ const safeZone = 15;
41
+
42
+ if (!origin) {
43
+ position.value = null;
44
+ return;
45
+ }
46
+
47
+ let {width, height} = element.getBoundingClientRect();
48
+ const {scale} = getComputedStyle(element);
49
+ const {top, left, width: originWidth, height: originHeight} = origin.getBoundingClientRect();
50
+
51
+ let s = Number(scale ?? 1);
52
+ s = isNaN(s) ? 1 : s;
53
+ height /= s;
54
+ width /= s;
55
+
56
+ if (direction === 'horizontal') {
57
+ position.value = calculateHorizontalPosition(top, left, width, height, originWidth, originHeight, margin, safeZone);
58
+ } else {
59
+ position.value = calculateVerticalPosition(top, left, width, height, originWidth, originHeight, margin, safeZone);
60
+ }
61
+ }
62
+
63
+ watch(content, () => requestAnimationFrame(() => calculate()));
64
+
65
+ return () => h(FluxTooltipTransition, {}, {
66
+ default: () => {
67
+ if (!unref(has)) {
68
+ return;
69
+ }
70
+
71
+ const pos = unref(position);
72
+
73
+ return h('div', {
74
+ ref: elementRef,
75
+ class: pos
76
+ ? clsx(
77
+ pos.transition === 'above' && $style.tooltipAbove,
78
+ pos.transition === 'below' && $style.tooltipBelow,
79
+ pos.transition === 'end' && $style.tooltipEnd,
80
+ pos.transition === 'start' && $style.tooltipStart
81
+ )
82
+ : $style.tooltip,
83
+ style: {
84
+ '--x': pos?.x ?? undefined,
85
+ '--y': pos?.y ?? undefined,
86
+ '--arrowAngle': pos?.arrowAngle ?? undefined,
87
+ '--arrowX': pos?.arrowX ?? undefined,
88
+ '--arrowY': pos?.arrowY ?? undefined
89
+ }
90
+ }, unref(content));
91
+ }
92
+ });
93
+ });
94
+
95
+ function calculateHorizontalPosition(top: number, left: number, width: number, height: number, originWidth: number, originHeight: number, margin: number, safeZone: number): PositionData {
96
+ let x, y, arrowAngle, arrowX, arrowY, transition: Transition;
97
+
98
+ if (left > innerWidth / 2) {
99
+ x = left - width - margin;
100
+ y = top + originHeight / 2 - height / 2;
101
+ arrowAngle = '315deg';
102
+ arrowX = '100%';
103
+ arrowY = '50%';
104
+ transition = 'start';
105
+ } else {
106
+ x = left + originWidth + margin;
107
+ y = top + originHeight / 2 - height / 2;
108
+ arrowAngle = '135deg';
109
+ arrowX = '0';
110
+ arrowY = '50%';
111
+ transition = 'end';
112
+ }
113
+
114
+ if (y + height > innerHeight - safeZone) {
115
+ const diff = Math.min(y, innerHeight - height - safeZone) - y;
116
+ arrowY = `calc(50% - ${diff}px)`;
117
+ y += diff;
118
+ }
119
+
120
+ if (y < safeZone) {
121
+ const diff = Math.max(y, safeZone) - y;
122
+ arrowY = `calc(50% - ${diff}px)`;
123
+ y += diff;
124
+ }
125
+
126
+ return {
127
+ x: Math.round(x),
128
+ y: Math.round(y),
129
+ arrowAngle,
130
+ arrowX,
131
+ arrowY,
132
+ transition
133
+ };
134
+ }
135
+
136
+ function calculateVerticalPosition(top: number, left: number, width: number, height: number, originWidth: number, originHeight: number, margin: number, safeZone: number): PositionData {
137
+ let x, y, arrowAngle, arrowX, arrowY, transition: Transition;
138
+
139
+ if (top > 300) {
140
+ x = left + originWidth / 2 - width / 2;
141
+ y = top - height - margin;
142
+ arrowAngle = '45deg';
143
+ arrowX = '50%';
144
+ arrowY = '100%';
145
+ transition = 'above';
146
+ } else {
147
+ x = left + originWidth / 2 - width / 2;
148
+ y = top + originHeight + margin;
149
+ arrowAngle = '225deg';
150
+ arrowX = '50%';
151
+ arrowY = '0';
152
+ transition = 'below';
153
+ }
154
+
155
+ if (x + width > innerWidth - safeZone) {
156
+ const diff = Math.min(x, innerWidth - width - safeZone) - x;
157
+ arrowX = `calc(50% - ${diff}px)`;
158
+ x += diff;
159
+ }
160
+
161
+ if (x < safeZone) {
162
+ const diff = Math.max(x, safeZone) - x;
163
+ arrowX = `calc(50% - ${diff}px)`;
164
+ x += diff;
165
+ }
166
+
167
+ return {
168
+ x: Math.round(x),
169
+ y: Math.round(y),
170
+ arrowAngle,
171
+ arrowX,
172
+ arrowY,
173
+ transition
174
+ };
175
+ }
176
+ </script>
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <FluxWindowTransition :is-back="isBack">
3
+ <template v-for="(_, slot) of slots">
4
+ <slot
5
+ v-if="slot === view"
6
+ v-bind="{back, navigate}"
7
+ :name="slot"/>
8
+ </template>
9
+ </FluxWindowTransition>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import { ref } from 'vue';
16
+ import { FluxWindowTransition } from '$flux/transition';
17
+
18
+ const slots = defineSlots<{
19
+ default(props: {
20
+ back(to?: string): void;
21
+ navigate(to: string): void;
22
+ }): any;
23
+
24
+ [key: string]: (props: {
25
+ back(to?: string): void;
26
+ navigate(to: string): void;
27
+ }) => any;
28
+ }>();
29
+
30
+ const isBack = ref(false);
31
+ const view = ref<string>('default');
32
+
33
+ function back(to: string = 'default'): void {
34
+ isBack.value = true;
35
+ view.value = to;
36
+ }
37
+
38
+ function navigate(to: string): void {
39
+ isBack.value = false;
40
+ view.value = to;
41
+ }
42
+
43
+ defineExpose({
44
+ back,
45
+ navigate
46
+ });
47
+ </script>