@bagelink/vue 0.0.1041 → 0.0.1043

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.
@@ -9,6 +9,7 @@ export interface RangeInputProps {
9
9
  id?: string;
10
10
  rtl?: boolean;
11
11
  multiRange?: boolean;
12
+ formatValue?: (value: number) => string;
12
13
  }
13
14
  declare const _default: import('vue').DefineComponent<RangeInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
15
  "update:modelValue": (...args: any[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"RangeInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/RangeInput.vue"],"names":[],"mappings":"AAyNA,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;;;;;;AAkND,wBAQG"}
1
+ {"version":3,"file":"RangeInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/RangeInput.vue"],"names":[],"mappings":"AAgNA,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CACvC;;;;;;AAwMD,wBAQG"}
package/dist/index.cjs CHANGED
@@ -20436,10 +20436,10 @@ const _hoisted_1$s = {
20436
20436
  class: "label"
20437
20437
  };
20438
20438
  const _hoisted_2$i = ["dir"];
20439
- const _hoisted_3$e = ["id", "min", "max", "step", "required", "disabled", "aria-label"];
20440
- const _hoisted_4$9 = ["min", "max", "step", "required", "disabled"];
20439
+ const _hoisted_3$e = ["id", "value", "min", "max", "step", "required", "disabled", "aria-label"];
20440
+ const _hoisted_4$9 = ["value", "min", "max", "step", "required", "disabled"];
20441
20441
  const _hoisted_5$9 = { class: "track absolute pointer-events-none overflow-hidden round" };
20442
- const _hoisted_6$8 = { class: "txt-center txt-14 range-slider-txt flex space-between opacity-4 mx-05" };
20442
+ const _hoisted_6$8 = { class: "txt-center txt-14 user-select-none range-slider-txt flex space-between opacity-4 mx-05" };
20443
20443
  const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20444
20444
  __name: "RangeInput",
20445
20445
  props: {
@@ -20452,7 +20452,8 @@ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20452
20452
  disabled: { type: Boolean },
20453
20453
  id: {},
20454
20454
  rtl: { type: Boolean },
20455
- multiRange: { type: Boolean }
20455
+ multiRange: { type: Boolean },
20456
+ formatValue: { type: Function }
20456
20457
  },
20457
20458
  emits: ["update:modelValue"],
20458
20459
  setup(__props, { emit: __emit }) {
@@ -20466,43 +20467,32 @@ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20466
20467
  disabled,
20467
20468
  id,
20468
20469
  rtl,
20469
- multiRange
20470
+ multiRange = false,
20471
+ formatValue = (value) => value.toString()
20470
20472
  } = props2;
20471
- let from = vue.ref(min2);
20472
- let to2 = vue.ref(max2);
20473
- let isExternalUpdate = vue.ref(true);
20473
+ let from = vue.ref(Array.isArray(props2.modelValue) ? props2.modelValue[0] : props2.modelValue ?? min2);
20474
+ let to2 = vue.ref(Array.isArray(props2.modelValue) ? props2.modelValue[1] : max2);
20474
20475
  const validFrom = vue.computed(() => Math.min(Math.max(from.value, min2), multiRange ? to2.value : max2));
20475
20476
  const validTo = vue.computed(() => Math.max(Math.min(to2.value, max2), from.value));
