@citruslime/ui 4.1.0-beta.22 → 4.1.0-beta.24
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/dist/citrus-lime-ui.es.js +62 -20
- package/dist/citrus-lime-ui.umd.js +2 -2
- package/dist/utils/dates.d.ts +7 -0
- package/package.json +1 -1
|
@@ -3376,13 +3376,21 @@ function getClampedDateValue(minDate, maxDate, currentDate, timeZone, calendarTy
|
|
|
3376
3376
|
value = getMinDateValue(minDate, timeZone, value, calendarType);
|
|
3377
3377
|
return value.toJSDate();
|
|
3378
3378
|
}
|
|
3379
|
+
function is24HourFormat(locale2) {
|
|
3380
|
+
const date = DateTime.fromObject({
|
|
3381
|
+
hour: 14,
|
|
3382
|
+
minute: 30
|
|
3383
|
+
}).setLocale(locale2);
|
|
3384
|
+
const formattedTime = date.toFormat("t");
|
|
3385
|
+
return !/\s?(AM|PM|am|pm|a\.m\.|p\.m\.)/i.test(formattedTime);
|
|
3386
|
+
}
|
|
3379
3387
|
function generateDatePickerMask(locale2, type) {
|
|
3380
3388
|
const date = DateTime.fromObject({
|
|
3381
|
-
day:
|
|
3382
|
-
month:
|
|
3383
|
-
year:
|
|
3384
|
-
hour:
|
|
3385
|
-
minute:
|
|
3389
|
+
day: 13,
|
|
3390
|
+
month: 7,
|
|
3391
|
+
year: 1999,
|
|
3392
|
+
hour: 17,
|
|
3393
|
+
minute: 59
|
|
3386
3394
|
}).setLocale(locale2);
|
|
3387
3395
|
let formattedDate;
|
|
3388
3396
|
if (type === "date") {
|
|
@@ -3392,12 +3400,31 @@ function generateDatePickerMask(locale2, type) {
|
|
|
3392
3400
|
} else {
|
|
3393
3401
|
formattedDate = date.toFormat("t");
|
|
3394
3402
|
}
|
|
3395
|
-
|
|
3396
|
-
|
|
3403
|
+
const uses12Hour = !is24HourFormat(locale2);
|
|
3404
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
3405
|
+
replacements.set("1999", "§YYYY§");
|
|
3406
|
+
replacements.set("99", "§YY§");
|
|
3407
|
+
replacements.set("07", "§MM§");
|
|
3408
|
+
replacements.set("7", "§M§");
|
|
3409
|
+
replacements.set("13", "§DD§");
|
|
3410
|
+
if (uses12Hour) {
|
|
3411
|
+
replacements.set("05", "§hh§");
|
|
3412
|
+
replacements.set("5", "§h§");
|
|
3397
3413
|
} else {
|
|
3398
|
-
|
|
3414
|
+
replacements.set("17", "§HH§");
|
|
3399
3415
|
}
|
|
3400
|
-
|
|
3416
|
+
replacements.set("59", "§mm§");
|
|
3417
|
+
formattedDate = formattedDate.replace(/\s?PM/g, " §A§").replace(/\s?AM/g, " §A§").replace(/\s?pm/g, " §A§").replace(/\s?am/g, " §A§").replace(/\s?p\.m\./gi, " §A§").replace(/\s?a\.m\./gi, " §A§");
|
|
3418
|
+
const sortedReplacements = Array.from(replacements.entries()).sort((a, b) => b[0].length - a[0].length);
|
|
3419
|
+
for (const [
|
|
3420
|
+
searchValue,
|
|
3421
|
+
placeholder
|
|
3422
|
+
] of sortedReplacements) {
|
|
3423
|
+
const regex = new RegExp(`(?<!§)\\b${searchValue}\\b(?!§)`, "g");
|
|
3424
|
+
formattedDate = formattedDate.replace(regex, placeholder);
|
|
3425
|
+
}
|
|
3426
|
+
formattedDate = formattedDate.replace(/§YYYY§/g, "YYYY").replace(/§YY§/g, "YY").replace(/§MM§/g, "MM").replace(/§M§/g, "M").replace(/§DD§/g, "DD").replace(/§D§/g, "D").replace(/§HH§/g, "HH").replace(/§H§/g, "H").replace(/§hh§/g, "hh").replace(/§h§/g, "h").replace(/§mm§/g, "mm").replace(/§m§/g, "m").replace(/§A§/g, "A");
|
|
3427
|
+
return formattedDate.trim();
|
|
3401
3428
|
}
|
|
3402
3429
|
function getPopoverOptions(isNotVisible, popoverPlacement) {
|
|
3403
3430
|
return isNotVisible ? false : {
|
|
@@ -4188,12 +4215,21 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4188
4215
|
return result;
|
|
4189
4216
|
},
|
|
4190
4217
|
set(value) {
|
|
4191
|
-
if (props.
|
|
4192
|
-
model.value
|
|
4193
|
-
|
|
4194
|
-
|
|
4218
|
+
if (!props.required && calendar.value?.inputValue && !value && model.value) {
|
|
4219
|
+
calendar.value.updateValue(model.value, {
|
|
4220
|
+
clearIfEqual: false,
|
|
4221
|
+
formatInput: true,
|
|
4222
|
+
hidePopover: true,
|
|
4223
|
+
moveToValue: true
|
|
4224
|
+
});
|
|
4195
4225
|
} else {
|
|
4196
|
-
|
|
4226
|
+
if (props.type === "time") {
|
|
4227
|
+
model.value = value;
|
|
4228
|
+
} else if (value !== null) {
|
|
4229
|
+
model.value = convertDateToIsoString(value, null, false, props.timeZone);
|
|
4230
|
+
} else {
|
|
4231
|
+
model.value = null;
|
|
4232
|
+
}
|
|
4197
4233
|
}
|
|
4198
4234
|
}
|
|
4199
4235
|
});
|
|
@@ -4230,6 +4266,9 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4230
4266
|
const mask = computed(() => {
|
|
4231
4267
|
return generateDatePickerMask(internalLocale.value, props.type);
|
|
4232
4268
|
});
|
|
4269
|
+
const is24Hr = computed(() => {
|
|
4270
|
+
return is24HourFormat(internalLocale.value);
|
|
4271
|
+
});
|
|
4233
4272
|
const input = ref(null);
|
|
4234
4273
|
const currentInitialDate = computed(() => {
|
|
4235
4274
|
return getInitialCalendarDate(model.value, props.initialCalendarDate, internalTimeZone.value, props.type);
|
|
@@ -4289,7 +4328,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4289
4328
|
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => internalCurrentDateTime.value = $event),
|
|
4290
4329
|
modelModifiers: { string: true },
|
|
4291
4330
|
locale: unref(locale2),
|
|
4292
|
-
is24hr:
|
|
4331
|
+
is24hr: is24Hr.value,
|
|
4293
4332
|
mode: _ctx.type,
|
|
4294
4333
|
"is-required": _ctx.required,
|
|
4295
4334
|
"update-on-input": false,
|
|
@@ -4333,7 +4372,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4333
4372
|
modelValue: internalCurrentDateTime.value,
|
|
4334
4373
|
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => internalCurrentDateTime.value = $event),
|
|
4335
4374
|
locale: unref(locale2),
|
|
4336
|
-
is24hr:
|
|
4375
|
+
is24hr: is24Hr.value,
|
|
4337
4376
|
timezone: internalTimeZone.value,
|
|
4338
4377
|
mode: _ctx.type,
|
|
4339
4378
|
"min-date": _ctx.minDate,
|
|
@@ -4423,6 +4462,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4423
4462
|
const props = __props;
|
|
4424
4463
|
const model = useModel(__props, "modelValue");
|
|
4425
4464
|
const internalTimeZone = computed(() => props.timeZone ?? "UTC");
|
|
4465
|
+
const is24Hr = computed(() => is24HourFormat(internalLocale.value));
|
|
4426
4466
|
const internalCurrentDateRange = computed({
|
|
4427
4467
|
get() {
|
|
4428
4468
|
let result = null;
|
|
@@ -4534,6 +4574,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4534
4574
|
mode: "date",
|
|
4535
4575
|
color: "primary",
|
|
4536
4576
|
"title-position": "left",
|
|
4577
|
+
is24hr: is24Hr.value,
|
|
4537
4578
|
"show-weeknumbers": _ctx.showWeekNumbers,
|
|
4538
4579
|
locale: internalLocale.value,
|
|
4539
4580
|
timezone: internalTimeZone.value,
|
|
@@ -4623,7 +4664,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4623
4664
|
])) : createCommentVNode("", true)
|
|
4624
4665
|
]),
|
|
4625
4666
|
_: 1
|
|
4626
|
-
}, 8, ["modelValue", "show-weeknumbers", "locale", "timezone", "columns", "popover", "min-date", "max-date", "initial-page"])
|
|
4667
|
+
}, 8, ["modelValue", "is24hr", "show-weeknumbers", "locale", "timezone", "columns", "popover", "min-date", "max-date", "initial-page"])
|
|
4627
4668
|
]),
|
|
4628
4669
|
_: 2
|
|
4629
4670
|
}, [
|
|
@@ -9861,6 +9902,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9861
9902
|
});
|
|
9862
9903
|
const { locale: locale2 } = useI18n();
|
|
9863
9904
|
const internalLocale = computed(() => props.dateFormatLocale ?? locale2.value);
|
|
9905
|
+
const is24Hr = computed(() => is24HourFormat(internalLocale.value));
|
|
9864
9906
|
const popover = computed(() => {
|
|
9865
9907
|
return getPopoverOptions(props.disabled, "auto");
|
|
9866
9908
|
});
|
|
@@ -9898,7 +9940,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9898
9940
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentDate.value = $event),
|
|
9899
9941
|
modelModifiers: { string: true },
|
|
9900
9942
|
locale: unref(locale2),
|
|
9901
|
-
is24hr:
|
|
9943
|
+
is24hr: is24Hr.value,
|
|
9902
9944
|
mode: _ctx.type,
|
|
9903
9945
|
"is-required": _ctx.required,
|
|
9904
9946
|
"update-on-input": false,
|
|
@@ -9933,7 +9975,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9933
9975
|
color: "primary",
|
|
9934
9976
|
"title-position": "left",
|
|
9935
9977
|
locale: unref(locale2),
|
|
9936
|
-
is24hr:
|
|
9978
|
+
is24hr: is24Hr.value,
|
|
9937
9979
|
timezone: internalTimeZone.value,
|
|
9938
9980
|
columns: dateRangeColumns.value,
|
|
9939
9981
|
popover: popover.value,
|
|
@@ -9976,7 +10018,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9976
10018
|
modelValue: currentDate.value,
|
|
9977
10019
|
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => currentDate.value = $event),
|
|
9978
10020
|
locale: unref(locale2),
|
|
9979
|
-
is24hr:
|
|
10021
|
+
is24hr: is24Hr.value,
|
|
9980
10022
|
timezone: internalTimeZone.value,
|
|
9981
10023
|
mode: _ctx.type,
|
|
9982
10024
|
"min-date": _ctx.min,
|