@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,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FluxStack
|
|
3
|
+
:class="$style.formDateTimeInput"
|
|
4
|
+
direction="horizontal"
|
|
5
|
+
:gap="15"
|
|
6
|
+
:aria-disabled="disabled ? true : undefined">
|
|
7
|
+
<FluxFlyout
|
|
8
|
+
ref="flyout"
|
|
9
|
+
:width="300">
|
|
10
|
+
<template #opener="{open}">
|
|
11
|
+
<FluxFormInputGroup>
|
|
12
|
+
<FluxFormInput
|
|
13
|
+
:="{autoFocus, disabled, isReadonly, modelValue, placeholder}"
|
|
14
|
+
:class="$style.formDateInput"
|
|
15
|
+
:disabled="disabled"
|
|
16
|
+
:model-value="localValue"
|
|
17
|
+
type="date"
|
|
18
|
+
@update:model-value="setDate"
|
|
19
|
+
@show-picker="open"/>
|
|
20
|
+
|
|
21
|
+
<FluxSecondaryButton
|
|
22
|
+
:disabled="disabled"
|
|
23
|
+
icon-leading="calendar"
|
|
24
|
+
@click.prevent="open"/>
|
|
25
|
+
</FluxFormInputGroup>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<FluxDatePicker
|
|
29
|
+
:max="max"
|
|
30
|
+
:min="min"
|
|
31
|
+
:model-value="localValue"
|
|
32
|
+
@update:model-value="setDate"/>
|
|
33
|
+
</FluxFlyout>
|
|
34
|
+
|
|
35
|
+
<FluxFormInput
|
|
36
|
+
:="{disabled, isReadonly, modelValue, placeholder}"
|
|
37
|
+
:class="$style.formTimeInput"
|
|
38
|
+
type="time"
|
|
39
|
+
:model-value="localValue"
|
|
40
|
+
@update:model-value="setTime"/>
|
|
41
|
+
</FluxStack>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script
|
|
45
|
+
lang="ts"
|
|
46
|
+
setup>
|
|
47
|
+
import type { FluxAutoCompleteType } from '@flux-ui/types';
|
|
48
|
+
import { DateTime } from 'luxon';
|
|
49
|
+
import { ref, toRef, unref, useTemplateRef, watch } from 'vue';
|
|
50
|
+
import { useDisabled } from '$flux/composable';
|
|
51
|
+
import FluxDatePicker from './FluxDatePicker.vue';
|
|
52
|
+
import FluxFlyout from './FluxFlyout.vue';
|
|
53
|
+
import FluxFormInput from './FluxFormInput.vue';
|
|
54
|
+
import FluxFormInputGroup from './FluxFormInputGroup.vue';
|
|
55
|
+
import FluxSecondaryButton from './FluxSecondaryButton.vue';
|
|
56
|
+
import FluxStack from './FluxStack.vue';
|
|
57
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
58
|
+
|
|
59
|
+
const modelValue = defineModel<DateTime | null>({
|
|
60
|
+
required: true
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
disabled: componentDisabled,
|
|
65
|
+
isHourOnly
|
|
66
|
+
} = defineProps<{
|
|
67
|
+
readonly autoComplete?: FluxAutoCompleteType;
|
|
68
|
+
readonly autoFocus?: boolean;
|
|
69
|
+
readonly disabled?: boolean;
|
|
70
|
+
readonly isHourOnly?: boolean;
|
|
71
|
+
readonly isReadonly?: boolean;
|
|
72
|
+
readonly max?: DateTime;
|
|
73
|
+
readonly min?: DateTime;
|
|
74
|
+
readonly placeholder?: string;
|
|
75
|
+
}>();
|
|
76
|
+
|
|
77
|
+
const disabled = useDisabled(toRef(() => componentDisabled));
|
|
78
|
+
const flyoutRef = useTemplateRef<{ close(): void; }>('flyout');
|
|
79
|
+
|
|
80
|
+
const localValue = ref<DateTime | null>(null);
|
|
81
|
+
|
|
82
|
+
function setDate(dateTime: DateTime | object | string | number | null): void {
|
|
83
|
+
if (!DateTime.isDateTime(dateTime)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const value: DateTime = (localValue.value ?? DateTime.now());
|
|
88
|
+
localValue.value = value.set({
|
|
89
|
+
day: dateTime.day,
|
|
90
|
+
month: dateTime.month,
|
|
91
|
+
year: dateTime.year
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function setTime(dateTime: DateTime | string | number | object | null): void {
|
|
96
|
+
if (!DateTime.isDateTime(dateTime)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const value: DateTime = (localValue.value ?? DateTime.now());
|
|
101
|
+
localValue.value = value.set({
|
|
102
|
+
hour: dateTime.hour,
|
|
103
|
+
minute: unref(isHourOnly) ? 0 : dateTime.minute,
|
|
104
|
+
second: unref(isHourOnly) ? 0 : dateTime.second
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
watch(() => isHourOnly, () => isHourOnly && (localValue.value = unref(localValue)?.startOf('hour') ?? null), {immediate: true});
|
|
109
|
+
watch(modelValue, modelValue => localValue.value = isHourOnly ? modelValue?.startOf('hour') ?? null : modelValue, {immediate: true});
|
|
110
|
+
|
|
111
|
+
watch(localValue, localValue => {
|
|
112
|
+
unref(flyoutRef)?.close();
|
|
113
|
+
|
|
114
|
+
if (modelValue.value?.toISO() === localValue?.toISO()) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
modelValue.value = localValue;
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.formField">
|
|
3
|
+
<label
|
|
4
|
+
:for="id"
|
|
5
|
+
:class="$style.formFieldHeader">
|
|
6
|
+
<span :class="$style.formFieldLabel">
|
|
7
|
+
{{ label }}
|
|
8
|
+
</span>
|
|
9
|
+
|
|
10
|
+
<span
|
|
11
|
+
v-if="isOptional"
|
|
12
|
+
:class="$style.formFieldOptional">
|
|
13
|
+
({{ translate('flux.optional') }})
|
|
14
|
+
</span>
|
|
15
|
+
|
|
16
|
+
<span
|
|
17
|
+
v-if="'value' in slots"
|
|
18
|
+
:class="$style.formFieldValue">
|
|
19
|
+
<slot
|
|
20
|
+
name="value"
|
|
21
|
+
v-bind="{currentLength, error, hint, id, isOptional, label, maxLength}"/>
|
|
22
|
+
</span>
|
|
23
|
+
</label>
|
|
24
|
+
|
|
25
|
+
<slot v-bind="{id}"/>
|
|
26
|
+
|
|
27
|
+
<span
|
|
28
|
+
v-if="currentLength && maxLength && maxLength > 0"
|
|
29
|
+
:class="$style.formFieldCounter">
|
|
30
|
+
{{ currentLength }} / {{ maxLength }}
|
|
31
|
+
</span>
|
|
32
|
+
|
|
33
|
+
<FluxFormFieldAddition
|
|
34
|
+
v-if="error"
|
|
35
|
+
icon="circle-exclamation"
|
|
36
|
+
mode="error"
|
|
37
|
+
:message="error"/>
|
|
38
|
+
|
|
39
|
+
<FluxFormFieldAddition
|
|
40
|
+
v-if="hint"
|
|
41
|
+
icon="circle-info"
|
|
42
|
+
:message="hint"/>
|
|
43
|
+
|
|
44
|
+
<slot
|
|
45
|
+
name="addition"
|
|
46
|
+
v-bind="{currentLength, error, hint, id, isOptional, label, maxLength}"/>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script
|
|
51
|
+
lang="ts"
|
|
52
|
+
setup>
|
|
53
|
+
import { provide, useId } from 'vue';
|
|
54
|
+
import { useTranslate } from '$flux/composable/private';
|
|
55
|
+
import { FluxFormFieldInjectionKey } from '$flux/data';
|
|
56
|
+
import FluxFormFieldAddition from './FluxFormFieldAddition.vue';
|
|
57
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
58
|
+
|
|
59
|
+
defineProps<{
|
|
60
|
+
readonly currentLength?: number;
|
|
61
|
+
readonly error?: string;
|
|
62
|
+
readonly hint?: string;
|
|
63
|
+
readonly isOptional?: boolean;
|
|
64
|
+
readonly label: string;
|
|
65
|
+
readonly maxLength?: number;
|
|
66
|
+
}>();
|
|
67
|
+
|
|
68
|
+
const slots = defineSlots<{
|
|
69
|
+
default(props: {
|
|
70
|
+
readonly id?: string;
|
|
71
|
+
}): any;
|
|
72
|
+
|
|
73
|
+
addition(props: {
|
|
74
|
+
readonly currentLength?: number;
|
|
75
|
+
readonly error?: string;
|
|
76
|
+
readonly hint?: string;
|
|
77
|
+
readonly isOptional?: boolean;
|
|
78
|
+
readonly label: string;
|
|
79
|
+
readonly maxLength?: number;
|
|
80
|
+
}): any;
|
|
81
|
+
|
|
82
|
+
value(props: {
|
|
83
|
+
readonly currentLength?: number;
|
|
84
|
+
readonly error?: string;
|
|
85
|
+
readonly hint?: string;
|
|
86
|
+
readonly isOptional?: boolean;
|
|
87
|
+
readonly label: string;
|
|
88
|
+
readonly maxLength?: number;
|
|
89
|
+
}): any;
|
|
90
|
+
}>();
|
|
91
|
+
|
|
92
|
+
const id = useId();
|
|
93
|
+
const translate = useTranslate();
|
|
94
|
+
|
|
95
|
+
provide(FluxFormFieldInjectionKey, {
|
|
96
|
+
id
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="clsx(
|
|
4
|
+
mode === 'error' && $style.formFieldAdditionError,
|
|
5
|
+
mode === 'hint' && $style.formFieldAdditionHint
|
|
6
|
+
)"
|
|
7
|
+
role="alert">
|
|
8
|
+
<FluxIcon
|
|
9
|
+
v-if="icon"
|
|
10
|
+
:class="$style.formFieldAdditionIcon"
|
|
11
|
+
:name="icon"
|
|
12
|
+
:size="16"/>
|
|
13
|
+
|
|
14
|
+
<span v-if="message">
|
|
15
|
+
{{ message }}
|
|
16
|
+
</span>
|
|
17
|
+
|
|
18
|
+
<slot/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script
|
|
23
|
+
setup
|
|
24
|
+
lang="ts">
|
|
25
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
26
|
+
import { clsx } from 'clsx';
|
|
27
|
+
import FluxIcon from './FluxIcon.vue';
|
|
28
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
mode = 'hint'
|
|
32
|
+
} = defineProps<{
|
|
33
|
+
readonly icon?: FluxIconName;
|
|
34
|
+
readonly message?: string;
|
|
35
|
+
readonly mode?: 'error' | 'hint';
|
|
36
|
+
}>();
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="clsx(
|
|
4
|
+
disabled ? $style.formInputDisabled : $style.formInputEnabled,
|
|
5
|
+
isSecondary && $style.isSecondary
|
|
6
|
+
)"
|
|
7
|
+
:aria-disabled="disabled ? true : undefined">
|
|
8
|
+
<input
|
|
9
|
+
ref="input"
|
|
10
|
+
:class="clsx(
|
|
11
|
+
$style.formInputNative,
|
|
12
|
+
(!!iconTrailing || type === 'password') && $style.formInputNativeHasIconTrailing,
|
|
13
|
+
!!iconLeading && $style.formInputNativeHasIconLeading
|
|
14
|
+
)"
|
|
15
|
+
:id="id"
|
|
16
|
+
:autocomplete="autoComplete"
|
|
17
|
+
:autofocus="autoFocus"
|
|
18
|
+
:aria-disabled="disabled ? true : undefined"
|
|
19
|
+
:disabled="disabled"
|
|
20
|
+
:max="max"
|
|
21
|
+
:maxlength="maxLength"
|
|
22
|
+
:min="min"
|
|
23
|
+
:placeholder="placeholder"
|
|
24
|
+
:readonly="isReadonly"
|
|
25
|
+
:step="step"
|
|
26
|
+
:type="nativeType"
|
|
27
|
+
:value="localValue"
|
|
28
|
+
@blur="onBlur()"
|
|
29
|
+
@focus="onFocus()"
|
|
30
|
+
@input="onInput"
|
|
31
|
+
@keydown="onKeyDown">
|
|
32
|
+
|
|
33
|
+
<FluxIcon
|
|
34
|
+
v-if="iconLeading"
|
|
35
|
+
:class="$style.formInputIconLeading"
|
|
36
|
+
:name="iconLeading"
|
|
37
|
+
:size="18"/>
|
|
38
|
+
|
|
39
|
+
<FluxIcon
|
|
40
|
+
v-if="type === 'password'"
|
|
41
|
+
:class="$style.formInputIconPasswordToggle"
|
|
42
|
+
:name="nativeType === 'password' ? 'eye' : 'eye-slash'"
|
|
43
|
+
:size="18"
|
|
44
|
+
@click="passwordTypeToggle()"/>
|
|
45
|
+
|
|
46
|
+
<FluxIcon
|
|
47
|
+
v-else-if="iconTrailing"
|
|
48
|
+
:class="$style.formInputIconTrailing"
|
|
49
|
+
:name="iconTrailing"
|
|
50
|
+
:size="18"/>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script
|
|
55
|
+
lang="ts"
|
|
56
|
+
setup>
|
|
57
|
+
import { unrefTemplateElement } from '@flux-ui/internals';
|
|
58
|
+
import type { FluxAutoCompleteType, FluxIconName, FluxInputMask, FluxInputType } from '@flux-ui/types';
|
|
59
|
+
import { clsx } from 'clsx';
|
|
60
|
+
import { DateTime } from 'luxon';
|
|
61
|
+
import { ref, toRef, unref, useTemplateRef, watch } from 'vue';
|
|
62
|
+
import { useDisabled, useFormFieldInjection } from '$flux/composable';
|
|
63
|
+
import { inputMask } from '$flux/data';
|
|
64
|
+
import FluxIcon from './FluxIcon.vue';
|
|
65
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
66
|
+
|
|
67
|
+
const emit = defineEmits<{
|
|
68
|
+
blur: [];
|
|
69
|
+
focus: [];
|
|
70
|
+
showPicker: [];
|
|
71
|
+
}>();
|
|
72
|
+
|
|
73
|
+
const modelValue = defineModel<object | string | number | null>({
|
|
74
|
+
default: ''
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
autoFocus = false,
|
|
79
|
+
disabled: componentDisabled,
|
|
80
|
+
pattern,
|
|
81
|
+
type = 'text'
|
|
82
|
+
} = defineProps<{
|
|
83
|
+
readonly autoComplete?: FluxAutoCompleteType;
|
|
84
|
+
readonly autoFocus?: boolean;
|
|
85
|
+
readonly iconLeading?: FluxIconName;
|
|
86
|
+
readonly iconTrailing?: FluxIconName;
|
|
87
|
+
readonly disabled?: boolean;
|
|
88
|
+
readonly isReadonly?: boolean;
|
|
89
|
+
readonly isSecondary?: boolean;
|
|
90
|
+
readonly max?: string | number;
|
|
91
|
+
readonly maxLength?: number;
|
|
92
|
+
readonly min?: string | number;
|
|
93
|
+
readonly pattern?: FluxInputMask;
|
|
94
|
+
readonly placeholder?: string;
|
|
95
|
+
readonly step?: number;
|
|
96
|
+
readonly type?: FluxInputType;
|
|
97
|
+
}>();
|
|
98
|
+
|
|
99
|
+
const disabled = useDisabled(toRef(() => componentDisabled));
|
|
100
|
+
const inputRef = useTemplateRef<HTMLInputElement>('input');
|
|
101
|
+
const {id} = useFormFieldInjection();
|
|
102
|
+
|
|
103
|
+
const localValue = ref<string | null>(null);
|
|
104
|
+
const nativeType = ref(type);
|
|
105
|
+
|
|
106
|
+
function blur(): void {
|
|
107
|
+
unrefTemplateElement(inputRef)?.blur();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function focus(): void {
|
|
111
|
+
unrefTemplateElement(inputRef)?.focus();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function passwordTypeToggle(): void {
|
|
115
|
+
if (type !== 'password') {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
nativeType.value = unref(nativeType) === 'password' ? 'text' : 'password';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function onBlur(): void {
|
|
123
|
+
emit('blur');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function onFocus(): void {
|
|
127
|
+
emit('focus');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function onInput(evt: Event): void {
|
|
131
|
+
const value = (evt.target as HTMLInputElement).value;
|
|
132
|
+
|
|
133
|
+
switch (type) {
|
|
134
|
+
case 'date':
|
|
135
|
+
case 'datetime-local':
|
|
136
|
+
case 'month':
|
|
137
|
+
case 'time':
|
|
138
|
+
case 'week':
|
|
139
|
+
const dateTime = DateTime.fromISO(value);
|
|
140
|
+
|
|
141
|
+
if (!dateTime.isValid) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
modelValue.value = dateTime;
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case 'number':
|
|
149
|
+
modelValue.value = Number(value);
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
default:
|
|
153
|
+
modelValue.value = value;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function onKeyDown(evt: KeyboardEvent): void {
|
|
159
|
+
if (!['date', 'datetime-local', 'month', 'week'].includes(type)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (evt.key === ' ') {
|
|
164
|
+
emit('showPicker');
|
|
165
|
+
evt.preventDefault();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
watch([modelValue, () => type], ([modelValue, type]) => {
|
|
170
|
+
if (!modelValue && modelValue !== 0) {
|
|
171
|
+
localValue.value = null;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (DateTime.isDateTime(modelValue)) {
|
|
176
|
+
const iso = modelValue.toISO()!;
|
|
177
|
+
|
|
178
|
+
switch (type) {
|
|
179
|
+
case 'date':
|
|
180
|
+
localValue.value = iso.substring(0, 10);
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case 'datetime-local':
|
|
184
|
+
localValue.value = iso.substring(0, 16);
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case 'time':
|
|
188
|
+
localValue.value = iso.substring(11, 16);
|
|
189
|
+
break;
|
|
190
|
+
|
|
191
|
+
default:
|
|
192
|
+
localValue.value = iso;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
localValue.value = modelValue.toString();
|
|
200
|
+
}, {immediate: true});
|
|
201
|
+
|
|
202
|
+
watch([inputRef, () => pattern, localValue], ([input, pattern, value], __, onCleanup) => {
|
|
203
|
+
if (!input || !pattern) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const mask = inputMask[pattern](input);
|
|
208
|
+
|
|
209
|
+
if (value) {
|
|
210
|
+
mask.value = value;
|
|
211
|
+
localValue.value = mask.value;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
onCleanup(() => mask.destroy());
|
|
215
|
+
}, {immediate: true});
|
|
216
|
+
|
|
217
|
+
watch(() => type, type => nativeType.value = type);
|
|
218
|
+
|
|
219
|
+
defineExpose({
|
|
220
|
+
blur,
|
|
221
|
+
focus
|
|
222
|
+
});
|
|
223
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.formInputAddition">
|
|
3
|
+
<FluxIcon
|
|
4
|
+
v-if="icon"
|
|
5
|
+
:name="icon"
|
|
6
|
+
:size="18"/>
|
|
7
|
+
|
|
8
|
+
<span v-if="label">
|
|
9
|
+
{{ label }}
|
|
10
|
+
</span>
|
|
11
|
+
|
|
12
|
+
<slot/>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script
|
|
17
|
+
lang="ts"
|
|
18
|
+
setup>
|
|
19
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
20
|
+
import FluxIcon from './FluxIcon.vue';
|
|
21
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
22
|
+
|
|
23
|
+
defineProps<{
|
|
24
|
+
readonly icon?: FluxIconName;
|
|
25
|
+
readonly label?: string;
|
|
26
|
+
}>();
|
|
27
|
+
|
|
28
|
+
defineSlots<{
|
|
29
|
+
default(): any;
|
|
30
|
+
}>();
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="clsx(
|
|
4
|
+
$style.formInputGroup,
|
|
5
|
+
isSecondary && $style.isSecondary
|
|
6
|
+
)"
|
|
7
|
+
role="textbox">
|
|
8
|
+
<slot/>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script
|
|
13
|
+
lang="ts"
|
|
14
|
+
setup>
|
|
15
|
+
import { clsx } from 'clsx';
|
|
16
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
17
|
+
|
|
18
|
+
defineProps<{
|
|
19
|
+
readonly isSecondary?: boolean;
|
|
20
|
+
}>();
|
|
21
|
+
|
|
22
|
+
defineSlots<{
|
|
23
|
+
default(): any;
|
|
24
|
+
}>();
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<fieldset
|
|
3
|
+
:class="disabled ? $style.pinInputDisabled : $style.pinInputEnabled"
|
|
4
|
+
:id="id"
|
|
5
|
+
:style="{
|
|
6
|
+
'--max-length': maxLength
|
|
7
|
+
}"
|
|
8
|
+
:autofocus="autoFocus"
|
|
9
|
+
:aria-disabled="disabled ? true : undefined">
|
|
10
|
+
<input
|
|
11
|
+
v-for="field of maxLength"
|
|
12
|
+
:key="field"
|
|
13
|
+
ref="fields"
|
|
14
|
+
:class="$style.pinInputField"
|
|
15
|
+
maxlength="1"
|
|
16
|
+
:autocomplete="field === 1 ? autoComplete : undefined"
|
|
17
|
+
:autofocus="field === 1 && autoFocus"
|
|
18
|
+
:disabled="disabled"
|
|
19
|
+
:tabindex="(field - 1) === modelValue?.length ? 0 : -1"
|
|
20
|
+
:type="isPrivate ? 'password' : 'text'"
|
|
21
|
+
:value="modelValue[field - 1]"
|
|
22
|
+
@focus="onFocus"
|
|
23
|
+
@input="onInput"
|
|
24
|
+
@keydown="onKeyDown"
|
|
25
|
+
@paste="onPaste"/>
|
|
26
|
+
</fieldset>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script
|
|
30
|
+
lang="ts"
|
|
31
|
+
setup>
|
|
32
|
+
import type { FluxAutoCompleteType } from '@flux-ui/types';
|
|
33
|
+
import { toRef, unref, useTemplateRef } from 'vue';
|
|
34
|
+
import { useDisabled, useFormFieldInjection } from '$flux/composable';
|
|
35
|
+
import $style from '$flux/css/component/Form.module.scss';
|
|
36
|
+
|
|
37
|
+
const modelValue = defineModel<string>({
|
|
38
|
+
default: ''
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
autoComplete = 'one-time-code',
|
|
43
|
+
autoFocus = false,
|
|
44
|
+
disabled: componentDisabled,
|
|
45
|
+
maxLength = 6
|
|
46
|
+
} = defineProps<{
|
|
47
|
+
readonly autoComplete?: FluxAutoCompleteType;
|
|
48
|
+
readonly autoFocus?: boolean;
|
|
49
|
+
readonly disabled?: boolean;
|
|
50
|
+
readonly isPrivate?: boolean;
|
|
51
|
+
readonly maxLength?: number;
|
|
52
|
+
}>();
|
|
53
|
+
|
|
54
|
+
const disabled = useDisabled(toRef(() => componentDisabled));
|
|
55
|
+
const {id} = useFormFieldInjection();
|
|
56
|
+
|
|
57
|
+
const fieldRefs = useTemplateRef<HTMLInputElement[]>('fields');
|
|
58
|
+
|
|
59
|
+
function onFocus(evt: FocusEvent): void {
|
|
60
|
+
const input = evt.target as HTMLInputElement;
|
|
61
|
+
requestAnimationFrame(() => input.select());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function onInput(): void {
|
|
65
|
+
const fields = unref(fieldRefs) ?? [];
|
|
66
|
+
const values = fields
|
|
67
|
+
.map(f => f.value.trim() === '' ? NaN : Number(f.value))
|
|
68
|
+
.filter(v => !isNaN(v));
|
|
69
|
+
|
|
70
|
+
modelValue.value = values.join('');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function onKeyDown(evt: KeyboardEvent): void {
|
|
74
|
+
const input = evt.target as HTMLInputElement;
|
|
75
|
+
const value = input.value.trim();
|
|
76
|
+
|
|
77
|
+
const next = input.nextElementSibling as HTMLInputElement | null;
|
|
78
|
+
const previous = input.previousElementSibling as HTMLInputElement | null;
|
|
79
|
+
|
|
80
|
+
switch (evt.key) {
|
|
81
|
+
case 'Backspace':
|
|
82
|
+
value === '' && previous?.focus();
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 'ArrowLeft':
|
|
86
|
+
case 'ArrowUp':
|
|
87
|
+
input.selectionStart === 0 && previous?.select();
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case 'ArrowDown':
|
|
91
|
+
case 'ArrowRight':
|
|
92
|
+
(input.selectionStart === 1 || value === '') && next?.select();
|
|
93
|
+
break;
|
|
94
|
+
|
|
95
|
+
case 'Tab':
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'v':
|
|
99
|
+
if (evt.ctrlKey || evt.metaKey) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
evt.preventDefault();
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
default:
|
|
107
|
+
if (isNaN(Number(evt.key))) {
|
|
108
|
+
evt.preventDefault();
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
requestAnimationFrame(() => next?.focus());
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function onPaste(evt: ClipboardEvent): void {
|
|
118
|
+
if (!evt.clipboardData) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const value = evt.clipboardData.getData('text').replace(/\D/g, '');
|
|
123
|
+
|
|
124
|
+
if (value.length !== maxLength) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
modelValue.value = value;
|
|
129
|
+
|
|
130
|
+
requestAnimationFrame(() => {
|
|
131
|
+
const fields = unref(fieldRefs) ?? [];
|
|
132
|
+
fields[maxLength - 1].focus();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
</script>
|