20477
+ const fromPercentage = vue.computed(() => (validFrom.value - min2) / (max2 - min2) * 100);
20478
+ const toPercentage = vue.computed(() => (validTo.value - min2) / (max2 - min2) * 100);
20476
20479
  vue.watch(() => props2.modelValue, (newVal) => {
20477
- isExternalUpdate.value = true;
20478
- if (multiRange && Array.isArray(newVal)) {
20480
+ if (Array.isArray(newVal) && multiRange) {
20479
20481
  from.value = newVal[0];
20480
20482
  to2.value = newVal[1];
20481
- } else if (!multiRange && !Array.isArray(newVal)) {
20483
+ } else if (!Array.isArray(newVal)) {
20482
20484
  from.value = newVal ?? min2;
20483
20485
  to2.value = max2;
20484
20486
  }
20485
20487
  }, { immediate: true });
20486
- vue.watch([() => validFrom.value, () => validTo.value], () => {
20487
- if (!isExternalUpdate.value) {
20488
- if (multiRange) {
20489
- emit2("update:modelValue", [validFrom.value, validTo.value]);
20490
- } else {
20491
- emit2("update:modelValue", validFrom.value);
20492
- }
20493
- }
20494
- isExternalUpdate.value = false;
20495
- });
20496
20488
  function handleInput(value, isFromInput) {
20497
- isExternalUpdate.value = false;
20498
20489
  if (isFromInput) {
20499
20490
  from.value = value;
20500
20491
  } else {
20501
20492
  to2.value = value;
20502
20493
  }
20494
+ emit2("update:modelValue", multiRange ? [validFrom.value, validTo.value] : validFrom.value);
20503
20495
  }
20504
- const fromPercentage = vue.computed(() => (validFrom.value - min2) / (max2 - min2) * 100);
20505
- const toPercentage = vue.computed(() => (validTo.value - min2) / (max2 - min2) * 100);
20506
20496
  const rangeStyle = vue.computed(() => {
20507
20497
  if (multiRange) {
20508
20498
  return {
@@ -20512,6 +20502,8 @@ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20512
20502
  }
20513
20503
  return rtl ? { left: `${100 - fromPercentage.value}%`, width: `${fromPercentage.value}%` } : { left: "0", width: `${fromPercentage.value}%` };
20514
20504
  });
20505
+ const displayFrom = vue.computed(() => formatValue(validFrom.value));
20506
+ const displayTo = vue.computed(() => formatValue(validTo.value));
20515
20507
  return (_ctx, _cache) => {
20516
20508
  return vue.openBlock(), vue.createElementBlock("div", null, [
20517
20509
  vue.unref(label) ? (vue.openBlock(), vue.createElementBlock("label", _hoisted_1$s, vue.toDisplayString(vue.unref(label)), 1)) : vue.createCommentVNode("", true),
@@ -20519,36 +20511,32 @@ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20519
20511
  class: "range-slider relative w-100",
20520
20512
  dir: vue.unref(rtl) ? "rtl" : "ltr"
20521
20513
  }, [
20522
- vue.withDirectives(vue.createElementVNode("input", {
20514
+ vue.createElementVNode("input", {
20523
20515
  id: vue.unref(id),
20524
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(from) ? from.value = $event : from = $event),
20516
+ value: validFrom.value,
20525
20517
  class: "from",
20526
20518
  type: "range",
20527
20519
  min: vue.unref(min2),
20528
- max: vue.unref(multiRange) ? vue.unref(to2) : vue.unref(max2),
20520
+ max: vue.unref(multiRange) ? validTo.value : vue.unref(max2),
20529
20521
  step: vue.unref(step),
20530
20522
  required: _ctx.required,
20531
20523
  disabled: vue.unref(disabled),
20532
20524
  "aria-label": vue.unref(multiRange) ? "Minimum value" : "Value",
20533
- onInput: _cache[1] || (_cache[1] = (e) => handleInput(+e.target.value, true))
20534
- }, null, 40, _hoisted_3$e), [
20535
- [vue.vModelText, vue.unref(from)]
20536
- ]),
20537
- vue.unref(multiRange) ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
20525
+ onInput: _cache[0] || (_cache[0] = (e) => handleInput(+e.target.value, true))
20526
+ }, null, 40, _hoisted_3$e),
20527
+ vue.unref(multiRange) ? (vue.openBlock(), vue.createElementBlock("input", {
20538
20528
  key: 0,
20539
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.isRef(to2) ? to2.value = $event : to2 = $event),
20529
+ value: validTo.value,
20540
20530
  class: "to",
20541
20531
  type: "range",
20542
- min: vue.unref(from),
20532
+ min: validFrom.value,
20543
20533
  max: vue.unref(max2),
20544
20534
  step: vue.unref(step),
20545
20535
  required: _ctx.required,
20546
20536
  disabled: vue.unref(disabled),
20547
20537
  "aria-label": "Maximum value",
20548
- onInput: _cache[3] || (_cache[3] = (e) => handleInput(+e.target.value, false))
20549
- }, null, 40, _hoisted_4$9)), [
20550
- [vue.vModelText, vue.unref(to2)]
20551
- ]) : vue.createCommentVNode("", true),
20538
+ onInput: _cache[1] || (_cache[1] = (e) => handleInput(+e.target.value, false))
20539
+ }, null, 40, _hoisted_4$9)) : vue.createCommentVNode("", true),
20552
20540
  vue.createElementVNode("div", _hoisted_5$9, [
20553
20541
  vue.createElementVNode("div", {
20554
20542
  class: "active-range absolute h-100 pointer-events-none bg-primary",
@@ -20559,22 +20547,22 @@ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
20559
20547
  key: 1,
20560
20548
  class: "txt-center txt-12 range-slider-position-txt absolute line-height-1 opacity-0",
20561
20549
  style: vue.normalizeStyle({ "--progress": `${fromPercentage.value}` })
20562
- }, vue.toDisplayString(validFrom.value), 5)) : vue.createCommentVNode("", true),
20550
+ }, vue.toDisplayString(displayFrom.value), 5)) : vue.createCommentVNode("", true),
20563
20551
  vue.unref(multiRange) && validTo.value !== vue.unref(max2) ? (vue.openBlock(), vue.createElementBlock("p", {
20564
20552
  key: 2,
20565
20553
  class: "txt-center txt-12 range-slider-position-txt opacity-0 line-height-1 absolute",
20566
20554
  style: vue.normalizeStyle({ "--progress": `${toPercentage.value}` })
20567
- }, vue.toDisplayString(validTo.value), 5)) : vue.createCommentVNode("", true)
20555
+ }, vue.toDisplayString(displayTo.value), 5)) : vue.createCommentVNode("", true)
20568
20556
  ], 8, _hoisted_2$i),
