@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.
- package/README.md +45 -0
- package/package.json +77 -0
- package/src/component/FluxAction.vue +27 -0
- package/src/component/FluxActionBar.vue +94 -0
- package/src/component/FluxActionPane.vue +40 -0
- package/src/component/FluxActions.vue +27 -0
- package/src/component/FluxAlert.vue +37 -0
- package/src/component/FluxAnimatedColors.vue +141 -0
- package/src/component/FluxAspectRatio.vue +21 -0
- package/src/component/FluxAutoGrid.vue +27 -0
- package/src/component/FluxAvatar.vue +119 -0
- package/src/component/FluxBadge.vue +84 -0
- package/src/component/FluxBadgeStack.vue +18 -0
- package/src/component/FluxBorderShine.vue +36 -0
- package/src/component/FluxBoxedIcon.vue +36 -0
- package/src/component/FluxButton.vue +110 -0
- package/src/component/FluxButtonGroup.vue +15 -0
- package/src/component/FluxButtonStack.vue +28 -0
- package/src/component/FluxCalendar.vue +254 -0
- package/src/component/FluxCalendarEvent.vue +41 -0
- package/src/component/FluxCheckbox.vue +60 -0
- package/src/component/FluxChip.vue +57 -0
- package/src/component/FluxClickablePane.vue +61 -0
- package/src/component/FluxColorPicker.vue +265 -0
- package/src/component/FluxColorSelect.vue +81 -0
- package/src/component/FluxComment.vue +71 -0
- package/src/component/FluxConfirm.vue +42 -0
- package/src/component/FluxContainer.vue +23 -0
- package/src/component/FluxDataTable.vue +96 -0
- package/src/component/FluxDatePicker.vue +353 -0
- package/src/component/FluxDestructiveButton.vue +28 -0
- package/src/component/FluxDisabled.vue +22 -0
- package/src/component/FluxDivider.vue +37 -0
- package/src/component/FluxDotPattern.vue +72 -0
- package/src/component/FluxDropZone.vue +202 -0
- package/src/component/FluxDynamicView.vue +16 -0
- package/src/component/FluxExpandable.vue +119 -0
- package/src/component/FluxExpandableGroup.vue +53 -0
- package/src/component/FluxFader.vue +64 -0
- package/src/component/FluxFaderItem.vue +15 -0
- package/src/component/FluxFilter.vue +133 -0
- package/src/component/FluxFilterDate.vue +58 -0
- package/src/component/FluxFilterDateRange.vue +59 -0
- package/src/component/FluxFilterOption.vue +49 -0
- package/src/component/FluxFilterOptionAsync.vue +103 -0
- package/src/component/FluxFilterOptions.vue +62 -0
- package/src/component/FluxFilterOptionsAsync.vue +113 -0
- package/src/component/FluxFilterRange.vue +91 -0
- package/src/component/FluxFlickeringGrid.vue +141 -0
- package/src/component/FluxFlyout.vue +205 -0
- package/src/component/FluxFocalPointEditor.vue +137 -0
- package/src/component/FluxFocalPointImage.vue +29 -0
- package/src/component/FluxForm.vue +35 -0
- package/src/component/FluxFormColumn.vue +15 -0
- package/src/component/FluxFormDateInput.vue +92 -0
- package/src/component/FluxFormDateRangeInput.vue +87 -0
- package/src/component/FluxFormDateTimeInput.vue +120 -0
- package/src/component/FluxFormField.vue +98 -0
- package/src/component/FluxFormFieldAddition.vue +37 -0
- package/src/component/FluxFormInput.vue +223 -0
- package/src/component/FluxFormInputAddition.vue +31 -0
- package/src/component/FluxFormInputGroup.vue +25 -0
- package/src/component/FluxFormPinInput.vue +135 -0
- package/src/component/FluxFormRangeSlider.vue +179 -0
- package/src/component/FluxFormRow.vue +15 -0
- package/src/component/FluxFormSection.vue +23 -0
- package/src/component/FluxFormSelect.vue +59 -0
- package/src/component/FluxFormSelectAsync.vue +118 -0
- package/src/component/FluxFormSlider.vue +123 -0
- package/src/component/FluxFormTextArea.vue +53 -0
- package/src/component/FluxFormTimeZonePicker.vue +713 -0
- package/src/component/FluxGallery.vue +99 -0
- package/src/component/FluxGalleryItem.vue +49 -0
- package/src/component/FluxGrid.vue +28 -0
- package/src/component/FluxGridColumn.vue +31 -0
- package/src/component/FluxGridPattern.vue +60 -0
- package/src/component/FluxIcon.vue +79 -0
- package/src/component/FluxInfo.vue +28 -0
- package/src/component/FluxInfoStack.vue +17 -0
- package/src/component/FluxLegend.vue +27 -0
- package/src/component/FluxLink.vue +35 -0
- package/src/component/FluxMenu.vue +31 -0
- package/src/component/FluxMenuGroup.vue +21 -0
- package/src/component/FluxMenuItem.vue +84 -0
- package/src/component/FluxMenuOptions.vue +38 -0
- package/src/component/FluxMenuSubHeader.vue +33 -0
- package/src/component/FluxMenuTitle.vue +17 -0
- package/src/component/FluxNotice.vue +79 -0
- package/src/component/FluxNoticeStack.vue +17 -0
- package/src/component/FluxOverlay.vue +31 -0
- package/src/component/FluxPagination.vue +148 -0
- package/src/component/FluxPaginationBar.vue +81 -0
- package/src/component/FluxPane.vue +45 -0
- package/src/component/FluxPaneBody.vue +15 -0
- package/src/component/FluxPaneDeck.vue +24 -0
- package/src/component/FluxPaneFooter.vue +15 -0
- package/src/component/FluxPaneGroup.vue +15 -0
- package/src/component/FluxPaneHeader.vue +44 -0
- package/src/component/FluxPaneIllustration.vue +68 -0
- package/src/component/FluxPaneMedia.vue +31 -0
- package/src/component/FluxPercentageBar.vue +45 -0
- package/src/component/FluxPersona.vue +48 -0
- package/src/component/FluxPlaceholder.vue +56 -0
- package/src/component/FluxPressable.vue +77 -0
- package/src/component/FluxPrimaryButton.vue +28 -0
- package/src/component/FluxProgressBar.vue +75 -0
- package/src/component/FluxPrompt.vue +77 -0
- package/src/component/FluxPublishButton.vue +59 -0
- package/src/component/FluxQuantitySelector.vue +109 -0
- package/src/component/FluxRemove.vue +34 -0
- package/src/component/FluxRoot.vue +60 -0
- package/src/component/FluxSecondaryButton.vue +28 -0
- package/src/component/FluxSegmentedControl.vue +77 -0
- package/src/component/FluxSegmentedView.vue +15 -0
- package/src/component/FluxSeparator.vue +19 -0
- package/src/component/FluxSlideOver.vue +25 -0
- package/src/component/FluxSnackbar.vue +154 -0
- package/src/component/FluxSnackbarProvider.vue +34 -0
- package/src/component/FluxSpacer.vue +9 -0
- package/src/component/FluxSpacing.vue +32 -0
- package/src/component/FluxSpinner.vue +48 -0
- package/src/component/FluxSplitButton.vue +61 -0
- package/src/component/FluxStack.vue +40 -0
- package/src/component/FluxStatistic.vue +68 -0
- package/src/component/FluxStepper.vue +69 -0
- package/src/component/FluxStepperStep.vue +15 -0
- package/src/component/FluxStepperSteps.vue +62 -0
- package/src/component/FluxTab.vue +23 -0
- package/src/component/FluxTabBar.vue +87 -0
- package/src/component/FluxTabBarItem.vue +104 -0
- package/src/component/FluxTable.vue +68 -0
- package/src/component/FluxTableActions.vue +16 -0
- package/src/component/FluxTableCell.vue +47 -0
- package/src/component/FluxTableHeader.vue +111 -0
- package/src/component/FluxTableRow.vue +15 -0
- package/src/component/FluxTabs.vue +91 -0
- package/src/component/FluxTag.vue +85 -0
- package/src/component/FluxTagStack.vue +18 -0
- package/src/component/FluxTicks.vue +44 -0
- package/src/component/FluxTimeline.vue +17 -0
- package/src/component/FluxTimelineItem.vue +73 -0
- package/src/component/FluxToggle.vue +64 -0
- package/src/component/FluxToolbar.vue +32 -0
- package/src/component/FluxToolbarGroup.vue +18 -0
- package/src/component/FluxTooltip.vue +56 -0
- package/src/component/FluxTooltipProvider.vue +176 -0
- package/src/component/FluxWindow.vue +47 -0
- package/src/component/index.ts +142 -0
- package/src/component/primitive/Anchor.vue +17 -0
- package/src/component/primitive/AnchorPopup.vue +194 -0
- package/src/component/primitive/CoordinatePicker.vue +155 -0
- package/src/component/primitive/CoordinatePickerThumb.vue +71 -0
- package/src/component/primitive/FilterItem.vue +44 -0
- package/src/component/primitive/FilterMenuRenderer.ts +233 -0
- package/src/component/primitive/FilterOptionBase.vue +67 -0
- package/src/component/primitive/SelectBase.vue +340 -0
- package/src/component/primitive/SliderBase.vue +89 -0
- package/src/component/primitive/SliderThumb.vue +64 -0
- package/src/component/primitive/SliderTrack.vue +22 -0
- package/src/component/primitive/VNodeRenderer.ts +11 -0
- package/src/component/primitive/index.ts +10 -0
- package/src/composable/index.ts +9 -0
- package/src/composable/private/index.ts +3 -0
- package/src/composable/private/useFormSelect.ts +66 -0
- package/src/composable/private/useLoaded.ts +21 -0
- package/src/composable/private/useTranslate.ts +35 -0
- package/src/composable/useBreakpoints.ts +54 -0
- package/src/composable/useDisabled.ts +9 -0
- package/src/composable/useDisabledInjection.ts +6 -0
- package/src/composable/useExpandableGroupInjection.ts +10 -0
- package/src/composable/useFilterInjection.ts +22 -0
- package/src/composable/useFlyoutInjection.ts +10 -0
- package/src/composable/useFormFieldInjection.ts +8 -0
- package/src/composable/useTableInjection.ts +11 -0
- package/src/css/base.scss +33 -0
- package/src/css/component/Action.module.scss +107 -0
- package/src/css/component/Avatar.module.scss +177 -0
- package/src/css/component/Badge.module.scss +189 -0
- package/src/css/component/Button.module.scss +293 -0
- package/src/css/component/Calendar.module.scss +171 -0
- package/src/css/component/Chip.module.scss +58 -0
- package/src/css/component/Color.module.scss +184 -0
- package/src/css/component/Comment.module.scss +123 -0
- package/src/css/component/DatePicker.module.scss +193 -0
- package/src/css/component/Divider.module.scss +79 -0
- package/src/css/component/DropZone.module.scss +99 -0
- package/src/css/component/Expandable.module.scss +112 -0
- package/src/css/component/Fader.module.scss +38 -0
- package/src/css/component/Filter.module.scss +80 -0
- package/src/css/component/Flyout.module.scss +63 -0
- package/src/css/component/FocalPoint.module.scss +84 -0
- package/src/css/component/Form.module.scss +812 -0
- package/src/css/component/Gallery.module.scss +64 -0
- package/src/css/component/Grid.module.scss +24 -0
- package/src/css/component/Icon.module.scss +104 -0
- package/src/css/component/Info.module.scss +15 -0
- package/src/css/component/Layout.module.scss +63 -0
- package/src/css/component/Legend.module.scss +32 -0
- package/src/css/component/Menu.module.scss +314 -0
- package/src/css/component/Notice.module.scss +279 -0
- package/src/css/component/Overlay.module.scss +149 -0
- package/src/css/component/Pagination.module.scss +59 -0
- package/src/css/component/Pane.module.scss +218 -0
- package/src/css/component/PercentageBar.module.scss +31 -0
- package/src/css/component/Placeholder.module.scss +72 -0
- package/src/css/component/Progress.module.scss +84 -0
- package/src/css/component/Remove.module.scss +29 -0
- package/src/css/component/Root.module.scss +8 -0
- package/src/css/component/SegmentedControl.module.scss +82 -0
- package/src/css/component/Snackbar.module.scss +227 -0
- package/src/css/component/Spinner.module.scss +36 -0
- package/src/css/component/Statistic.module.scss +118 -0
- package/src/css/component/Stepper.module.scss +103 -0
- package/src/css/component/Tab.module.scss +162 -0
- package/src/css/component/Table.module.scss +164 -0
- package/src/css/component/Timeline.module.scss +173 -0
- package/src/css/component/Toolbar.module.scss +82 -0
- package/src/css/component/Tooltip.module.scss +62 -0
- package/src/css/component/Transition.module.scss +142 -0
- package/src/css/component/Visual.module.scss +70 -0
- package/src/css/component/base/Button.module.scss +87 -0
- package/src/css/component/base/Effect.module.scss +139 -0
- package/src/css/component/base/Grid.module.scss +8 -0
- package/src/css/component/base/Pane.module.scss +54 -0
- package/src/css/component/primitive/CoordinatePicker.module.scss +24 -0
- package/src/css/component/primitive/Slider.module.scss +116 -0
- package/src/css/index.scss +5 -0
- package/src/css/layers.scss +1 -0
- package/src/css/mixin/breakpoints.scss +112 -0
- package/src/css/mixin/focus-ring.scss +56 -0
- package/src/css/mixin/hover.scss +7 -0
- package/src/css/mixin/index.scss +3 -0
- package/src/css/reset.scss +169 -0
- package/src/css/typography.scss +87 -0
- package/src/css/variables.scss +214 -0
- package/src/data/di.ts +42 -0
- package/src/data/filter.ts +9 -0
- package/src/data/helper.ts +9 -0
- package/src/data/i18n.ts +55 -0
- package/src/data/iconRegistry.ts +21 -0
- package/src/data/index.ts +8 -0
- package/src/data/inputMask.ts +34 -0
- package/src/data/store.ts +233 -0
- package/src/image/avatar-mask.svg +3 -0
- package/src/index.ts +25 -0
- package/src/transition/FluxAutoHeightTransition.vue +59 -0
- package/src/transition/FluxAutoWidthTransition.vue +59 -0
- package/src/transition/FluxBreakthroughTransition.vue +23 -0
- package/src/transition/FluxFadeTransition.vue +24 -0
- package/src/transition/FluxOverlayTransition.vue +22 -0
- package/src/transition/FluxRouteTransition.vue +23 -0
- package/src/transition/FluxSlideOverTransition.vue +22 -0
- package/src/transition/FluxTooltipTransition.vue +22 -0
- package/src/transition/FluxVerticalWindowTransition.vue +23 -0
- package/src/transition/FluxWindowTransition.vue +23 -0
- package/src/transition/index.ts +10 -0
- package/src/util/createDialogRenderer.ts +64 -0
- package/src/util/createLabelForDateRange.ts +61 -0
- package/src/util/index.ts +2 -0
- package/src/vite.d.ts +13 -0
- 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,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>
|