@citruslime/ui 4.1.0-beta.21 → 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 +49 -17
- 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
|
}, [
|
|
@@ -4948,7 +4980,6 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
4948
4980
|
focus
|
|
4949
4981
|
});
|
|
4950
4982
|
return (_ctx, _cache) => {
|
|
4951
|
-
const _component_icon = resolveComponent("icon");
|
|
4952
4983
|
return openBlock(), createElementBlock("div", {
|
|
4953
4984
|
ref_key: "outsideRef",
|
|
4954
4985
|
ref: outsideRef,
|
|
@@ -5009,7 +5040,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
5009
5040
|
class: "cl:cursor-pointer cl:flex cl:items-center cl:px-2 cl:py-1 cl:relative cl:text-grey-3 cl:z-10",
|
|
5010
5041
|
onClick: _cache[5] || (_cache[5] = withModifiers(($event) => isCurrentlySearchable.value ? toggleSelectModalState(false) : onInputClick(), ["stop", "prevent"]))
|
|
5011
5042
|
}, [
|
|
5012
|
-
createVNode(
|
|
5043
|
+
createVNode(unref(Icon), {
|
|
5013
5044
|
icon: selectModalVisible.value ? "ph:caret-up-bold" : "ph:caret-down-bold"
|
|
5014
5045
|
}, null, 8, ["icon"])
|
|
5015
5046
|
])
|
|
@@ -9862,6 +9893,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9862
9893
|
});
|
|
9863
9894
|
const { locale: locale2 } = useI18n();
|
|
9864
9895
|
const internalLocale = computed(() => props.dateFormatLocale ?? locale2.value);
|
|
9896
|
+
const is24Hr = computed(() => is24HourFormat(internalLocale.value));
|
|
9865
9897
|
const popover = computed(() => {
|
|
9866
9898
|
return getPopoverOptions(props.disabled, "auto");
|
|
9867
9899
|
});
|
|
@@ -9899,7 +9931,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9899
9931
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentDate.value = $event),
|
|
9900
9932
|
modelModifiers: { string: true },
|
|
9901
9933
|
locale: unref(locale2),
|
|
9902
|
-
is24hr:
|
|
9934
|
+
is24hr: is24Hr.value,
|
|
9903
9935
|
mode: _ctx.type,
|
|
9904
9936
|
"is-required": _ctx.required,
|
|
9905
9937
|
"update-on-input": false,
|
|
@@ -9934,7 +9966,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9934
9966
|
color: "primary",
|
|
9935
9967
|
"title-position": "left",
|
|
9936
9968
|
locale: unref(locale2),
|
|
9937
|
-
is24hr:
|
|
9969
|
+
is24hr: is24Hr.value,
|
|
9938
9970
|
timezone: internalTimeZone.value,
|
|
9939
9971
|
columns: dateRangeColumns.value,
|
|
9940
9972
|
popover: popover.value,
|
|
@@ -9977,7 +10009,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
9977
10009
|
modelValue: currentDate.value,
|
|
9978
10010
|
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => currentDate.value = $event),
|
|
9979
10011
|
locale: unref(locale2),
|
|
9980
|
-
is24hr:
|
|
10012
|
+
is24hr: is24Hr.value,
|
|
9981
10013
|
timezone: internalTimeZone.value,
|
|
9982
10014
|
mode: _ctx.type,
|
|
9983
10015
|
"min-date": _ctx.min,
|