@citizenplane/pimp 8.0.0 → 8.0.1

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/pimp.es.js CHANGED
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, createCommentVNode, createElementVNode, resolveDynamicComponent, mergeProps, withCtx, createVNode, createTextVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, vModelSelect, defineComponent, watch, h as h$1, resolveDirective, Transition, normalizeStyle, withKeys, TransitionGroup, vShow, withModifiers, vModelCheckbox } from "vue";
32
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, createCommentVNode, createElementVNode, resolveDynamicComponent, mergeProps, withCtx, createVNode, resolveDirective, createTextVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, vModelSelect, defineComponent, watch, h as h$1, Transition, normalizeStyle, withKeys, TransitionGroup, vShow, ref, withModifiers, vModelCheckbox } from "vue";
33
33
  function _mergeNamespaces(n2, m) {
34
34
  m.forEach(function(e2) {
35
35
  e2 && typeof e2 !== "string" && !Array.isArray(e2) && Object.keys(e2).forEach(function(k2) {
@@ -461,15 +461,14 @@ function floorMod(x, n2) {
461
461
  return x - n2 * Math.floor(x / n2);
462
462
  }
463
463
  function padStart(input, n2 = 2) {
464
- const minus = input < 0 ? "-" : "";
465
- const target = minus ? input * -1 : input;
466
- let result;
467
- if (target.toString().length < n2) {
468
- result = ("0".repeat(n2) + target).slice(-n2);
464
+ const isNeg = input < 0;
465
+ let padded;
466
+ if (isNeg) {
467
+ padded = "-" + ("" + -input).padStart(n2, "0");
469
468
  } else {
470
- result = target.toString();
469
+ padded = ("" + input).padStart(n2, "0");
471
470
  }
472
- return `${minus}${result}`;
471
+ return padded;
473
472
  }
474
473
  function parseInteger(string) {
475
474
  if (isUndefined(string) || string === null || string === "") {
@@ -1309,6 +1308,16 @@ class Settings {
1309
1308
  IANAZone.resetCache();
1310
1309
  }
1311
1310
  }
1311
+ let intlLFCache = {};
1312
+ function getCachedLF(locString, opts = {}) {
1313
+ const key = JSON.stringify([locString, opts]);
1314
+ let dtf = intlLFCache[key];
1315
+ if (!dtf) {
1316
+ dtf = new Intl.ListFormat(locString, opts);
1317
+ intlLFCache[key] = dtf;
1318
+ }
1319
+ return dtf;
1320
+ }
1312
1321
  let intlDTCache = {};
1313
1322
  function getCachedDTF(locString, opts = {}) {
1314
1323
  const key = JSON.stringify([locString, opts]);
@@ -1416,8 +1425,9 @@ class PolyNumberFormatter {
1416
1425
  constructor(intl, forceSimple, opts) {
1417
1426
  this.padTo = opts.padTo || 0;
1418
1427
  this.floor = opts.floor || false;
1419
- if (!forceSimple) {
1420
- const intlOpts = { useGrouping: false };
1428
+ const _a = opts, { padTo, floor } = _a, otherOpts = __objRest(_a, ["padTo", "floor"]);
1429
+ if (!forceSimple || Object.keys(otherOpts).length > 0) {
1430
+ const intlOpts = __spreadValues({ useGrouping: false }, opts);
1421
1431
  if (opts.padTo > 0)
1422
1432
  intlOpts.minimumIntegerDigits = opts.padTo;
1423
1433
  this.inf = getCachedINF(intl, intlOpts);
@@ -1534,7 +1544,7 @@ class Locale {
1534
1544
  }
1535
1545
  return this.fastNumbersCached;
1536
1546
  }
1537
- listingMode(defaultOK = true) {
1547
+ listingMode() {
1538
1548
  const isActuallyEn = this.isEnglish();
1539
1549
  const hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
1540
1550
  return isActuallyEn && hasNoWeirdness ? "en" : "intl";
@@ -1601,6 +1611,9 @@ class Locale {
1601
1611
  relFormatter(opts = {}) {
1602
1612
  return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
1603
1613
  }
1614
+ listFormatter(opts = {}) {
1615
+ return getCachedLF(this.intl, opts);
1616
+ }
1604
1617
  isEnglish() {
1605
1618
  return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
1606
1619
  }
@@ -2001,6 +2014,16 @@ class Duration {
2001
2014
  });
2002
2015
  return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID$2;
2003
2016
  }
2017
+ toHuman(opts = {}) {
2018
+ const l2 = orderedUnits$1.map((unit) => {
2019
+ const val = this.values[unit];
2020
+ if (isUndefined(val)) {
2021
+ return null;
2022
+ }
2023
+ return this.loc.numberFormatter(__spreadProps(__spreadValues({ style: "unit", unitDisplay: "long" }, opts), { unit: unit.slice(0, -1) })).format(val);
2024
+ }).filter((n2) => n2);
2025
+ return this.loc.listFormatter(__spreadValues({ type: "conjunction", style: opts.listStyle || "narrow" }, opts)).format(l2);
2026
+ }
2004
2027
  toObject() {
2005
2028
  if (!this.isValid)
2006
2029
  return {};
@@ -3190,35 +3213,57 @@ function toTechFormat(dt, format, allowZ = true) {
3190
3213
  forceSimple: true
3191
3214
  }).formatDateTimeFromString(dt, format) : null;
3192
3215
  }
3193
- function toTechTimeFormat(dt, {
3194
- suppressSeconds = false,
3195
- suppressMilliseconds = false,
3196
- includeOffset,
3197
- includePrefix = false,
3198
- includeZone = false,
3199
- spaceZone = false,
3200
- format = "extended"
3201
- }) {
3202
- let fmt = format === "basic" ? "HHmm" : "HH:mm";
3203
- if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
3204
- fmt += format === "basic" ? "ss" : ":ss";
3205
- if (!suppressMilliseconds || dt.millisecond !== 0) {
3206
- fmt += ".SSS";
3207
- }
3208
- }
3209
- if ((includeZone || includeOffset) && spaceZone) {
3210
- fmt += " ";
3211
- }
3212
- if (includeZone) {
3213
- fmt += "z";
3214
- } else if (includeOffset) {
3215
- fmt += format === "basic" ? "ZZZ" : "ZZ";
3216
+ function toISODate(o2, extended) {
3217
+ const longFormat = o2.c.year > 9999 || o2.c.year < 0;
3218
+ let c2 = "";
3219
+ if (longFormat && o2.c.year >= 0)
3220
+ c2 += "+";
3221
+ c2 += padStart(o2.c.year, longFormat ? 6 : 4);
3222
+ if (extended) {
3223
+ c2 += "-";
3224
+ c2 += padStart(o2.c.month);
3225
+ c2 += "-";
3226
+ c2 += padStart(o2.c.day);
3227
+ } else {
3228
+ c2 += padStart(o2.c.month);
3229
+ c2 += padStart(o2.c.day);
3216
3230
  }
3217
- let str = toTechFormat(dt, fmt);
3218
- if (includePrefix) {
3219
- str = "T" + str;
3231
+ return c2;
3232
+ }
3233
+ function toISOTime(o2, extended, suppressSeconds, suppressMilliseconds, includeOffset) {
3234
+ let c2 = padStart(o2.c.hour);
3235
+ if (extended) {
3236
+ c2 += ":";
3237
+ c2 += padStart(o2.c.minute);
3238
+ if (o2.c.second !== 0 || !suppressSeconds) {
3239
+ c2 += ":";
3240
+ }
3241
+ } else {
3242
+ c2 += padStart(o2.c.minute);
3243
+ }
3244
+ if (o2.c.second !== 0 || !suppressSeconds) {
3245
+ c2 += padStart(o2.c.second);
3246
+ if (o2.c.millisecond !== 0 || !suppressMilliseconds) {
3247
+ c2 += ".";
3248
+ c2 += padStart(o2.c.millisecond, 3);
3249
+ }
3250
+ }
3251
+ if (includeOffset) {
3252
+ if (o2.isOffsetFixed && o2.offset === 0) {
3253
+ c2 += "Z";
3254
+ } else if (o2.o < 0) {
3255
+ c2 += "-";
3256
+ c2 += padStart(Math.trunc(-o2.o / 60));
3257
+ c2 += ":";
3258
+ c2 += padStart(Math.trunc(-o2.o % 60));
3259
+ } else {
3260
+ c2 += "+";
3261
+ c2 += padStart(Math.trunc(o2.o / 60));
3262
+ c2 += ":";
3263
+ c2 += padStart(Math.trunc(o2.o % 60));
3264
+ }
3220
3265
  }
3221
- return str;
3266
+ return c2;
3222
3267
  }
3223
3268
  const defaultUnitValues = {
3224
3269
  month: 1,
@@ -3746,18 +3791,26 @@ class DateTime {
3746
3791
  toLocaleParts(opts = {}) {
3747
3792
  return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
3748
3793
  }
3749
- toISO(opts = {}) {
3794
+ toISO({
3795
+ format = "extended",
3796
+ suppressSeconds = false,
3797
+ suppressMilliseconds = false,
3798
+ includeOffset = true
3799
+ } = {}) {
3750
3800
  if (!this.isValid) {
3751
3801
  return null;
3752
3802
  }
3753
- return `${this.toISODate(opts)}T${this.toISOTime(opts)}`;
3803
+ const ext = format === "extended";
3804
+ let c2 = toISODate(this, ext);
3805
+ c2 += "T";
3806
+ c2 += toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset);
3807
+ return c2;
3754
3808
  }
3755
3809
  toISODate({ format = "extended" } = {}) {
3756
- let fmt = format === "basic" ? "yyyyMMdd" : "yyyy-MM-dd";
3757
- if (this.year > 9999) {
3758
- fmt = "+" + fmt;
3810
+ if (!this.isValid) {
3811
+ return null;
3759
3812
  }
3760
- return toTechFormat(this, fmt);
3813
+ return toISODate(this, format === "extended");
3761
3814
  }
3762
3815
  toISOWeekDate() {
3763
3816
  return toTechFormat(this, "kkkk-'W'WW-c");
@@ -3769,13 +3822,11 @@ class DateTime {
3769
3822
  includePrefix = false,
3770
3823
  format = "extended"
3771
3824
  } = {}) {
3772
- return toTechTimeFormat(this, {
3773
- suppressSeconds,
3774
- suppressMilliseconds,
3775
- includeOffset,
3776
- includePrefix,
3777
- format
3778
- });
3825
+ if (!this.isValid) {
3826
+ return null;
3827
+ }
3828
+ let c2 = includePrefix ? "T" : "";
3829
+ return c2 + toISOTime(this, format === "extended", suppressSeconds, suppressMilliseconds, includeOffset);
3779
3830
  }
3780
3831
  toRFC2822() {
3781
3832
  return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
@@ -3784,14 +3835,22 @@ class DateTime {
3784
3835
  return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
3785
3836
  }
3786
3837
  toSQLDate() {
3787
- return toTechFormat(this, "yyyy-MM-dd");
3838
+ if (!this.isValid) {
3839
+ return null;
3840
+ }
3841
+ return toISODate(this, true);
3788
3842
  }
3789
3843
  toSQLTime({ includeOffset = true, includeZone = false } = {}) {
3790
- return toTechTimeFormat(this, {
3791
- includeOffset,
3792
- includeZone,
3793
- spaceZone: true
3794
- });
3844
+ let fmt = "HH:mm:ss.SSS";
3845
+ if (includeZone || includeOffset) {
3846
+ fmt += " ";
3847
+ if (includeZone) {
3848
+ fmt += "z";
3849
+ } else if (includeOffset) {
3850
+ fmt += "ZZ";
3851
+ }
3852
+ }
3853
+ return toTechFormat(this, fmt, true);
3795
3854
  }
3796
3855
  toSQL(opts = {}) {
3797
3856
  if (!this.isValid) {
@@ -3849,8 +3908,8 @@ class DateTime {
3849
3908
  if (!this.isValid)
3850
3909
  return false;
3851
3910
  const inputMs = otherDateTime.valueOf();
3852
- const otherZoneDateTime = this.setZone(otherDateTime.zone, { keepLocalTime: true });
3853
- return otherZoneDateTime.startOf(unit) <= inputMs && inputMs <= otherZoneDateTime.endOf(unit);
3911
+ const adjustedToZone = this.setZone(otherDateTime.zone, { keepLocalTime: true });
3912
+ return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit);
3854
3913
  }
3855
3914
  equals(other) {
3856
3915
  return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
@@ -4349,6 +4408,18 @@ const _sfc_main$g = {
4349
4408
  disabled: {
4350
4409
  type: Boolean,
4351
4410
  default: false
4411
+ },
4412
+ isInvalid: {
4413
+ type: Boolean,
4414
+ default: false
4415
+ },
4416
+ errorMessage: {
4417
+ type: String,
4418
+ default: ""
4419
+ },
4420
+ autocompleteBirthday: {
4421
+ type: Boolean,
4422
+ default: false
4352
4423
  }
4353
4424
  },
4354
4425
  emits: ["update:modelValue", "on-validation"],
@@ -4412,11 +4483,9 @@ const _sfc_main$g = {
4412
4483
  return this.day === "" && this.month === "" && this.year === "";
4413
4484
  },
4414
4485
  isDateValid() {
4415
- if (!this.required && this.areInputsEmpty)
4486
+ if (this.areInputsEmpty && !this.errorMessage)
4416
4487
  return true;
4417
- const isValid = this.isDayValid && this.isMonthValid && this.isYearValid && this.isDateBeforeMaxDate && this.isDateAfterMinDate;
4418
- this.$emit("on-validation", isValid);
4419
- return isValid;
4488
+ return !this.isInvalid && this.isDayValid && this.isMonthValid && this.isYearValid && this.isDateBeforeMaxDate && this.isDateAfterMinDate;
4420
4489
  },
4421
4490
  isDayValid() {
4422
4491
  return this.day >= 1 && this.day <= this.monthMaxDay;
@@ -4430,10 +4499,11 @@ const _sfc_main$g = {
4430
4499
  areAllFieldsEmpty() {
4431
4500
  return !this.day && !this.month && !this.year;
4432
4501
  },
4433
- errorMessage() {
4434
- if (this.areAllFieldsEmpty && this.required) {
4435
- return `The ${this.label} field is required.`;
4436
- }
4502
+ advancedErrorMessage() {
4503
+ if (this.isDateValid)
4504
+ return "";
4505
+ if (this.errorMessage)
4506
+ return this.errorMessage;
4437
4507
  if (!this.isMonthValid) {
4438
4508
  return "Month is required.";
4439
4509
  }
@@ -4463,6 +4533,15 @@ const _sfc_main$g = {
4463
4533
  return {
4464
4534
  "cpDate__month--isEmpty": !this.month
4465
4535
  };
4536
+ },
4537
+ autocompleteFields() {
4538
+ if (!this.autocompleteBirthday)
4539
+ return "off";
4540
+ return {
4541
+ day: "bday-day",
4542
+ month: "bday-month",
4543
+ year: "bday-year"
4544
+ };
4466
4545
  }
4467
4546
  },
4468
4547
  watch: {
@@ -4471,7 +4550,6 @@ const _sfc_main$g = {
4471
4550
  },
4472
4551
  month() {
4473
4552
  this.handleUpdate();
4474
- this.focusOnFirstEmptyInput();
4475
4553
  },
4476
4554
  year() {
4477
4555
  this.handleUpdate();
@@ -4484,31 +4562,20 @@ const _sfc_main$g = {
4484
4562
  return DateTime.fromISO(this.modelValue)[token];
4485
4563
  },
4486
4564
  handleUpdate() {
4487
- const dateValue = this.isDateValid ? this.isoDate : "Invalid Datetime";
4488
- this.$emit("update:modelValue", dateValue);
4489
- },
4490
- focusOnFirstEmptyInput() {
4491
- if (!this.isDayValid) {
4492
- this.$refs.day.focus();
4493
- return;
4494
- }
4495
- if (!this.isYearValid)
4496
- this.$refs.year.focus();
4565
+ this.$emit("update:modelValue", this.isoDate);
4566
+ this.$emit("on-validation", this.isDateValid);
4497
4567
  }
4498
4568
  }
4499
4569
  };
4500
4570
  const _hoisted_1$d = ["for"];
4501
4571
  const _hoisted_2$c = { class: "cpDate__inputs" };
4502
- const _hoisted_3$9 = ["required", "disabled"];
4572
+ const _hoisted_3$9 = ["required", "disabled", "autocomplete"];
4503
4573
  const _hoisted_4$9 = /* @__PURE__ */ createElementVNode("div", { class: "cpDate__divider" }, null, -1);
4504
- const _hoisted_5$7 = ["id", "required", "disabled"];
4505
- const _hoisted_6$6 = /* @__PURE__ */ createElementVNode("option", {
4506
- value: "",
4507
- disabled: ""
4508
- }, "Month", -1);
4574
+ const _hoisted_5$7 = ["id", "required", "disabled", "autocomplete"];
4575
+ const _hoisted_6$6 = /* @__PURE__ */ createElementVNode("option", { value: "" }, "Month", -1);
4509
4576
  const _hoisted_7$5 = ["value"];
4510
4577
  const _hoisted_8$4 = /* @__PURE__ */ createElementVNode("div", { class: "cpDate__divider" }, null, -1);
4511
- const _hoisted_9$4 = ["min", "max", "disabled", "required"];
4578
+ const _hoisted_9$4 = ["disabled", "required", "autocomplete"];
4512
4579
  const _hoisted_10$4 = {
4513
4580
  key: 0,
4514
4581
  class: "cpDate__errorMessage"
@@ -4516,6 +4583,7 @@ const _hoisted_10$4 = {
4516
4583
  function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
4517
4584
  const _component_cp_icon = resolveComponent("cp-icon");
4518
4585
  const _component_transition_expand = resolveComponent("transition-expand");
4586
+ const _directive_maska = resolveDirective("maska");
4519
4587
  return openBlock(), createElementBlock("div", {
4520
4588
  class: normalizeClass(["cpDate", $options.dynamicClasses])
4521
4589
  }, [
@@ -4532,19 +4600,17 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
4532
4600
  ], 8, _hoisted_1$d)) : createCommentVNode("", true),
4533
4601
  createElementVNode("div", _hoisted_2$c, [
4534
4602
  withDirectives(createElementVNode("input", {
4535
- ref: "day",
4536
4603
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.day = $event),
4537
4604
  placeholder: "DD",
4538
4605
  class: "cpDate__day",
4539
- type: "number",
4540
4606
  inputmode: "numeric",
4541
- min: 1,
4542
- max: 31,
4543
4607
  maxlength: "2",
4544
4608
  required: $props.required,
4545
- disabled: $props.disabled
4609
+ disabled: $props.disabled,
4610
+ autocomplete: $options.autocompleteFields.day
4546
4611
  }, null, 8, _hoisted_3$9), [
4547
- [vModelText, $data.day]
4612
+ [vModelText, $data.day],
4613
+ [_directive_maska, "##"]
4548
4614
  ]),
4549
4615
  _hoisted_4$9,
4550
4616
  createElementVNode("div", {
@@ -4554,7 +4620,8 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
4554
4620
  id: $options.cpDateId,
4555
4621
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $data.month = $event),
4556
4622
  required: $props.required,
4557
- disabled: $props.disabled
4623
+ disabled: $props.disabled,
4624
+ autocomplete: $options.autocompleteFields.month
4558
4625
  }, [
4559
4626
  _hoisted_6$6,
4560
4627
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.months, (monthItem, index) => {
@@ -4569,24 +4636,22 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
4569
4636
  ], 2),
4570
4637
  _hoisted_8$4,
4571
4638
  withDirectives(createElementVNode("input", {
4572
- ref: "year",
4573
4639
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => $data.year = $event),
4574
4640
  placeholder: "YYYY",
4575
4641
  class: "cpDate__year",
4576
- type: "number",
4577
4642
  inputmode: "numeric",
4578
- min: $options.minYear,
4579
- max: $options.maxYear,
4580
4643
  maxlength: "4",
4581
4644
  disabled: $props.disabled,
4582
- required: $props.required
4645
+ required: $props.required,
4646
+ autocomplete: $options.autocompleteFields.year
4583
4647
  }, null, 8, _hoisted_9$4), [
4584
- [vModelText, $data.year]
4648
+ [vModelText, $data.year],
4649
+ [_directive_maska, "####"]
4585
4650
  ])
4586
4651
  ]),
4587
4652
  createVNode(_component_transition_expand, null, {
4588
4653
  default: withCtx(() => [
4589
- !$options.isDateValid ? (openBlock(), createElementBlock("div", _hoisted_10$4, toDisplayString($options.errorMessage), 1)) : createCommentVNode("", true)
4654
+ $options.advancedErrorMessage ? (openBlock(), createElementBlock("div", _hoisted_10$4, toDisplayString($options.advancedErrorMessage), 1)) : createCommentVNode("", true)
4590
4655
  ]),
4591
4656
  _: 1
4592
4657
  })
@@ -7138,20 +7203,6 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7138
7203
  }
7139
7204
  var TransitionExpand = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["__scopeId", "data-v-d29b8092"]]);
7140
7205
  var CpInput_vue_vue_type_style_index_0_lang = "";
7141
- const inputTypesList = [
7142
- "text",
7143
- "date",
7144
- "datetime-local",
7145
- "email",
7146
- "month",
7147
- "number",
7148
- "password",
7149
- "search",
7150
- "tel",
7151
- "time",
7152
- "url",
7153
- "week"
7154
- ];
7155
7206
  const _sfc_main$b = {
7156
7207
  name: "CpInput",
7157
7208
  components: {
@@ -7159,6 +7210,7 @@ const _sfc_main$b = {
7159
7210
  BaseInputLabel,
7160
7211
  TransitionExpand
7161
7212
  },
7213
+ inheritAttrs: false,
7162
7214
  props: {
7163
7215
  modelValue: {
7164
7216
  type: [String, Number, Boolean],
@@ -7168,46 +7220,10 @@ const _sfc_main$b = {
7168
7220
  type: String,
7169
7221
  default: ""
7170
7222
  },
7171
- placeholder: {
7172
- type: String,
7173
- default: "",
7174
- required: true
7175
- },
7176
- required: {
7177
- type: Boolean,
7178
- default: false
7179
- },
7180
7223
  inputId: {
7181
7224
  type: String,
7182
- default: ""
7183
- },
7184
- type: {
7185
- type: String,
7186
- default: inputTypesList[0],
7187
- validator: (value) => {
7188
- return inputTypesList.includes(value);
7189
- }
7190
- },
7191
- name: {
7192
- type: String,
7193
- default: ""
7194
- },
7195
- readonly: {
7196
- type: Boolean,
7197
- default: false
7198
- },
7199
- disabled: {
7200
- type: Boolean,
7201
7225
  default: null
7202
7226
  },
7203
- autocomplete: {
7204
- type: String,
7205
- default: "on"
7206
- },
7207
- inputMode: {
7208
- type: String,
7209
- default: "text"
7210
- },
7211
7227
  isInvalid: {
7212
7228
  type: Boolean,
7213
7229
  default: false
@@ -7234,18 +7250,35 @@ const _sfc_main$b = {
7234
7250
  }
7235
7251
  },
7236
7252
  emits: ["update:modelValue"],
7253
+ setup(props, { attrs }) {
7254
+ const _a = attrs, { ["class"]: value, id } = _a, restAttributes = __objRest(_a, ["class", "id"]);
7255
+ const inputIdentifier = id === void 0 ? ref(randomString()) : id;
7256
+ return {
7257
+ inputIdentifier,
7258
+ restAttributes
7259
+ };
7260
+ },
7237
7261
  data() {
7238
7262
  return {
7239
- inputReferenceId: this.inputId,
7240
7263
  isDOMElementValid: true
7241
7264
  };
7242
7265
  },
7243
7266
  computed: {
7267
+ isDisabled() {
7268
+ return this.checkAttribute("disabled");
7269
+ },
7270
+ isRequired() {
7271
+ return this.checkAttribute("required");
7272
+ },
7273
+ isReadonly() {
7274
+ return this.checkAttribute("readonly");
7275
+ },
7244
7276
  dynamicClasses() {
7245
7277
  return [
7278
+ this.$attrs.class,
7246
7279
  {
7247
7280
  "cpInput--isInvalid": this.isInputInvalid,
7248
- "cpInput--isDisabled": this.disabled,
7281
+ "cpInput--isDisabled": this.isDisabled,
7249
7282
  "cpInput--hasNoBorder": this.removeBorder,
7250
7283
  "cpInput--isLarge": this.isLarge
7251
7284
  }
@@ -7259,11 +7292,13 @@ const _sfc_main$b = {
7259
7292
  };
7260
7293
  },
7261
7294
  inputLabelTitle() {
7262
- const requiredLabel = this.required && this.label ? "*" : "";
7263
- return `${this.label} ${requiredLabel}`;
7295
+ if (this.label === "")
7296
+ return "";
7297
+ const requiredMark = this.isRequired ? "*" : "";
7298
+ return `${this.label} ${requiredMark}`;
7264
7299
  },
7265
7300
  isValid() {
7266
- return this.modelValue && !this.readonly && !this.isInvalid && this.isDOMElementValid;
7301
+ return this.modelValue && !this.isReadonly && !this.isInvalid && this.isDOMElementValid;
7267
7302
  },
7268
7303
  isInputInvalid() {
7269
7304
  return this.isInvalid || !this.isDOMElementValid;
@@ -7275,15 +7310,11 @@ const _sfc_main$b = {
7275
7310
  return !!this.$slots["input-icon-after"];
7276
7311
  },
7277
7312
  DOMElement() {
7278
- return this.$refs.cpInputContainer.children.namedItem(this.inputReferenceId);
7313
+ return this.$refs.cpInputContainer.children.namedItem(this.inputIdentifier);
7279
7314
  }
7280
7315
  },
7281
7316
  mounted() {
7282
- if (!this.inputReferenceId)
7283
- this.inputReferenceId = randomString();
7284
- this.$nextTick(() => {
7285
- this.checkInputValidity();
7286
- });
7317
+ this.$nextTick(() => this.checkInputValidity());
7287
7318
  },
7288
7319
  methods: {
7289
7320
  handleChange(e2) {
@@ -7299,6 +7330,9 @@ const _sfc_main$b = {
7299
7330
  if (!this.DOMElement)
7300
7331
  return false;
7301
7332
  this.isDOMElementValid = this.DOMElement.validity && this.DOMElement.validity.valid || this.DOMElement.validity && this.DOMElement.validity.valueMissing;
7333
+ },
7334
+ checkAttribute(attribute) {
7335
+ return this.$attrs[attribute] === "" || this.$attrs[attribute] === true;
7302
7336
  }
7303
7337
  }
7304
7338
  };
@@ -7311,7 +7345,7 @@ const _hoisted_3$7 = {
7311
7345
  key: 2,
7312
7346
  class: "cpInput__icon cpInput__icon--isAfter"
7313
7347
  };
7314
- const _hoisted_4$7 = ["id", "disabled", "name", "placeholder", "readonly", "required", "autocomplete", "inputmode", "type", "value"];
7348
+ const _hoisted_4$7 = ["id", "value"];
7315
7349
  function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
7316
7350
  const _component_base_input_label = resolveComponent("base-input-label");
7317
7351
  const _component_cp_icon = resolveComponent("cp-icon");
@@ -7319,12 +7353,13 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
7319
7353
  const _directive_maska = resolveDirective("maska");
7320
7354
  return openBlock(), createElementBlock("div", {
7321
7355
  class: normalizeClass(["cpInput", $options.dynamicClasses]),
7322
- "aria-disabled": $props.disabled,
7356
+ "aria-disabled": $options.isDisabled,
7323
7357
  onClick: _cache[1] || (_cache[1] = (...args) => $options.focusOnInput && $options.focusOnInput(...args))
7324
7358
  }, [
7325
7359
  $props.label ? (openBlock(), createBlock(_component_base_input_label, {
7326
7360
  key: 0,
7327
- for: $data.inputReferenceId
7361
+ for: $setup.inputIdentifier,
7362
+ class: "cpInput__label"
7328
7363
  }, {
7329
7364
  default: withCtx(() => [
7330
7365
  createTextVNode(toDisplayString($options.inputLabelTitle), 1)
@@ -7358,20 +7393,13 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
7358
7393
  $options.hasAfterIcon ? (openBlock(), createElementBlock("div", _hoisted_3$7, [
7359
7394
  renderSlot(_ctx.$slots, "input-icon-after")
7360
7395
  ])) : createCommentVNode("", true),
7361
- withDirectives(createElementVNode("input", {
7362
- id: $data.inputReferenceId,
7363
- disabled: $props.disabled,
7364
- name: $props.name,
7365
- placeholder: $props.placeholder,
7366
- readonly: $props.readonly,
7367
- required: $props.required,
7368
- autocomplete: $props.autocomplete,
7369
- inputmode: $props.inputMode,
7370
- type: $props.type,
7371
- value: $props.modelValue,
7396
+ withDirectives(createElementVNode("input", mergeProps({
7397
+ id: $setup.inputIdentifier,
7398
+ value: $props.modelValue
7399
+ }, $setup.restAttributes, {
7372
7400
  class: "cpInput__inner",
7373
7401
  onInput: _cache[0] || (_cache[0] = (...args) => $options.handleChange && $options.handleChange(...args))
7374
- }, null, 40, _hoisted_4$7), [
7402
+ }), null, 16, _hoisted_4$7), [
7375
7403
  [_directive_maska, $props.mask]
7376
7404
  ])
7377
7405
  ], 2),
@@ -7380,7 +7408,8 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
7380
7408
  $options.isInputInvalid && $props.errorMessage ? (openBlock(), createBlock(_component_base_input_label, {
7381
7409
  key: 0,
7382
7410
  "is-invalid": $props.isInvalid,
7383
- for: $data.inputReferenceId
7411
+ for: $setup.inputIdentifier,
7412
+ class: "cpInput__label cpInput__label--isAfter"
7384
7413
  }, {
7385
7414
  default: withCtx(() => [
7386
7415
  createTextVNode(toDisplayString($props.errorMessage), 1)
@@ -7522,16 +7551,16 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
7522
7551
  const _component_core_datepicker = resolveComponent("core-datepicker");
7523
7552
  return openBlock(), createElementBlock("div", _hoisted_1$a, [
7524
7553
  withDirectives(createVNode(_component_cp_input, {
7554
+ id: $data.datePickerReferenceId,
7525
7555
  "model-value": $options.inputComputedValue,
7526
7556
  type: "text",
7527
- "input-id": $data.datePickerReferenceId,
7528
7557
  placeholder: $props.placeholder,
7529
7558
  "is-invalid": $props.isError,
7530
7559
  "error-message": $props.errorMessage,
7531
7560
  disabled: $data.isDisabled,
7532
7561
  label: $props.label,
7533
7562
  class: "cpDatepicker__input"
7534
- }, null, 8, ["model-value", "input-id", "placeholder", "is-invalid", "error-message", "disabled", "label"]), [
7563
+ }, null, 8, ["id", "model-value", "placeholder", "is-invalid", "error-message", "disabled", "label"]), [
7535
7564
  [vShow, !$props.isInline]
7536
7565
  ]),
7537
7566
  createVNode(_component_core_datepicker, {
@@ -7731,8 +7760,8 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
7731
7760
  const _component_core_datepicker = resolveComponent("core-datepicker");
7732
7761
  return openBlock(), createElementBlock("div", _hoisted_1$9, [
7733
7762
  createVNode(_component_cp_input, {
7763
+ id: $props.triggerElementId,
7734
7764
  type: "text",
7735
- "input-id": $props.triggerElementId,
7736
7765
  "model-value": $options.humanDateFormat($data.dateOne, $data.dateTwo),
7737
7766
  placeholder: "Select a date",
7738
7767
  "is-invalid": $props.isError,
@@ -7740,7 +7769,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
7740
7769
  disabled: $data.isDisabled,
7741
7770
  label: $props.label,
7742
7771
  class: "cpCalendar__input"
7743
- }, null, 8, ["input-id", "model-value", "is-invalid", "error-message", "disabled", "label"]),
7772
+ }, null, 8, ["id", "model-value", "is-invalid", "error-message", "disabled", "label"]),
7744
7773
  createVNode(_component_core_datepicker, {
7745
7774
  "date-one": $data.dateOne,
7746
7775
  "date-two": $data.dateTwo,
@@ -7864,6 +7893,7 @@ const _sfc_main$8 = {
7864
7893
  intent: {
7865
7894
  type: String,
7866
7895
  required: true,
7896
+ default: Intent.INFO.value,
7867
7897
  validator(value) {
7868
7898
  const intentValues = Object.values(Intent).map((item) => item.value);
7869
7899
  return intentValues.includes(value);
@@ -8025,7 +8055,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
8025
8055
  return openBlock(), createElementBlock("div", _hoisted_1$7, [
8026
8056
  $props.label ? (openBlock(), createBlock(_component_base_input_label, {
8027
8057
  key: 0,
8028
- for: $data.inputReferenceId
8058
+ for: $data.inputReferenceId,
8059
+ class: "cpTextarea__label"
8029
8060
  }, {
8030
8061
  default: withCtx(() => [
8031
8062
  createTextVNode(toDisplayString($options.inputLabelTitle), 1)
@@ -8047,7 +8078,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
8047
8078
  $props.isInvalid ? (openBlock(), createBlock(_component_base_input_label, {
8048
8079
  key: 0,
8049
8080
  for: $data.inputReferenceId,
8050
- "is-invalid": ""
8081
+ "is-invalid": "",
8082
+ class: "cpTextarea__label cpTextarea__label--isAfter"
8051
8083
  }, {
8052
8084
  default: withCtx(() => [
8053
8085
  createTextVNode(toDisplayString($props.errorMessage), 1)
@@ -8153,7 +8185,8 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
8153
8185
  }, [
8154
8186
  $props.label ? (openBlock(), createBlock(_component_base_input_label, {
8155
8187
  key: 0,
8156
- for: $data.selectReferenceId
8188
+ for: $data.selectReferenceId,
8189
+ class: "cpSelect__label"
8157
8190
  }, {
8158
8191
  default: withCtx(() => [
8159
8192
  createTextVNode(toDisplayString($options.selectLabelTitle), 1)
@@ -8186,7 +8219,8 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
8186
8219
  $props.isInvalid ? (openBlock(), createBlock(_component_base_input_label, {
8187
8220
  key: 0,
8188
8221
  "is-invalid": $props.isInvalid,
8189
- for: $data.selectReferenceId
8222
+ for: $data.selectReferenceId,
8223
+ class: "cpSelect__label cpSelect__label--isAfter"
8190
8224
  }, {
8191
8225
  default: withCtx(() => [
8192
8226
  createTextVNode(toDisplayString($props.errorMessage), 1)