@citizenplane/pimp 8.1.2 → 8.2.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
@@ -1,4 +1,4 @@
1
- import { resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, createCommentVNode, createElementVNode, resolveDynamicComponent, mergeProps, withCtx, createVNode, resolveDirective, createTextVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, vModelSelect, defineComponent, watch, h, Transition, normalizeStyle, withKeys, TransitionGroup, vShow, ref, withModifiers, vModelCheckbox } from "vue";
1
+ import { useSlots, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createBlock, createCommentVNode, createElementVNode, createVNode, resolveDynamicComponent, mergeProps, withCtx, resolveDirective, createTextVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, vModelSelect, defineComponent, watch, h, Transition, normalizeStyle, withKeys, TransitionGroup, vShow, ref, withModifiers, vModelCheckbox } from "vue";
2
2
  function _mergeNamespaces(n2, m) {
3
3
  m.forEach(function(e) {
4
4
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -15,10 +15,10 @@ function _mergeNamespaces(n2, m) {
15
15
  });
16
16
  return Object.freeze(Object.defineProperty(n2, Symbol.toStringTag, { value: "Module" }));
17
17
  }
18
- /*! maska v2.1.2 | (c) Alexander Shabunevich | Released under the MIT license */
19
- var L = Object.defineProperty;
20
- var b = (n2, t, s2) => t in n2 ? L(n2, t, { enumerable: true, configurable: true, writable: true, value: s2 }) : n2[t] = s2;
21
- var f = (n2, t, s2) => (b(n2, typeof t != "symbol" ? t + "" : t, s2), s2);
18
+ /*! maska v2.1.4 | (c) Alexander Shabunevich | Released under the MIT license */
19
+ var b = Object.defineProperty;
20
+ var L = (n2, t, s2) => t in n2 ? b(n2, t, { enumerable: true, configurable: true, writable: true, value: s2 }) : n2[t] = s2;
21
+ var f = (n2, t, s2) => (L(n2, typeof t != "symbol" ? t + "" : t, s2), s2);
22
22
  const R = {
23
23
  "#": { pattern: /[0-9]/ },
24
24
  "@": { pattern: /[a-zA-Z]/ },
@@ -129,7 +129,7 @@ class N {
129
129
  e.isEager() && "inputType" in t2 && t2.inputType.startsWith("delete") && e.unmasked(s3.value).length <= 1 && this.setMaskedValue(s3, "");
130
130
  });
131
131
  f(this, "inputEvent", (t2) => {
132
- if (t2 instanceof CustomEvent && t2.type === "input" && t2.detail != null && "masked" in t2.detail)
132
+ if (t2 instanceof CustomEvent && t2.type === "input" && t2.detail != null && typeof t2.detail == "object" && "masked" in t2.detail)
133
133
  return;
134
134
  const s3 = t2.target, e = this.items.get(s3), a = s3.value, i = s3.selectionStart, p = s3.selectionEnd;
135
135
  let l2 = a;
@@ -137,7 +137,11 @@ class N {
137
137
  const k = e.unmasked(a), r = e.masked(k);
138
138
  k === "" && "data" in t2 && t2.data != null ? l2 = t2.data : (r.startsWith(a) || e.completed(k)) && (l2 = k);
139
139
  }
140
- this.setMaskedValue(s3, l2), "inputType" in t2 && (t2.inputType.startsWith("delete") || i != null && i < a.length) && s3.setSelectionRange(i, p);
140
+ if (this.setMaskedValue(s3, l2), "inputType" in t2 && (t2.inputType.startsWith("delete") || i != null && i < a.length))
141
+ try {
142
+ s3.setSelectionRange(i, p);
143
+ } catch {
144
+ }
141
145
  });
142
146
  this.options = s2, typeof t == "string" ? this.init(
143
147
  Array.from(document.querySelectorAll(t)),
@@ -626,24 +630,33 @@ function systemLocale() {
626
630
  }
627
631
  }
628
632
  function parseLocaleString(localeStr) {
633
+ const xIndex = localeStr.indexOf("-x-");
634
+ if (xIndex !== -1) {
635
+ localeStr = localeStr.substring(0, xIndex);
636
+ }
629
637
  const uIndex = localeStr.indexOf("-u-");
630
638
  if (uIndex === -1) {
631
639
  return [localeStr];
632
640
  } else {
633
641
  let options;
634
- const smaller = localeStr.substring(0, uIndex);
642
+ let selectedStr;
635
643
  try {
636
644
  options = getCachedDTF(localeStr).resolvedOptions();
645
+ selectedStr = localeStr;
637
646
  } catch (e) {
647
+ const smaller = localeStr.substring(0, uIndex);
638
648
  options = getCachedDTF(smaller).resolvedOptions();
649
+ selectedStr = smaller;
639
650
  }
640
651
  const { numberingSystem, calendar } = options;
641
- return [smaller, numberingSystem, calendar];
652
+ return [selectedStr, numberingSystem, calendar];
642
653
  }
643
654
  }
644
655
  function intlConfigString(localeStr, numberingSystem, outputCalendar) {
645
656
  if (outputCalendar || numberingSystem) {
646
- localeStr += "-u";
657
+ if (!localeStr.includes("-u-")) {
658
+ localeStr += "-u";
659
+ }
647
660
  if (outputCalendar) {
648
661
  localeStr += `-ca-${outputCalendar}`;
649
662
  }
@@ -713,7 +726,7 @@ class PolyNumberFormatter {
713
726
  class PolyDateFormatter {
714
727
  constructor(dt, intl, opts) {
715
728
  this.opts = opts;
716
- let z;
729
+ let z = void 0;
717
730
  if (dt.zone.isUniversal) {
718
731
  const gmtOffset = -1 * (dt.offset / 60);
719
732
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
@@ -735,9 +748,7 @@ class PolyDateFormatter {
735
748
  z = dt.zone.name;
736
749
  }
737
750
  const intlOpts = { ...this.opts };
738
- if (z) {
739
- intlOpts.timeZone = z;
740
- }
751
+ intlOpts.timeZone = intlOpts.timeZone || z;
741
752
  this.dtf = getCachedDTF(intl, intlOpts);
742
753
  }
743
754
  format() {
@@ -1465,6 +1476,10 @@ class Formatter {
1465
1476
  const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
1466
1477
  return df.formatToParts();
1467
1478
  }
1479
+ formatInterval(interval, opts = {}) {
1480
+ const df = this.loc.dtFormatter(interval.start, { ...this.opts, ...opts });
1481
+ return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
1482
+ }
1468
1483
  resolvedOptions(dt, opts = {}) {
1469
1484
  const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
1470
1485
  return df.resolvedOptions();
@@ -1818,7 +1833,7 @@ function extractRFC2822(match2) {
1818
1833
  return [result, new FixedOffsetZone(offset2)];
1819
1834
  }
1820
1835
  function preprocessRFC2822(s2) {
1821
- return s2.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
1836
+ return s2.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
1822
1837
  }
1823
1838
  const rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/, rfc850 = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/, ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
1824
1839
  function extractRFC1123Or850(match2) {
@@ -2646,6 +2661,9 @@ class Interval {
2646
2661
  return INVALID$1;
2647
2662
  return `[${this.s.toISO()} \u2013 ${this.e.toISO()})`;
2648
2663
  }
2664
+ toLocaleString(formatOpts = DATE_SHORT, opts = {}) {
2665
+ return this.isValid ? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this) : INVALID$1;
2666
+ }
2649
2667
  toISO(opts) {
2650
2668
  if (!this.isValid)
2651
2669
  return INVALID$1;
@@ -2728,19 +2746,19 @@ function highOrderDiffs(cursor, later, units) {
2728
2746
  ["days", dayDiff]
2729
2747
  ];
2730
2748
  const results = {};
2749
+ const earlier = cursor;
2731
2750
  let lowestOrder, highWater;
2732
2751
  for (const [unit, differ] of differs) {
2733
2752
  if (units.indexOf(unit) >= 0) {
2734
2753
  lowestOrder = unit;
2735
- let delta = differ(cursor, later);
2736
- highWater = cursor.plus({ [unit]: delta });
2754
+ results[unit] = differ(cursor, later);
2755
+ highWater = earlier.plus(results);
2737
2756
  if (highWater > later) {
2738
- cursor = cursor.plus({ [unit]: delta - 1 });
2739
- delta -= 1;
2757
+ results[unit]--;
2758
+ cursor = earlier.plus(results);
2740
2759
  } else {
2741
2760
  cursor = highWater;
2742
2761
  }
2743
- results[unit] = delta;
2744
2762
  }
2745
2763
  }
2746
2764
  return [cursor, results, highWater, lowestOrder];
@@ -3018,7 +3036,7 @@ const partTypeStyleToTokenVal = {
3018
3036
  short: "ZZZ"
3019
3037
  }
3020
3038
  };
3021
- function tokenForPart(part, locale, formatOpts) {
3039
+ function tokenForPart(part, formatOpts) {
3022
3040
  const { type, value } = part;
3023
3041
  if (type === "literal") {
3024
3042
  return {
@@ -3177,7 +3195,7 @@ function formatOptsToTokens(formatOpts, locale) {
3177
3195
  }
3178
3196
  const formatter = Formatter.create(locale, formatOpts);
3179
3197
  const parts = formatter.formatDateTimeParts(getDummyDateTime());
3180
- return parts.map((p) => tokenForPart(p, locale, formatOpts));
3198
+ return parts.map((p) => tokenForPart(p, formatOpts));
3181
3199
  }
3182
3200
  const nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
3183
3201
  function unitOutOfRange(unit, value) {
@@ -4268,79 +4286,98 @@ const capitalizeFirstLetter = (rawString) => {
4268
4286
  return rawString.charAt(0).toUpperCase() + rawString.slice(1);
4269
4287
  };
4270
4288
  var CpBadge_vue_vue_type_style_index_0_lang = "";
4271
- var _export_sfc = (sfc, props) => {
4272
- const target = sfc.__vccOpts || sfc;
4273
- for (const [key, val] of props) {
4274
- target[key] = val;
4275
- }
4276
- return target;
4289
+ const _hoisted_1$g = {
4290
+ key: 0,
4291
+ class: "cpBadge__icon"
4277
4292
  };
4293
+ const _hoisted_2$f = { class: "cpBadge__label" };
4278
4294
  const badgeColors = ["neutral", "blue", "green", "red", "orange", "purple", "teal", "pink", "yellow"];
4279
4295
  const _sfc_main$k = {
4296
+ __name: "CpBadge",
4280
4297
  props: {
4281
4298
  color: {
4282
4299
  type: String,
4283
4300
  default: "",
4284
- validator: (value) => Object.values(badgeColors).includes(value) || value === ""
4301
+ validator: (value) => badgeColors.includes(value) || value === ""
4285
4302
  },
4286
4303
  isSolid: {
4287
4304
  type: Boolean,
4288
- default: false,
4289
- required: false
4305
+ default: false
4290
4306
  },
4291
4307
  isPlain: {
4292
4308
  type: Boolean,
4293
- default: false,
4294
- required: false
4309
+ default: false
4310
+ },
4311
+ isClearable: {
4312
+ type: Boolean,
4313
+ default: false
4295
4314
  },
4296
4315
  icon: {
4297
4316
  type: String,
4298
- default: "",
4299
- required: false
4317
+ default: ""
4300
4318
  }
4301
4319
  },
4302
- computed: {
4303
- capitalizedColor() {
4304
- return capitalizeFirstLetter(this.color);
4305
- },
4306
- computedClasses() {
4307
- const hasIcon = this.icon !== "" || this.hasIconSlot;
4308
- return [
4309
- this.isSolid ? "cpBadge--isSolid" : "",
4310
- this.isPlain ? "cpBadge--isPlain" : "",
4311
- hasIcon ? "cpBadge--hasIcon" : "",
4312
- this.capitalizedColor ? `cpBadge--is${this.capitalizedColor}` : ""
4313
- ];
4314
- },
4315
- hasIconSlot() {
4316
- return !!this.$slots.icon;
4317
- }
4320
+ emits: ["on-clear"],
4321
+ setup(__props, { emit: emits }) {
4322
+ const props = __props;
4323
+ const slots = useSlots();
4324
+ const capitalizedColor = computed(() => {
4325
+ return capitalizeFirstLetter(props.color);
4326
+ });
4327
+ const hasIconSlot = computed(() => {
4328
+ return !!slots.icon;
4329
+ });
4330
+ const computedClasses = computed(() => {
4331
+ const hasIcon = props.icon !== "" || hasIconSlot.value;
4332
+ return {
4333
+ "cpBadge--isSolid": props.isSolid,
4334
+ "cpBadge--isPlain": props.isPlain,
4335
+ "cpBadge--hasIcon": hasIcon,
4336
+ "cpBadge--isClearable": props.isClearable,
4337
+ [`cpBadge--is${capitalizedColor.value}`]: capitalizedColor.value
4338
+ };
4339
+ });
4340
+ const onClear = () => {
4341
+ emits("on-clear");
4342
+ };
4343
+ return (_ctx, _cache) => {
4344
+ const _component_cp_icon = resolveComponent("cp-icon");
4345
+ return openBlock(), createElementBlock("div", {
4346
+ class: normalizeClass(["cpBadge", unref(computedClasses)])
4347
+ }, [
4348
+ unref(hasIconSlot) ? (openBlock(), createElementBlock("span", _hoisted_1$g, [
4349
+ renderSlot(_ctx.$slots, "icon")
4350
+ ])) : __props.icon ? (openBlock(), createBlock(_component_cp_icon, {
4351
+ key: 1,
4352
+ type: __props.icon,
4353
+ class: "cpBadge__icon"
4354
+ }, null, 8, ["type"])) : createCommentVNode("", true),
4355
+ createElementVNode("span", _hoisted_2$f, [
4356
+ renderSlot(_ctx.$slots, "default")
4357
+ ]),
4358
+ __props.isClearable ? (openBlock(), createElementBlock("button", {
4359
+ key: 2,
4360
+ class: "cpBadge__clear",
4361
+ type: "button",
4362
+ onClick: onClear
4363
+ }, [
4364
+ createVNode(_component_cp_icon, {
4365
+ class: "cpBadge__icon cpBadge__icon--isClear",
4366
+ type: "x"
4367
+ })
4368
+ ])) : createCommentVNode("", true)
4369
+ ], 2);
4370
+ };
4318
4371
  }
4319
4372
  };
4320
- const _hoisted_1$g = {
4321
- key: 0,
4322
- class: "cpBadge__icon"
4323
- };
4324
- const _hoisted_2$f = { class: "cpBadge__label" };
4325
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
4326
- const _component_cp_icon = resolveComponent("cp-icon");
4327
- return openBlock(), createElementBlock("div", {
4328
- class: normalizeClass(["cpBadge", $options.computedClasses])
4329
- }, [
4330
- $options.hasIconSlot ? (openBlock(), createElementBlock("span", _hoisted_1$g, [
4331
- renderSlot(_ctx.$slots, "icon")
4332
- ])) : $props.icon ? (openBlock(), createBlock(_component_cp_icon, {
4333
- key: 1,
4334
- type: $props.icon,
4335
- class: "cpBadge__icon"
4336
- }, null, 8, ["type"])) : createCommentVNode("", true),
4337
- createElementVNode("span", _hoisted_2$f, [
4338
- renderSlot(_ctx.$slots, "default")
4339
- ])
4340
- ], 2);
4341
- }
4342
- var CpBadge = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$j]]);
4343
4373
  var index_vue_vue_type_style_index_0_lang$8 = "";
4374
+ var _export_sfc = (sfc, props) => {
4375
+ const target = sfc.__vccOpts || sfc;
4376
+ for (const [key, val] of props) {
4377
+ target[key] = val;
4378
+ }
4379
+ return target;
4380
+ };
4344
4381
  const headingLevels = ["h1", "h2", "h3", "h4", "h5", "h6"];
4345
4382
  const sizes = [100, 200, 300, 400, 500, 600, 700, 800, 900];
4346
4383
  const _sfc_main$j = {
@@ -10927,7 +10964,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
10927
10964
  }
10928
10965
  var CpTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
10929
10966
  const Components = {
10930
- CpBadge,
10967
+ CpBadge: _sfc_main$k,
10931
10968
  CpHeading,
10932
10969
  CpButton,
10933
10970
  CpDate,