vueless 0.0.163 → 0.0.165
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/composable.ui/index.js +2 -5
- package/package.json +2 -2
- package/service.ui/index.js +27 -8
- package/ui.button/composables/attrs.composable.js +3 -3
- package/ui.button/configs/default.config.js +1 -2
- package/ui.button-link/composables/attrs.composable.js +6 -3
- package/ui.container-modal-confirm/composable/attrs.composable.js +18 -29
- package/ui.form-calendar/components/DayView.vue +1 -1
- package/ui.form-calendar/configs/default.config.js +1 -1
- package/ui.form-calendar/index.stories.js +21 -10
- package/ui.form-calendar/index.vue +22 -15
- package/ui.form-calendar/services/calendar.service.js +5 -7
- package/ui.form-calendar/services/date.service.js +1 -23
- package/ui.form-checkbox/composables/attrs.composable.js +3 -3
- package/ui.form-date-picker/configs/default.config.js +1 -1
- package/ui.form-date-picker/index.stories.js +19 -7
- package/ui.form-date-picker/index.vue +7 -12
- package/ui.form-date-picker-range/configs/default.config.js +1 -1
- package/ui.form-date-picker-range/index.stories.js +22 -6
- package/ui.form-date-picker-range/index.vue +79 -84
- package/ui.form-date-picker-range/services/dateRange.service.js +8 -10
- package/ui.form-radio/composables/attrs.composable.js +2 -2
- package/ui.form-switch/composables/attrs.composable.js +3 -3
- package/ui.image-avatar/composables/attrs.composable.js +2 -2
- package/ui.image-icon/composables/attrs.composable.js +3 -3
- package/ui.loader/composables/attrs.composable.js +2 -2
- package/ui.loader-rendering/composables/attrs.composable.js +2 -2
- package/ui.loader-top/composables/attrs.composable.js +7 -2
- package/ui.navigation-progress/composables/attrs.composable.js +2 -2
- package/ui.other-dot/composables/attrs.composable.js +2 -2
- package/ui.text-alert/composables/attrs.composable.js +5 -2
- package/ui.text-alert/configs/default.config.js +5 -1
- package/ui.text-badge/composables/attrs.composable.js +5 -2
- package/ui.text-header/composables/attrs.composable.js +2 -2
- package/ui.text-money/composables/attrs.composable.js +5 -2
- package/web-types.json +14 -17
package/composable.ui/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Text,
|
|
9
9
|
Fragment,
|
|
10
10
|
} from "vue";
|
|
11
|
-
import { cx, globalComponentConfig, strategy } from "../service.ui";
|
|
11
|
+
import { cx, globalComponentConfig, strategy, getColor, setColor } from "../service.ui";
|
|
12
12
|
import { cloneDeep } from "../service.helper";
|
|
13
13
|
|
|
14
14
|
const strategyType = {
|
|
@@ -94,6 +94,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
94
94
|
return {
|
|
95
95
|
config,
|
|
96
96
|
getAttrs,
|
|
97
|
+
getColor,
|
|
97
98
|
setColor,
|
|
98
99
|
hasSlotContent,
|
|
99
100
|
};
|
|
@@ -350,7 +351,3 @@ function hasSlotContent(slot, props = {}) {
|
|
|
350
351
|
|
|
351
352
|
return !isVNodeEmpty(slot?.(props));
|
|
352
353
|
}
|
|
353
|
-
|
|
354
|
-
function setColor(classes, color) {
|
|
355
|
-
return classes?.replaceAll("{color}", color);
|
|
356
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.165",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless Component Framework.",
|
|
6
6
|
"homepage": "https://vueless.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@release-it/bumper": "^6.0.1",
|
|
38
38
|
"@vitejs/plugin-vue": "^5.0.5",
|
|
39
39
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
40
|
-
"@vueless/plugin-vite": "^0.0.
|
|
40
|
+
"@vueless/plugin-vite": "^0.0.30",
|
|
41
41
|
"@vueless/storybook": "^0.0.31",
|
|
42
42
|
"@vueless/web-types": "^0.0.11",
|
|
43
43
|
"autoprefixer": "^10.4.19",
|
package/service.ui/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
|
|
|
43
43
|
*/
|
|
44
44
|
export const { layout, strategy, gray, brand, component: globalComponentConfig } = vuelessConfig;
|
|
45
45
|
|
|
46
|
-
export default class
|
|
46
|
+
export default class UIService {
|
|
47
47
|
isMac = false;
|
|
48
48
|
isPWA = false;
|
|
49
49
|
isIOS = false;
|
|
@@ -137,7 +137,7 @@ export default class UIServiceDefault {
|
|
|
137
137
|
const globalBrandColor = getBrandColor(brand, grayColor, BRAND_COLORS);
|
|
138
138
|
|
|
139
139
|
const style = document.createElement("style");
|
|
140
|
-
const rgb =
|
|
140
|
+
const rgb = UIService.convertHexInRgb(localBrandColor || globalBrandColor || grayColor);
|
|
141
141
|
|
|
142
142
|
style.innerHTML = `
|
|
143
143
|
:root {
|
|
@@ -187,22 +187,41 @@ export default class UIServiceDefault {
|
|
|
187
187
|
globalComponentConfig[name]?.defaultVariants,
|
|
188
188
|
);
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
defaultVariants.color = GRAYSCALE_COLOR;
|
|
192
|
-
}
|
|
190
|
+
defaultVariants.color = getColor(defaultVariants.color);
|
|
193
191
|
|
|
194
192
|
return {
|
|
195
193
|
default: defaultVariants,
|
|
196
194
|
};
|
|
197
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
Get color for props.
|
|
199
|
+
@param { String } color
|
|
200
|
+
@returns { String }
|
|
201
|
+
*/
|
|
202
|
+
getColor(color) {
|
|
203
|
+
return brand === GRAYSCALE_COLOR && color === BRAND_COLOR ? GRAYSCALE_COLOR : color;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
Find and replace all {color} variables in class names into given color.
|
|
208
|
+
@param { String } classes
|
|
209
|
+
@param { String } color
|
|
210
|
+
@returns { String }
|
|
211
|
+
*/
|
|
212
|
+
setColor(classes, color) {
|
|
213
|
+
return classes?.replaceAll("{color}", color);
|
|
214
|
+
}
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
export const {
|
|
201
218
|
getRandomId,
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
getColor,
|
|
220
|
+
setColor,
|
|
204
221
|
setTitle,
|
|
205
222
|
setFavicon,
|
|
223
|
+
setBrandColor,
|
|
224
|
+
convertHexInRgb,
|
|
206
225
|
isMac,
|
|
207
226
|
isPWA,
|
|
208
227
|
isIOS,
|
|
@@ -210,4 +229,4 @@ export const {
|
|
|
210
229
|
isMobileApp,
|
|
211
230
|
PX_IN_REM,
|
|
212
231
|
HYPHEN_SYMBOL,
|
|
213
|
-
} = new
|
|
232
|
+
} = new UIService();
|
|
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
|
|
|
5
5
|
import defaultConfig from "../configs/default.config";
|
|
6
6
|
|
|
7
7
|
export function useAttrs(props) {
|
|
8
|
-
const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
|
|
8
|
+
const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
|
|
9
9
|
const { button, text } = config.value;
|
|
10
10
|
|
|
11
11
|
const cvaButton = cva({
|
|
@@ -24,7 +24,7 @@ export function useAttrs(props) {
|
|
|
24
24
|
setColor(
|
|
25
25
|
cvaButton({
|
|
26
26
|
size: props.size,
|
|
27
|
-
color: props.color,
|
|
27
|
+
color: getColor(props.color),
|
|
28
28
|
variant: props.variant,
|
|
29
29
|
pill: props.pill,
|
|
30
30
|
block: props.block,
|
|
@@ -40,7 +40,7 @@ export function useAttrs(props) {
|
|
|
40
40
|
const textClasses = computed(() =>
|
|
41
41
|
setColor(
|
|
42
42
|
cvaText({
|
|
43
|
-
color: props.color,
|
|
43
|
+
color: getColor(props.color),
|
|
44
44
|
}),
|
|
45
45
|
props.color,
|
|
46
46
|
),
|
|
@@ -160,7 +160,6 @@ export default /*tw*/ {
|
|
|
160
160
|
{ pattern: `text-(${colors})-700`, variants: ["hover", "focus"] },
|
|
161
161
|
{ pattern: `text-(${colors})-800`, variants: ["active"] },
|
|
162
162
|
{ pattern: `text-(${colors})-300`, variants: ["disabled"] },
|
|
163
|
-
{ pattern: `ring-(${colors})-700`, variants: ["focus"] },
|
|
164
|
-
{ pattern: `ring-(${colors})-800`, variants: ["active"] },
|
|
163
|
+
{ pattern: `ring-(${colors})-700`, variants: ["focus", "focus-within"] },
|
|
165
164
|
],
|
|
166
165
|
};
|
|
@@ -8,7 +8,10 @@ import defaultConfig from "../configs/default.config";
|
|
|
8
8
|
export function useAttrs(props, { isActive, isExactActive }) {
|
|
9
9
|
const slots = useSlots();
|
|
10
10
|
|
|
11
|
-
const { config, getAttrs, hasSlotContent, setColor } = useUI(
|
|
11
|
+
const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
|
|
12
|
+
defaultConfig,
|
|
13
|
+
() => props.config,
|
|
14
|
+
);
|
|
12
15
|
const { wrapper, link, text, rightSlot, leftSlot } = config.value;
|
|
13
16
|
|
|
14
17
|
const cvaWrapper = cva({
|
|
@@ -45,7 +48,7 @@ export function useAttrs(props, { isActive, isExactActive }) {
|
|
|
45
48
|
setColor(
|
|
46
49
|
cvaWrapper({
|
|
47
50
|
size: props.size,
|
|
48
|
-
color: props.color,
|
|
51
|
+
color: getColor(props.color),
|
|
49
52
|
block: props.block,
|
|
50
53
|
noRing: props.noRing,
|
|
51
54
|
disabled: props.disabled,
|
|
@@ -58,7 +61,7 @@ export function useAttrs(props, { isActive, isExactActive }) {
|
|
|
58
61
|
setColor(
|
|
59
62
|
cvaLink({
|
|
60
63
|
size: props.size,
|
|
61
|
-
color: props.color,
|
|
64
|
+
color: getColor(props.color),
|
|
62
65
|
dashed: props.dashed,
|
|
63
66
|
underlined: props.underlined,
|
|
64
67
|
}),
|
|
@@ -4,8 +4,11 @@ import { cva } from "../../service.ui/index.js";
|
|
|
4
4
|
import { computed } from "vue";
|
|
5
5
|
|
|
6
6
|
export function useAttrs(props) {
|
|
7
|
-
const { config, getAttrs, hasSlotContent, setColor } = useUI(
|
|
8
|
-
|
|
7
|
+
const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
|
|
8
|
+
defaultConfig,
|
|
9
|
+
() => props.config,
|
|
10
|
+
);
|
|
11
|
+
const { modal, footerLeftFallback } = config.value;
|
|
9
12
|
|
|
10
13
|
const cvaModal = cva({
|
|
11
14
|
base: modal.base,
|
|
@@ -19,40 +22,26 @@ export function useAttrs(props) {
|
|
|
19
22
|
compoundVariants: footerLeftFallback.compoundVariants,
|
|
20
23
|
});
|
|
21
24
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
variants: cancelButton.variants,
|
|
31
|
-
compoundVariants: cancelButton.compoundVariants,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const modalClasses = computed(() => setColor(cvaModal({ color: props.color }), props.color));
|
|
25
|
+
const modalClasses = computed(() =>
|
|
26
|
+
setColor(
|
|
27
|
+
cvaModal({
|
|
28
|
+
color: getColor(props.color),
|
|
29
|
+
}),
|
|
30
|
+
props.color,
|
|
31
|
+
),
|
|
32
|
+
);
|
|
35
33
|
|
|
36
34
|
const footerLeftFallbackClasses = computed(() =>
|
|
37
|
-
setColor(cvaFooterLeftFallback({ color: props.color }), props.color),
|
|
35
|
+
setColor(cvaFooterLeftFallback({ color: getColor(props.color) }), props.color),
|
|
38
36
|
);
|
|
39
37
|
|
|
40
|
-
const confirmButtonClasses = computed(() => cvaConfirmButton({ color: props.color }));
|
|
41
|
-
|
|
42
|
-
const cancelButtonClasses = computed(() => cvaCancelButton({ color: props.color }));
|
|
43
|
-
|
|
44
|
-
const modalAttrsRaw = getAttrs("modal", { isComponent: true, classes: modalClasses });
|
|
45
38
|
const footerLeftFallbackAttrs = getAttrs("footerLeftFallback", {
|
|
46
39
|
classes: footerLeftFallbackClasses,
|
|
47
40
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
const cancelButtonAttrs = getAttrs("cancelButton", {
|
|
53
|
-
isComponent: true,
|
|
54
|
-
classes: cancelButtonClasses,
|
|
55
|
-
});
|
|
41
|
+
|
|
42
|
+
const confirmButtonAttrs = getAttrs("confirmButton", { isComponent: true });
|
|
43
|
+
const cancelButtonAttrs = getAttrs("cancelButton", { isComponent: true });
|
|
44
|
+
const modalAttrsRaw = getAttrs("modal", { isComponent: true, classes: modalClasses });
|
|
56
45
|
|
|
57
46
|
const modalAttrs = computed(() => ({
|
|
58
47
|
...modalAttrsRaw.value,
|
|
@@ -138,10 +138,10 @@ export default /*tw*/ {
|
|
|
138
138
|
okLabel: "Ok",
|
|
139
139
|
},
|
|
140
140
|
defaultVariants: {
|
|
141
|
-
dateFormat: "Y-m-d",
|
|
142
141
|
userFormat: "F j, Y",
|
|
143
142
|
range: false,
|
|
144
143
|
timepicker: false,
|
|
144
|
+
dateFormat: undefined,
|
|
145
145
|
maxDate: undefined,
|
|
146
146
|
minDate: undefined,
|
|
147
147
|
},
|
|
@@ -9,9 +9,7 @@ export default {
|
|
|
9
9
|
id: "3165",
|
|
10
10
|
title: "Form Inputs & Controls / Calendar",
|
|
11
11
|
component: UCalendar,
|
|
12
|
-
args: {
|
|
13
|
-
label: "Label",
|
|
14
|
-
},
|
|
12
|
+
args: {},
|
|
15
13
|
argTypes: {
|
|
16
14
|
...getArgTypes(UCalendar.name),
|
|
17
15
|
},
|
|
@@ -31,32 +29,45 @@ const DefaultTemplate = (args) => ({
|
|
|
31
29
|
|
|
32
30
|
return { args, slots };
|
|
33
31
|
},
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
value: this.args.value,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
34
37
|
template: `
|
|
35
|
-
<UCalendar v-bind="args" v-model="
|
|
38
|
+
<UCalendar v-bind="args" v-model="value">
|
|
36
39
|
<template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
|
|
37
40
|
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
38
41
|
</template>
|
|
39
42
|
</UCalendar>
|
|
43
|
+
|
|
44
|
+
<div class="mt-4">
|
|
45
|
+
{{ value }}
|
|
46
|
+
</div>
|
|
40
47
|
`,
|
|
41
48
|
});
|
|
42
49
|
|
|
43
50
|
export const Default = DefaultTemplate.bind({});
|
|
44
|
-
Default.args = {};
|
|
51
|
+
Default.args = { value: new Date() };
|
|
45
52
|
|
|
46
53
|
export const Range = DefaultTemplate.bind({});
|
|
47
54
|
Range.args = {
|
|
48
55
|
range: true,
|
|
49
56
|
value: {
|
|
50
|
-
from:
|
|
51
|
-
to:
|
|
57
|
+
from: new Date(2022, 2),
|
|
58
|
+
to: new Date(2024, 2, 14, 12, 24, 14),
|
|
52
59
|
},
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
export const Timepicker = DefaultTemplate.bind({});
|
|
56
|
-
Timepicker.args = { value:
|
|
63
|
+
Timepicker.args = { value: new Date(2024, 2, 14, 12, 24, 14), timepicker: true };
|
|
57
64
|
|
|
58
65
|
export const MinMax = DefaultTemplate.bind({});
|
|
59
|
-
MinMax.args = {
|
|
66
|
+
MinMax.args = {
|
|
67
|
+
minDate: "2022-02-22",
|
|
68
|
+
maxDate: new Date(2022, 2, 26),
|
|
69
|
+
value: new Date(2022, 2, 24),
|
|
70
|
+
};
|
|
60
71
|
|
|
61
72
|
export const DateFormat = DefaultTemplate.bind({});
|
|
62
|
-
DateFormat.args = { dateFormat: "d.m.Y", userFormat: "d.m.Y", value:
|
|
73
|
+
DateFormat.args = { dateFormat: "d.m.Y", userFormat: "d.m.Y", value: "28.06.2024" };
|
|
@@ -167,7 +167,6 @@ import {
|
|
|
167
167
|
} from "./services/calendar.service";
|
|
168
168
|
|
|
169
169
|
import {
|
|
170
|
-
getUnixTimestampFromDate,
|
|
171
170
|
getDateWithoutTime,
|
|
172
171
|
addMonths,
|
|
173
172
|
addDays,
|
|
@@ -202,10 +201,10 @@ defineOptions({ name: "UCalendar" });
|
|
|
202
201
|
|
|
203
202
|
const props = defineProps({
|
|
204
203
|
/**
|
|
205
|
-
* Calendar value
|
|
204
|
+
* Calendar value in JS Date Object or String formatted in provided props.dateFormat.
|
|
206
205
|
*/
|
|
207
206
|
modelValue: {
|
|
208
|
-
type: [
|
|
207
|
+
type: [String, Object],
|
|
209
208
|
default: null,
|
|
210
209
|
},
|
|
211
210
|
|
|
@@ -251,7 +250,7 @@ const props = defineProps({
|
|
|
251
250
|
},
|
|
252
251
|
|
|
253
252
|
/**
|
|
254
|
-
* Min date in
|
|
253
|
+
* Min date in JS Date Object or Date String formatted in provided props.dateFormat.
|
|
255
254
|
*/
|
|
256
255
|
minDate: {
|
|
257
256
|
type: [Date, String],
|
|
@@ -259,7 +258,7 @@ const props = defineProps({
|
|
|
259
258
|
},
|
|
260
259
|
|
|
261
260
|
/**
|
|
262
|
-
* Max date in
|
|
261
|
+
* Max date in JS Date Object or Date String formatted in provided props.dateFormat.
|
|
263
262
|
*/
|
|
264
263
|
maxDate: {
|
|
265
264
|
type: [Date, String],
|
|
@@ -402,7 +401,7 @@ const isTimepickerEnabled = computed(() => {
|
|
|
402
401
|
const isModelRangeType = computed(() => {
|
|
403
402
|
return (
|
|
404
403
|
props.modelValue !== null &&
|
|
405
|
-
!
|
|
404
|
+
!(props.modelValue instanceof Date) &&
|
|
406
405
|
typeof props.modelValue === "object"
|
|
407
406
|
);
|
|
408
407
|
});
|
|
@@ -414,10 +413,15 @@ const localValue = computed({
|
|
|
414
413
|
|
|
415
414
|
const to = isModelRangeType.value ? props.modelValue.to : null;
|
|
416
415
|
|
|
417
|
-
return {
|
|
416
|
+
return {
|
|
417
|
+
from: parseDate(from || null, props.dateFormat, locale.value),
|
|
418
|
+
to: parseDate(to || null, props.dateFormat, locale.value),
|
|
419
|
+
};
|
|
418
420
|
}
|
|
419
421
|
|
|
420
|
-
return isModelRangeType.value
|
|
422
|
+
return isModelRangeType.value
|
|
423
|
+
? parseDate(props.modelValue.from || null, props.dateFormat, locale.value)
|
|
424
|
+
: parseDate(props.modelValue || null, props.dateFormat, locale.value);
|
|
421
425
|
},
|
|
422
426
|
set(value) {
|
|
423
427
|
value = getCurrentValueType(value);
|
|
@@ -433,9 +437,6 @@ const localValue = computed({
|
|
|
433
437
|
parsedDate.setMinutes(Number(minutesRef.value.value));
|
|
434
438
|
}
|
|
435
439
|
|
|
436
|
-
const timestamp = parsedDate ? getUnixTimestampFromDate(parsedDate) : null;
|
|
437
|
-
const timestampTo = parsedDateTo ? getUnixTimestampFromDate(parsedDateTo) : null;
|
|
438
|
-
|
|
439
440
|
const isOutOfRange = dateIsOutOfRange(
|
|
440
441
|
parsedDate || new Date(),
|
|
441
442
|
props.minDate,
|
|
@@ -448,7 +449,15 @@ const localValue = computed({
|
|
|
448
449
|
return;
|
|
449
450
|
}
|
|
450
451
|
|
|
451
|
-
|
|
452
|
+
const newDate = props.dateFormat
|
|
453
|
+
? formatDate(parsedDate || null, props.dateFormat, locale.value)
|
|
454
|
+
: parsedDate;
|
|
455
|
+
|
|
456
|
+
const newDateTo = props.dateFormat
|
|
457
|
+
? formatDate(parsedDateTo || null, props.dateFormat, locale.value)
|
|
458
|
+
: parsedDateTo;
|
|
459
|
+
|
|
460
|
+
emit("update:modelValue", props.range ? { from: newDate, to: newDateTo } : newDate);
|
|
452
461
|
|
|
453
462
|
if (parsedDate === null && isTimepickerEnabled.value) {
|
|
454
463
|
const currentDate = new Date();
|
|
@@ -568,9 +577,7 @@ function onInputDate(newDate) {
|
|
|
568
577
|
|
|
569
578
|
if (props.range) {
|
|
570
579
|
const isFullReset =
|
|
571
|
-
localValue.value.to ||
|
|
572
|
-
!localValue.value.from ||
|
|
573
|
-
getUnixTimestampFromDate(date) <= localValue.value.from;
|
|
580
|
+
localValue.value.to || !localValue.value.from || date <= localValue.value.from;
|
|
574
581
|
|
|
575
582
|
localValue.value = isFullReset
|
|
576
583
|
? { from: date, to: null }
|
|
@@ -15,7 +15,7 @@ export function getInitialActiveDate(localValue) {
|
|
|
15
15
|
return new Date();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function formatDate(dateObj, format, locale) {
|
|
18
|
+
export function formatDate(dateObj, format = "Y-m-d H:i:S", locale) {
|
|
19
19
|
if (dateObj === null) {
|
|
20
20
|
return "";
|
|
21
21
|
}
|
|
@@ -85,7 +85,7 @@ export function parseDate(date, format = "Y-m-d H:i:S", locale) {
|
|
|
85
85
|
return parsedDate;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function parseStringDate(dateString, format, localeTokenRegex, locale) {
|
|
88
|
+
export function parseStringDate(dateString, format = "Y-m-d H:i:S", localeTokenRegex, locale) {
|
|
89
89
|
const isWithinTimezone = /Z$/.test(dateString) || /GMT$/.test(dateString);
|
|
90
90
|
|
|
91
91
|
if (isWithinTimezone) {
|
|
@@ -163,18 +163,16 @@ export function dateIsOutOfRange(date, min, max, locale, dateFormat = null) {
|
|
|
163
163
|
|
|
164
164
|
const maxDate = typeof max === "string" ? parseDate(max, dateFormat, locale) : max;
|
|
165
165
|
|
|
166
|
-
const time = date.getTime();
|
|
167
|
-
|
|
168
166
|
if (minDate && maxDate) {
|
|
169
|
-
return
|
|
167
|
+
return date < minDate || date > maxDate;
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
if (minDate) {
|
|
173
|
-
return
|
|
171
|
+
return date < minDate;
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
if (maxDate) {
|
|
177
|
-
return
|
|
175
|
+
return date > maxDate;
|
|
178
176
|
}
|
|
179
177
|
|
|
180
178
|
return false;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LOCALE_TYPE,
|
|
3
|
-
DAYS_IN_WEEK,
|
|
4
|
-
SECONDS_IN_MINUTES,
|
|
5
|
-
MILLISECONDS_IN_MINUTE,
|
|
6
|
-
} from "../constants";
|
|
1
|
+
import { LOCALE_TYPE, DAYS_IN_WEEK, SECONDS_IN_MINUTES } from "../constants";
|
|
7
2
|
|
|
8
3
|
const daysMap = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
9
4
|
const monthsMap = [
|
|
@@ -25,10 +20,6 @@ export function minutesToSeconds(minutes) {
|
|
|
25
20
|
return Math.trunc(minutes * SECONDS_IN_MINUTES);
|
|
26
21
|
}
|
|
27
22
|
|
|
28
|
-
export function utcToGMT(date) {
|
|
29
|
-
return new Date(date.getTime() + date.getTimezoneOffset() * MILLISECONDS_IN_MINUTE);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
export function getDaysInMonth(date) {
|
|
33
24
|
return new Date(new Date(date.valueOf()).setDate(0)).getDate();
|
|
34
25
|
}
|
|
@@ -152,19 +143,6 @@ export function getStartOfDay(date) {
|
|
|
152
143
|
return localDate;
|
|
153
144
|
}
|
|
154
145
|
|
|
155
|
-
export function gmtToUTC(date) {
|
|
156
|
-
return new Date(
|
|
157
|
-
Date.UTC(
|
|
158
|
-
date.getUTCFullYear(),
|
|
159
|
-
date.getUTCMonth(),
|
|
160
|
-
date.getUTCDate(),
|
|
161
|
-
date.getUTCHours(),
|
|
162
|
-
date.getUTCMinutes(),
|
|
163
|
-
date.getUTCSeconds(),
|
|
164
|
-
),
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
146
|
export function getSortedLocale(locale, type) {
|
|
169
147
|
const targetMap = type === LOCALE_TYPE.month ? monthsMap : daysMap;
|
|
170
148
|
|
|
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
|
|
|
5
5
|
import defaultConfig from "../configs/default.config";
|
|
6
6
|
|
|
7
7
|
export function useAttrs(props) {
|
|
8
|
-
const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
|
|
8
|
+
const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
|
|
9
9
|
const { checkbox, iconWrapper } = config.value;
|
|
10
10
|
|
|
11
11
|
const cvaCheckbox = cva({
|
|
@@ -25,7 +25,7 @@ export function useAttrs(props) {
|
|
|
25
25
|
cvaCheckbox({
|
|
26
26
|
size: props.size,
|
|
27
27
|
label: Boolean(props.label),
|
|
28
|
-
color: props.color,
|
|
28
|
+
color: getColor(props.color),
|
|
29
29
|
disabled: props.color,
|
|
30
30
|
}),
|
|
31
31
|
props.color,
|
|
@@ -36,7 +36,7 @@ export function useAttrs(props) {
|
|
|
36
36
|
setColor(
|
|
37
37
|
cvaIconWrapper({
|
|
38
38
|
size: props.size,
|
|
39
|
-
color: props.color,
|
|
39
|
+
color: getColor(props.color),
|
|
40
40
|
}),
|
|
41
41
|
props.color,
|
|
42
42
|
),
|
|
@@ -109,13 +109,13 @@ export default /*tw*/ {
|
|
|
109
109
|
okLabel: "Ok",
|
|
110
110
|
},
|
|
111
111
|
defaultVariants: {
|
|
112
|
-
dateFormat: "Y-m-d",
|
|
113
112
|
userFormat: "F j, Y",
|
|
114
113
|
size: "md",
|
|
115
114
|
openDirectionX: "auto",
|
|
116
115
|
openDirectionY: "auto",
|
|
117
116
|
timepicker: false,
|
|
118
117
|
disabled: false,
|
|
118
|
+
dateFormat: undefined,
|
|
119
119
|
maxDate: undefined,
|
|
120
120
|
minDate: undefined,
|
|
121
121
|
},
|
|
@@ -33,12 +33,21 @@ const DefaultTemplate = (args) => ({
|
|
|
33
33
|
|
|
34
34
|
return { args, slots };
|
|
35
35
|
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
value: this.args.value,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
36
41
|
template: `
|
|
37
|
-
<UDatePicker v-bind="args" v-model="
|
|
42
|
+
<UDatePicker v-bind="args" v-model="value">
|
|
38
43
|
<template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
|
|
39
44
|
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
40
45
|
</template>
|
|
41
46
|
</UDatePicker>
|
|
47
|
+
|
|
48
|
+
<div class="mt-4">
|
|
49
|
+
{{ value }}
|
|
50
|
+
</div>
|
|
42
51
|
`,
|
|
43
52
|
});
|
|
44
53
|
|
|
@@ -64,12 +73,11 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
64
73
|
`,
|
|
65
74
|
});
|
|
66
75
|
|
|
67
|
-
const OpenDirectionTemplate = (args
|
|
76
|
+
const OpenDirectionTemplate = (args) => ({
|
|
68
77
|
components: { UDatePicker, URow },
|
|
69
78
|
setup() {
|
|
70
79
|
return {
|
|
71
80
|
args,
|
|
72
|
-
directions: argTypes.openDirection.options,
|
|
73
81
|
};
|
|
74
82
|
},
|
|
75
83
|
template: `
|
|
@@ -117,7 +125,7 @@ const SlotTemplate = (args) => ({
|
|
|
117
125
|
});
|
|
118
126
|
|
|
119
127
|
export const Default = DefaultTemplate.bind({});
|
|
120
|
-
Default.args = {
|
|
128
|
+
Default.args = { value: new Date() };
|
|
121
129
|
|
|
122
130
|
export const sizes = SizesTemplate.bind({});
|
|
123
131
|
sizes.args = { label: "" };
|
|
@@ -138,13 +146,17 @@ export const placeholder = DefaultTemplate.bind({});
|
|
|
138
146
|
placeholder.args = { placeholder: "some placeholder" };
|
|
139
147
|
|
|
140
148
|
export const DateFormat = DefaultTemplate.bind({});
|
|
141
|
-
DateFormat.args = { dateFormat: "d.m.Y", userFormat: "d.m.Y",
|
|
149
|
+
DateFormat.args = { dateFormat: "d.m.Y", userFormat: "d.m.Y", value: "28.06.2024" };
|
|
142
150
|
|
|
143
151
|
export const Timepicker = DefaultTemplate.bind({});
|
|
144
|
-
Timepicker.args = { timepicker: true,
|
|
152
|
+
Timepicker.args = { timepicker: true, value: new Date(2024, 2, 14, 12, 24, 14) };
|
|
145
153
|
|
|
146
154
|
export const MinMax = DefaultTemplate.bind({});
|
|
147
|
-
MinMax.args = {
|
|
155
|
+
MinMax.args = {
|
|
156
|
+
minDate: new Date(2022, 2, 22),
|
|
157
|
+
maxDate: new Date(2022, 2, 26),
|
|
158
|
+
value: new Date(2022, 2, 24),
|
|
159
|
+
};
|
|
148
160
|
|
|
149
161
|
export const slotIcon = SlotTemplate.bind({});
|
|
150
162
|
slotIcon.args = {
|
|
@@ -61,11 +61,7 @@ import { VIEW } from "../ui.form-calendar/constants";
|
|
|
61
61
|
|
|
62
62
|
import UIService, { getRandomId } from "../service.ui";
|
|
63
63
|
|
|
64
|
-
import {
|
|
65
|
-
addDays,
|
|
66
|
-
isSameDay,
|
|
67
|
-
getDateFromUnixTimestamp,
|
|
68
|
-
} from "../ui.form-calendar/services/date.service";
|
|
64
|
+
import { addDays, isSameDay } from "../ui.form-calendar/services/date.service";
|
|
69
65
|
|
|
70
66
|
import useAttrs from "./composables/attrs.composable";
|
|
71
67
|
import { useLocale } from "../composable.locale";
|
|
@@ -95,10 +91,10 @@ const props = defineProps({
|
|
|
95
91
|
},
|
|
96
92
|
|
|
97
93
|
/**
|
|
98
|
-
* Datepicker value
|
|
94
|
+
* Datepicker value in JS Date Object or String formatted in provided props.dateFormat.
|
|
99
95
|
*/
|
|
100
96
|
modelValue: {
|
|
101
|
-
type:
|
|
97
|
+
type: [Object, String],
|
|
102
98
|
default: null,
|
|
103
99
|
},
|
|
104
100
|
|
|
@@ -301,7 +297,7 @@ function onBlur(event) {
|
|
|
301
297
|
}
|
|
302
298
|
|
|
303
299
|
function formatUserDate(data) {
|
|
304
|
-
if (props.
|
|
300
|
+
if (props.userFormat !== STANDARD_USER_FORMAT) return data;
|
|
305
301
|
|
|
306
302
|
const i18nGlobal = tm(UDatePicker);
|
|
307
303
|
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
@@ -310,12 +306,11 @@ function formatUserDate(data) {
|
|
|
310
306
|
const formattedDate = data.charAt(0).toUpperCase() + data.toLowerCase().slice(1);
|
|
311
307
|
const formattedDateWithoutDay = formattedDate.split(",").slice(1).join("").trim();
|
|
312
308
|
|
|
313
|
-
const selectedDate = getDateFromUnixTimestamp(localValue.value);
|
|
314
309
|
const today = new Date();
|
|
315
310
|
|
|
316
|
-
const isToday = isSameDay(today,
|
|
317
|
-
const isYesterday = isSameDay(addDays(today, -1),
|
|
318
|
-
const isTomorrow = isSameDay(addDays(today, 1),
|
|
311
|
+
const isToday = isSameDay(today, localValue.value);
|
|
312
|
+
const isYesterday = isSameDay(addDays(today, -1), localValue.value);
|
|
313
|
+
const isTomorrow = isSameDay(addDays(today, 1), localValue.value);
|
|
319
314
|
|
|
320
315
|
if (isToday) {
|
|
321
316
|
prefix = currentLocale.value.today;
|