@citruslime/ui 4.1.0-beta.22 → 4.1.0-beta.23
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 +48 -15
- 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 : {
|
|
@@ -4230,6 +4257,9 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4230
4257
|
const mask = computed(() => {
|
|
4231
4258
|
return generateDatePickerMask(internalLocale.value, props.type);
|
|
4232
4259
|
});
|
|
4260
|
+
const is24Hr = computed(() => {
|
|
4261
|
+
return is24HourFormat(internalLocale.value);
|
|
4262
|
+
});
|
|
4233
4263
|
const input = ref(null);
|
|
4234
4264
|
const currentInitialDate = computed(() => {
|
|
4235
4265
|
return getInitialCalendarDate(model.value, props.initialCalendarDate, internalTimeZone.value, props.type);
|
|
@@ -4289,7 +4319,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4289
4319
|
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => internalCurrentDateTime.value = $event),
|
|
4290
4320
|
modelModifiers: { string: true },
|
|
4291
4321
|
locale: unref(locale2),
|
|
4292
|
-
is24hr:
|
|
4322
|
+
is24hr: is24Hr.value,
|
|
4293
4323
|
mode: _ctx.type,
|
|
4294
4324
|
"is-required": _ctx.required,
|
|
4295
4325
|
"update-on-input": false,
|
|
@@ -4333,7 +4363,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4333
4363
|
modelValue: internalCurrentDateTime.value,
|
|
4334
4364
|
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => internalCurrentDateTime.value = $event),
|
|
4335
4365
|
locale: unref(locale2),
|
|
4336
|
-
is24hr:
|
|
4366
|
+
is24hr: is24Hr.value,
|
|
4337
4367
|
timezone: internalTimeZone.value,
|
|
4338
4368
|
mode: _ctx.type,
|
|
4339
4369
|
"min-date": _ctx.minDate,
|
|
@@ -4423,6 +4453,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4423
4453
|
const props = __props;
|
|
4424
4454
|
const model = useModel(__props, "modelValue");
|
|
4425
4455
|
const internalTimeZone = computed(() => props.timeZone ?? "UTC");
|
|
4456
|
+
const is24Hr = computed(() => is24HourFormat(internalLocale.value));
|
|
4426
4457
|
const internalCurrentDateRange = computed({
|
|
4427
4458
|
get() {
|
|
4428
4459
|
let result = null;
|
|
@@ -4534,6 +4565,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4534
4565
|
mode: "date",
|
|
4535
4566
|
color: "primary",
|
|
4536
4567
|
"title-position": "left",
|
|
4568
|
+
is24hr: is24Hr.value,
|
|
4537
4569
|
"show-weeknumbers": _ctx.showWeekNumbers,
|
|
4538
4570
|
locale: internalLocale.value,
|
|
4539
4571
|
timezone: internalTimeZone.value,
|
|
@@ -4623,7 +4655,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4623
4655
|
])) : createCommentVNode("", true)
|
|
4624
4656
|
]),
|
|
4625
4657
|
_: 1
|
|
4626
|
-
}, 8, ["modelValue", "show-weeknumbers", "locale", "timezone", "columns", "popover", "min-date", "max-date", "initial-page"])
|
|
4658
|
+
}, 8, ["modelValue", "is24hr", "show-weeknumbers", "locale", "timezone", "columns", "popover", "min-date", "max-date", "initial-page"])
|
|
4627
4659
|
]),
|
|
4628
4660
|
_: 2
|
|
4629
4661
|
}, [
|
|
@@ -9861,6 +9893,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9861
9893
|
});
|
|
9862
9894
|
const { locale: locale2 } = useI18n();
|
|
9863
9895
|
const internalLocale = computed(() => props.dateFormatLocale ?? locale2.value);
|
|
9896
|
+
const is24Hr = computed(() => is24HourFormat(internalLocale.value));
|
|
9864
9897
|
const popover = computed(() => {
|
|
9865
9898
|
return getPopoverOptions(props.disabled, "auto");
|
|
9866
9899
|
});
|
|
@@ -9898,7 +9931,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9898
9931
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentDate.value = $event),
|
|
9899
9932
|
modelModifiers: { string: true },
|
|
9900
9933
|
locale: unref(locale2),
|
|
9901
|
-
is24hr:
|
|
9934
|
+
is24hr: is24Hr.value,
|
|
9902
9935
|
mode: _ctx.type,
|
|
9903
9936
|
"is-required": _ctx.required,
|
|
9904
9937
|
"update-on-input": false,
|
|
@@ -9933,7 +9966,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9933
9966
|
color: "primary",
|
|
9934
9967
|
"title-position": "left",
|
|
9935
9968
|
locale: unref(locale2),
|
|
9936
|
-
is24hr:
|
|
9969
|
+
is24hr: is24Hr.value,
|
|
9937
9970
|
timezone: internalTimeZone.value,
|
|
9938
9971
|
columns: dateRangeColumns.value,
|
|
9939
9972
|
popover: popover.value,
|
|
@@ -9976,7 +10009,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9976
10009
|
modelValue: currentDate.value,
|
|
9977
10010
|
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => currentDate.value = $event),
|
|
9978
10011
|
locale: unref(locale2),
|
|
9979
|
-
is24hr:
|
|
10012
|
+
is24hr: is24Hr.value,
|
|
9980
10013
|
timezone: internalTimeZone.value,
|
|
9981
10014
|
mode: _ctx.type,
|
|
9982
10015
|
"min-date": _ctx.min,
|