@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,205 @@
1
+ <template>
2
+ <div
3
+ ref="mount"
4
+ :class="$style.flyout"
5
+ :style="{
6
+ '--opener-width': `${openerWidth}px`,
7
+ '--pane-mx': `${paneMarginX}px`,
8
+ '--pane-my': `${paneMarginY}px`,
9
+ '--pane-x': `${paneX - 12}px`,
10
+ '--pane-y': `${paneY - 12}px`
11
+ }">
12
+ <slot
13
+ name="opener"
14
+ v-bind="{close, open, toggle}"/>
15
+
16
+ <dialog
17
+ ref="dialog"
18
+ :class="$style.flyoutDialog"
19
+ @click="onDialogBackdropClick"
20
+ @keydown.prevent.esc="close">
21
+ <FluxPane
22
+ v-if="isOpen"
23
+ ref="pane"
24
+ :class="clsx(
25
+ $style.flyoutPane,
26
+ isAutoWidth && $style.isAutoWidth,
27
+ isClosing && $style.isClosing,
28
+ isOpening && $style.isOpening
29
+ )"
30
+ :style="{
31
+ width: `${width}px`
32
+ }">
33
+ <slot v-bind="{close, paneX, paneY, openerWidth, openerHeight}"/>
34
+ </FluxPane>
35
+ </dialog>
36
+ </div>
37
+ </template>
38
+
39
+ <script
40
+ lang="ts"
41
+ setup>
42
+ import { unrefTemplateElement, useFocusTrap } from '@flux-ui/internals';
43
+ import type { FluxDirection } from '@flux-ui/types';
44
+ import { clsx } from 'clsx';
45
+ import { provide, ref, unref, useTemplateRef, watch } from 'vue';
46
+ import { FluxFlyoutInjectionKey } from '$flux/data';
47
+ import FluxPane from './FluxPane.vue';
48
+ import $style from '$flux/css/component/Flyout.module.scss';
49
+
50
+ const {
51
+ direction = 'vertical',
52
+ margin = 9
53
+ } = defineProps<{
54
+ readonly direction?: FluxDirection;
55
+ readonly isAutoWidth?: boolean;
56
+ readonly margin?: number;
57
+ readonly width?: number | string;
58
+ }>();
59
+
60
+ defineSlots<{
61
+ default(props: {
62
+ close(): void;
63
+
64
+ readonly paneX: number;
65
+ readonly paneY: number;
66
+ readonly openerWidth: number;
67
+ readonly openerHeight: number;
68
+ }): any;
69
+
70
+ opener(props: {
71
+ close(): void;
72
+ open(): void;
73
+ toggle(): void;
74
+ }): any;
75
+ }>();
76
+
77
+ const dialogRef = useTemplateRef('dialog');
78
+ const mountRef = useTemplateRef('mount');
79
+ const paneRef = useTemplateRef('pane');
80
+
81
+ const isClosing = ref(false);
82
+ const isOpening = ref(false);
83
+ const isOpen = ref(false);
84
+ const openerWidth = ref(0);
85
+ const openerHeight = ref(0);
86
+ const paneX = ref(0);
87
+ const paneY = ref(0);
88
+ const paneMarginX = ref(0);
89
+ const paneMarginY = ref(0);
90
+
91
+ useFocusTrap(paneRef);
92
+
93
+ function close(): void {
94
+ const pane = unrefTemplateElement(paneRef);
95
+
96
+ if (!pane) {
97
+ return;
98
+ }
99
+
100
+ pane.addEventListener('animationend', () => {
101
+ isClosing.value = false;
102
+ isOpen.value = false;
103
+ }, {once: true});
104
+
105
+ isClosing.value = true;
106
+ }
107
+
108
+ function open(): void {
109
+ const mount = unref(mountRef)!;
110
+ const {width, height} = mount.children[0].getBoundingClientRect();
111
+
112
+ isOpen.value = true;
113
+ openerWidth.value = width;
114
+ openerHeight.value = height;
115
+
116
+ requestAnimationFrame(() => {
117
+ const pane = unrefTemplateElement(paneRef)!;
118
+
119
+ pane.addEventListener('animationend', () => {
120
+ isOpening.value = false;
121
+ }, {once: true});
122
+
123
+ isOpening.value = true;
124
+ });
125
+
126
+ requestAnimationFrame(reposition);
127
+ }
128
+
129
+ function reposition(): void {
130
+ const mount = unref(mountRef)!;
131
+ const pane = unrefTemplateElement(paneRef)!;
132
+ const {top, left, width, height} = mount.children[0].getBoundingClientRect();
133
+ const {width: paneWidth, height: paneHeight} = pane.getBoundingClientRect();
134
+
135
+ let x, y, mx = 0, my = 0;
136
+
137
+ if (direction === 'horizontal') {
138
+ x = left + width;
139
+ y = top + height / 2 - paneHeight / 2;
140
+ mx = margin;
141
+
142
+ if (x + paneWidth > innerWidth - 30) {
143
+ x = left - paneWidth;
144
+ mx = -mx;
145
+ }
146
+ } else {
147
+ x = left + width / 2 - paneWidth / 2;
148
+ y = top + height;
149
+ my = margin;
150
+
151
+ if (y + paneHeight > innerHeight - 30) {
152
+ y = top - paneHeight;
153
+ my = -my;
154
+ }
155
+ }
156
+
157
+ paneX.value = Math.max(30, Math.min(innerWidth - paneWidth - 30, x));
158
+ paneY.value = Math.max(30, Math.min(innerHeight - paneHeight - 30, y));
159
+ paneMarginX.value = mx;
160
+ paneMarginY.value = my;
161
+ }
162
+
163
+ function toggle(): void {
164
+ if (isOpen.value) {
165
+ close();
166
+ } else {
167
+ open();
168
+ }
169
+ }
170
+
171
+ function onDialogBackdropClick(evt: Event): void {
172
+ const target = evt.target as HTMLElement;
173
+
174
+ if (target.tagName !== 'DIALOG') {
175
+ return;
176
+ }
177
+
178
+ close();
179
+ }
180
+
181
+ watch(isOpen, (isOpen, _, onCleanup) => {
182
+ const dialog = unref(dialogRef)!;
183
+
184
+ if (isOpen && !dialog.open) {
185
+ dialog.showModal();
186
+
187
+ window.addEventListener('scroll', reposition, {passive: true});
188
+ onCleanup(() => window.removeEventListener('scroll', reposition));
189
+ } else if (!isOpen && dialog.open) {
190
+ dialog.close();
191
+ }
192
+ });
193
+
194
+ provide(FluxFlyoutInjectionKey, {
195
+ isClosing,
196
+ isOpen,
197
+ isOpening
198
+ });
199
+
200
+ defineExpose({
201
+ close,
202
+ open,
203
+ toggle
204
+ });
205
+ </script>
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <FluxPane :style="{'--aspect-ratio': aspectRatio}">
3
+ <FluxFadeTransition mode="out-in">
4
+ <FluxPaneBody
5
+ v-if="isPreviewing"
6
+ key="preview">
7
+ <div :class="$style.focalPointPreview">
8
+ <div
9
+ :class="$style.focalPointPreviewImage"
10
+ :style="{
11
+ backgroundImage: `url(${src})`,
12
+ backgroundPosition: `${focalPointX}% ${focalPointY}%`
13
+ }"/>
14
+ </div>
15
+ </FluxPaneBody>
16
+
17
+ <FluxPaneBody
18
+ v-else
19
+ key="editor">
20
+ <div
21
+ :class="$style.focalPointEditor"
22
+ @pointerdown="onPointerDown"
23
+ @pointermove="onPointerMove">
24
+ <img
25
+ ref="image"
26
+ :class="$style.focalPointEditorImage"
27
+ :src="src"
28
+ alt=""
29
+ @load="onImageLoaded"/>
30
+
31
+ <div
32
+ :class="$style.focalPointEditorArea"
33
+ :style="{
34
+ top: `${focalPointY}%`,
35
+ left: `${focalPointX}%`
36
+ }"/>
37
+ </div>
38
+ </FluxPaneBody>
39
+ </FluxFadeTransition>
40
+
41
+ <FluxPaneFooter>
42
+ <slot name="footer-before"/>
43
+
44
+ <FluxSecondaryButton
45
+ :label="translate(isPreviewing ? 'flux.previewClose' : 'flux.preview')"
46
+ @click="onShowPreviewClicked"/>
47
+
48
+ <FluxSpacer/>
49
+
50
+ <slot name="footer"/>
51
+ </FluxPaneFooter>
52
+ </FluxPane>
53
+ </template>
54
+
55
+ <script
56
+ lang="ts"
57
+ setup>
58
+ import { computed, onMounted, onUnmounted, ref, unref, useTemplateRef, watch } from 'vue';
59
+ import { useTranslate } from '$flux/composable/private';
60
+ import { FluxFadeTransition } from '$flux/transition';
61
+ import FluxPane from './FluxPane.vue';
62
+ import FluxPaneBody from './FluxPaneBody.vue';
63
+ import FluxPaneFooter from './FluxPaneFooter.vue';
64
+ import FluxSecondaryButton from './FluxSecondaryButton.vue';
65
+ import FluxSpacer from './FluxSpacer.vue';
66
+ import $style from '$flux/css/component/FocalPoint.module.scss';
67
+
68
+ const modelValue = defineModel<[number, number]>({
69
+ required: true
70
+ });
71
+
72
+ const {
73
+ src
74
+ } = defineProps<{
75
+ readonly src: string;
76
+ }>();
77
+
78
+ const imageRef = useTemplateRef('image');
79
+ const translate = useTranslate();
80
+
81
+ const aspectRatio = ref(1);
82
+ const dragging = ref<[number, number] | null>(null);
83
+ const isPreviewing = ref(false);
84
+
85
+ const focalPointX = computed(() => unref(dragging) ? unref(dragging)![0] : unref(modelValue)[0]);
86
+ const focalPointY = computed(() => unref(dragging) ? unref(dragging)![1] : unref(modelValue)[1]);
87
+
88
+ onMounted(() => window.addEventListener('pointerup', onPointerUp, {passive: true}));
89
+
90
+ onUnmounted(() => window.removeEventListener('pointerup', onPointerUp));
91
+
92
+ function onImageLoaded(): void {
93
+ const image = unref(imageRef);
94
+
95
+ if (!image) {
96
+ return;
97
+ }
98
+
99
+ aspectRatio.value = image.width / image.height;
100
+ }
101
+
102
+ function onPointerDown(evt: PointerEvent): void {
103
+ dragging.value = [0, 0];
104
+ onPointerMove(evt);
105
+ }
106
+
107
+ function onPointerMove(evt: PointerEvent): void {
108
+ const image = unref(imageRef);
109
+
110
+ if (!image || !dragging.value) {
111
+ return;
112
+ }
113
+
114
+ const {top, left, width, height} = image.getBoundingClientRect();
115
+ const {pageX, pageY} = evt;
116
+
117
+ dragging.value = [
118
+ Math.max(0, Math.min(1, (pageX - left) / width)) * 100,
119
+ Math.max(0, Math.min(1, (pageY - top) / height)) * 100
120
+ ];
121
+ }
122
+
123
+ function onPointerUp(): void {
124
+ if (!dragging.value) {
125
+ return;
126
+ }
127
+
128
+ modelValue.value = dragging.value!;
129
+ dragging.value = null;
130
+ }
131
+
132
+ function onShowPreviewClicked(): void {
133
+ isPreviewing.value = !isPreviewing.value;
134
+ }
135
+
136
+ watch(() => src, () => isPreviewing.value = false);
137
+ </script>
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <img
3
+ :class="$style.focalPointImage"
4
+ :style="{
5
+ objectPosition: `${x}% ${y}%`
6
+ }"
7
+ :src="src"
8
+ :alt="alt"/>
9
+ </template>
10
+
11
+ <script
12
+ lang="ts"
13
+ setup>
14
+ import type { FluxFocalPointObject } from '@flux-ui/types';
15
+ import { computed } from 'vue';
16
+ import $style from '$flux/css/component/FocalPoint.module.scss';
17
+
18
+ const {
19
+ alt = '',
20
+ focalPoint
21
+ } = defineProps<{
22
+ readonly focalPoint?: FluxFocalPointObject;
23
+ readonly alt?: string;
24
+ readonly src: string;
25
+ }>();
26
+
27
+ const x = computed(() => focalPoint?.x ?? 50);
28
+ const y = computed(() => focalPoint?.y ?? 50);
29
+ </script>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <FluxDisabled :disabled="disabled">
3
+ <form
4
+ :class="$style.form"
5
+ :aria-disabled="disabled ? true : undefined"
6
+ @submit.prevent="onSubmit()">
7
+ <slot/>
8
+ </form>
9
+ </FluxDisabled>
10
+ </template>
11
+
12
+ <script
13
+ lang="ts"
14
+ setup>
15
+ import FluxDisabled from './FluxDisabled.vue';
16
+ import $style from '$flux/css/component/Form.module.scss';
17
+
18
+ const emit = defineEmits<{
19
+ submit: [];
20
+ }>();
21
+
22
+ const {
23
+ disabled = false
24
+ } = defineProps<{
25
+ readonly disabled?: boolean;
26
+ }>();
27
+
28
+ defineSlots<{
29
+ default(): any;
30
+ }>();
31
+
32
+ function onSubmit(): void {
33
+ emit('submit');
34
+ }
35
+ </script>
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <div :class="$style.formColumn">
3
+ <slot/>
4
+ </div>
5
+ </template>
6
+
7
+ <script
8
+ lang="ts"
9
+ setup>
10
+ import $style from '$flux/css/component/Form.module.scss';
11
+
12
+ defineSlots<{
13
+ default(): any;
14
+ }>();
15
+ </script>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <FluxFlyout
3
+ ref="flyout"
4
+ :width="300">
5
+ <template #opener="{open}">
6
+ <FluxFormInputGroup>
7
+ <FluxFormInput
8
+ :="{autoComplete, autoFocus, disabled, isReadonly, modelValue, placeholder}"
9
+ v-model="localValue"
10
+ :class="$style.formDateInput"
11
+ :disabled="disabled"
12
+ :max="max?.toISO()?.substring(0, 10)"
13
+ :min="min?.toISO()?.substring(0, 10)"
14
+ type="date"
15
+ @blur="onBlur()"
16
+ @focus="onFocus()"
17
+ @show-picker="open"/>
18
+
19
+ <FluxSecondaryButton
20
+ :disabled="disabled"
21
+ icon-leading="calendar"
22
+ @click.prevent="open"/>
23
+ </FluxFormInputGroup>
24
+ </template>
25
+
26
+ <FluxDatePicker
27
+ v-model="localValue"
28
+ :max="max"
29
+ :min="min"/>
30
+ </FluxFlyout>
31
+ </template>
32
+
33
+ <script
34
+ lang="ts"
35
+ setup>
36
+ import type { FluxAutoCompleteType } from '@flux-ui/types';
37
+ import type { DateTime } from 'luxon';
38
+ import { ref, toRef, unref, useTemplateRef, watch } from 'vue';
39
+ import { useDisabled } from '$flux/composable';
40
+ import FluxDatePicker from './FluxDatePicker.vue';
41
+ import FluxFlyout from './FluxFlyout.vue';
42
+ import FluxFormInput from './FluxFormInput.vue';
43
+ import FluxFormInputGroup from './FluxFormInputGroup.vue';
44
+ import FluxSecondaryButton from './FluxSecondaryButton.vue';
45
+ import $style from '$flux/css/component/Form.module.scss';
46
+
47
+ const emit = defineEmits<{
48
+ blur: [];
49
+ focus: [];
50
+ }>();
51
+
52
+ const modelValue = defineModel<DateTime | null>({
53
+ default: null
54
+ });
55
+
56
+ const {
57
+ disabled: componentDisabled
58
+ } = defineProps<{
59
+ readonly autoComplete?: FluxAutoCompleteType;
60
+ readonly autoFocus?: boolean;
61
+ readonly disabled?: boolean;
62
+ readonly isReadonly?: boolean;
63
+ readonly max?: DateTime;
64
+ readonly min?: DateTime;
65
+ readonly placeholder?: string;
66
+ }>();
67
+
68
+ const disabled = useDisabled(toRef(() => componentDisabled));
69
+ const flyoutRef = useTemplateRef('flyout');
70
+
71
+ const localValue = ref<DateTime | null>(null);
72
+
73
+ function onBlur(): void {
74
+ emit('blur');
75
+ }
76
+
77
+ function onFocus(): void {
78
+ emit('focus');
79
+ }
80
+
81
+ watch(modelValue, modelValue => localValue.value = modelValue, {immediate: true});
82
+
83
+ watch(localValue, localValue => {
84
+ unref(flyoutRef)?.close();
85
+
86
+ if (modelValue.value?.toISODate() === localValue?.toISODate()) {
87
+ return;
88
+ }
89
+
90
+ modelValue.value = localValue;
91
+ });
92
+ </script>
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <FluxFlyout
3
+ ref="flyout"
4
+ :width="300">
5
+ <template #opener="{open}">
6
+ <FluxFormInputGroup :aria-disabled="disabled ? true : undefined">
7
+ <div
8
+ :class="clsx(
9
+ $style.formDateRangeInput,
10
+ disabled && $style.isDisabled
11
+ )"
12
+ role="presentation">
13
+ <span>{{ label }}</span>
14
+ </div>
15
+
16
+ <FluxSecondaryButton
17
+ :disabled="disabled"
18
+ icon-leading="calendar"
19
+ @click.prevent="open"/>
20
+ </FluxFormInputGroup>
21
+ </template>
22
+
23
+ <FluxDatePicker
24
+ v-model="localValue"
25
+ :max="max"
26
+ :min="min"
27
+ :range-mode="rangeMode"/>
28
+ </FluxFlyout>
29
+ </template>
30
+
31
+ <script
32
+ lang="ts"
33
+ setup>
34
+ import type { FluxAutoCompleteType } from '@flux-ui/types';
35
+ import { clsx } from 'clsx';
36
+ import type { DateTime } from 'luxon';
37
+ import { computed, ref, toRef, unref, useTemplateRef, watch } from 'vue';
38
+ import { useDisabled } from '$flux/composable';
39
+ import { createLabelForDateRange } from '$flux/util';
40
+ import FluxDatePicker from './FluxDatePicker.vue';
41
+ import FluxFlyout from './FluxFlyout.vue';
42
+ import FluxFormInputGroup from './FluxFormInputGroup.vue';
43
+ import FluxSecondaryButton from './FluxSecondaryButton.vue';
44
+ import $style from '$flux/css/component/Form.module.scss';
45
+
46
+ const modelValue = defineModel<[DateTime, DateTime] | null>({
47
+ required: true
48
+ });
49
+
50
+ const {
51
+ disabled: componentDisabled,
52
+ rangeMode = 'range'
53
+ } = defineProps<{
54
+ readonly autoComplete?: FluxAutoCompleteType;
55
+ readonly autoFocus?: boolean;
56
+ readonly disabled?: boolean;
57
+ readonly isReadonly?: boolean;
58
+ readonly max?: DateTime;
59
+ readonly min?: DateTime;
60
+ readonly placeholder?: string;
61
+ readonly rangeMode?: 'range' | 'week' | 'month';
62
+ }>();
63
+
64
+ const disabled = useDisabled(toRef(() => componentDisabled));
65
+ const flyoutRef = useTemplateRef('flyout');
66
+
67
+ const localValue = ref<[DateTime, DateTime] | null>(null);
68
+
69
+ const label = computed(() => {
70
+ const value = unref(localValue);
71
+
72
+ if (!value) {
73
+ return '';
74
+ }
75
+
76
+ const [start, end] = value;
77
+
78
+ return createLabelForDateRange(start, end, true);
79
+ });
80
+
81
+ watch(localValue, localValue => {
82
+ unref(flyoutRef)?.close();
83
+ modelValue.value = localValue;
84
+ });
85
+
86
+ watch(modelValue, modelValue => localValue.value = modelValue, {immediate: true});
87
+ </script>