20569
20557
  vue.createElementVNode("p", _hoisted_6$8, [
20570
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(min2)), 1),
20571
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(max2)), 1)
20558
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(formatValue)(vue.unref(min2))), 1),
20559
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(formatValue)(vue.unref(max2))), 1)
20572
20560
  ])
20573
20561
  ]);
20574
20562
  };
20575
20563
  }
20576
20564
  });
20577
- const RangeInput = /* @__PURE__ */ _export_sfc(_sfc_main$A, [["__scopeId", "data-v-28a2da0e"]]);
20565
+ const RangeInput = /* @__PURE__ */ _export_sfc(_sfc_main$A, [["__scopeId", "data-v-3616fbd2"]]);
20578
20566
  const tableTools = [
20579
20567
  "mergeCells",
20580
20568
  "splitCells",
package/dist/index.mjs CHANGED
@@ -20434,10 +20434,10 @@ const _hoisted_1$s = {
20434
20434
  class: "label"
20435
20435
  };
20436
20436
  const _hoisted_2$i = ["dir"];
20437
- const _hoisted_3$e = ["id", "min", "max", "step", "required", "disabled", "aria-label"];
20438
- const _hoisted_4$9 = ["min", "max", "step", "required", "disabled"];
20437
+ const _hoisted_3$e = ["id", "value", "min", "max", "step", "required", "disabled", "aria-label"];
20438
+ const _hoisted_4$9 = ["value", "min", "max", "step", "required", "disabled"];
20439
20439
  const _hoisted_5$9 = { class: "track absolute pointer-events-none overflow-hidden round" };
20440
- const _hoisted_6$8 = { class: "txt-center txt-14 range-slider-txt flex space-between opacity-4 mx-05" };
20440
+ const _hoisted_6$8 = { class: "txt-center txt-14 user-select-none range-slider-txt flex space-between opacity-4 mx-05" };
20441
20441
  const _sfc_main$A = /* @__PURE__ */ defineComponent({
20442
20442
  __name: "RangeInput",
20443
20443
  props: {
@@ -20450,7 +20450,8 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
20450
20450
  disabled: { type: Boolean },
20451
20451
  id: {},
20452
20452
  rtl: { type: Boolean },
20453
- multiRange: { type: Boolean }
20453
+ multiRange: { type: Boolean },
20454
+ formatValue: { type: Function }
20454
20455
  },
20455
20456
  emits: ["update:modelValue"],
20456
20457
  setup(__props, { emit: __emit }) {
@@ -20464,43 +20465,32 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
20464
20465
  disabled,
20465
20466
  id,
20466
20467
  rtl,
20467
- multiRange
20468
+ multiRange = false,
20469
+ formatValue = (value) => value.toString()
20468
20470
  } = props2;
20469
- let from = ref(min2);
20470
- let to2 = ref(max2);
20471
- let isExternalUpdate = ref(true);
20471
+ let from = ref(Array.isArray(props2.modelValue) ? props2.modelValue[0] : props2.modelValue ?? min2);
20472
+ let to2 = ref(Array.isArray(props2.modelValue) ? props2.modelValue[1] : max2);
20472
20473
  const validFrom = computed(() => Math.min(Math.max(from.value, min2), multiRange ? to2.value : max2));
20473
20474
  const validTo = computed(() => Math.max(Math.min(to2.value, max2), from.value));
20475
+ const fromPercentage = computed(() => (validFrom.value - min2) / (max2 - min2) * 100);
20476
+ const toPercentage = computed(() => (validTo.value - min2) / (max2 - min2) * 100);
20474
20477
  watch(() => props2.modelValue, (newVal) => {
20475
- isExternalUpdate.value = true;
20476
- if (multiRange && Array.isArray(newVal)) {
20478
+ if (Array.isArray(newVal) && multiRange) {
20477
20479
  from.value = newVal[0];
20478
20480
  to2.value = newVal[1];
20479
- } else if (!multiRange && !Array.isArray(newVal)) {
20481
+ } else if (!Array.isArray(newVal)) {
20480
20482
  from.value = newVal ?? min2;
20481
20483
  to2.value = max2;
20482
20484
  }
20483
20485
  }, { immediate: true });
20484
- watch([() => validFrom.value, () => validTo.value], () => {
20485
- if (!isExternalUpdate.value) {
20486
- if (multiRange) {
20487
- emit2("update:modelValue", [validFrom.value, validTo.value]);
20488
- } else {
20489
- emit2("update:modelValue", validFrom.value);
20490
- }
20491
- }
20492
- isExternalUpdate.value = false;
20493
- });
20494
20486
  function handleInput(value, isFromInput) {
20495
- isExternalUpdate.value = false;
20496
20487
  if (isFromInput) {
20497
20488
  from.value = value;
20498
20489
  } else {
20499
20490
  to2.value = value;
20500
20491
  }
20492
+ emit2("update:modelValue", multiRange ? [validFrom.value, validTo.value] : validFrom.value);
20501
20493
  }
20502
- const fromPercentage = computed(() => (validFrom.value - min2) / (max2 - min2) * 100);
20503
- const toPercentage = computed(() => (validTo.value - min2) / (max2 - min2) * 100);
20504
20494
  const rangeStyle = computed(() => {
20505
20495
  if (multiRange) {
20506
20496
  return {
@@ -20510,6 +20500,8 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
20510
20500
  }
20511
20501
  return rtl ? { left: `${100 - fromPercentage.value}%`, width: `${fromPercentage.value}%` } : { left: "0", width: `${fromPercentage.value}%` };
20512
20502
  });
20503
+ const displayFrom = computed(() => formatValue(validFrom.value));
20504
+ const displayTo = computed(() => formatValue(validTo.value));
20513
20505
  return (_ctx, _cache) => {
20514
20506
  return openBlock(), createElementBlock("div", null, [
20515
20507
  unref(label) ? (openBlock(), createElementBlock("label", _hoisted_1$s, toDisplayString(unref(label)), 1)) : createCommentVNode("", true),
@@ -20517,36 +20509,32 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
20517
20509
  class: "range-slider relative w-100",
20518
20510
  dir: unref(rtl) ? "rtl" : "ltr"
20519
20511
  }, [
20520
- withDirectives(createElementVNode("input", {
20512
+ createElementVNode("input", {
20521
20513
  id: unref(id),
20522
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(from) ? from.value = $event : from = $event),
20514
+ value: validFrom.value,
20523
20515
  class: "from",
20524
20516
  type: "range",
20525
20517
  min: unref(min2),
20526
- max: unref(multiRange) ? unref(to2) : unref(max2),
20518
+ max: unref(multiRange) ? validTo.value : unref(max2),
20527
20519
  step: unref(step),
20528
20520
  required: _ctx.required,
20529
20521
  disabled: unref(disabled),
20530
20522
  "aria-label": unref(multiRange) ? "Minimum value" : "Value",
20531
- onInput: _cache[1] || (_cache[1] = (e) => handleInput(+e.target.value, true))
20532
- }, null, 40, _hoisted_3$e), [
20533
- [vModelText, unref(from)]
20534
- ]),
20535
- unref(multiRange) ? withDirectives((openBlock(), createElementBlock("input", {
20523
+ onInput: _cache[0] || (_cache[0] = (e) => handleInput(+e.target.value, true))
20524
+ }, null, 40, _hoisted_3$e),
20525
+ unref(multiRange) ? (openBlock(), createElementBlock("input", {
20536
20526
  key: 0,
20537
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(to2) ? to2.value = $event : to2 = $event),
20527
+ value: validTo.value,
20538
20528
  class: "to",
20539
20529
  type: "range",
20540
- min: unref(from),
20530
+ min: validFrom.value,
20541
20531
  max: unref(max2),
20542
20532
  step: unref(step),
20543
20533
  required: _ctx.required,
20544
20534
  disabled: unref(disabled),
20545
20535
  "aria-label": "Maximum value",
20546
- onInput: _cache[3] || (_cache[3] = (e) => handleInput(+e.target.value, false))
20547
- }, null, 40, _hoisted_4$9)), [
20548
- [vModelText, unref(to2)]
20549
- ]) : createCommentVNode("", true),
20536
+ onInput: _cache[1] || (_cache[1] = (e) => handleInput(+e.target.value, false))
20537
+ }, null, 40, _hoisted_4$9)) : createCommentVNode("", true),
20550
20538
  createElementVNode("div", _hoisted_5$9, [
20551
20539
  createElementVNode("div", {
20552
20540
  class: "active-range absolute h-100 pointer-events-none bg-primary",
@@ -20557,22 +20545,22 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
20557
20545
  key: 1,
20558
20546
  class: "txt-center txt-12 range-slider-position-txt absolute line-height-1 opacity-0",
20559
20547
  style: normalizeStyle({ "--progress": `${fromPercentage.value}` })
20560
- }, toDisplayString(validFrom.value), 5)) : createCommentVNode("", true),
20548
+ }, toDisplayString(displayFrom.value), 5)) : createCommentVNode("", true),
20561
20549
  unref(multiRange) && validTo.value !== unref(max2) ? (openBlock(), createElementBlock("p", {
20562
20550
  key: 2,
20563
20551
  class: "txt-center txt-12 range-slider-position-txt opacity-0 line-height-1 absolute",
20564
20552
  style: normalizeStyle({ "--progress": `${toPercentage.value}` })
20565
- }, toDisplayString(validTo.value), 5)) : createCommentVNode("", true)
20553
+ }, toDisplayString(displayTo.value), 5)) : createCommentVNode("", true)
20566
20554
  ], 8, _hoisted_2$i),
20567
20555
  createElementVNode("p", _hoisted_6$8, [
20568
- createElementVNode("span", null, toDisplayString(unref(min2)), 1),
20569
- createElementVNode("span", null, toDisplayString(unref(max2)), 1)
20556
+ createElementVNode("span", null, toDisplayString(unref(formatValue)(unref(min2))), 1),
20557
+ createElementVNode("span", null, toDisplayString(unref(formatValue)(unref(max2))), 1)
20570
20558
  ])
20571
20559
  ]);
20572
20560
  };
20573
20561
  }
20574
20562
  });
20575
- const RangeInput = /* @__PURE__ */ _export_sfc(_sfc_main$A, [["__scopeId", "data-v-28a2da0e"]]);
20563
+ const RangeInput = /* @__PURE__ */ _export_sfc(_sfc_main$A, [["__scopeId", "data-v-3616fbd2"]]);
20576
20564
  const tableTools = [
20577
20565
  "mergeCells",
20578
20566
  "splitCells",