@knime/kds-components 0.5.0 → 0.5.2

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { shallowRef, watch, defineComponent, toRef, createBlock, createElementBlock, unref, openBlock, resolveDynamicComponent, normalizeClass, computed, withCtx, createCommentVNode, toDisplayString, mergeProps, h, useSlots, getCurrentInstance, mergeModels, useModel, useId, createElementVNode, Fragment, createVNode, renderSlot, useTemplateRef, nextTick, ref, withModifiers, createSlots, renderList, normalizeProps, guardReactiveProps } from 'vue';
1
+ import { shallowRef, watch, defineComponent, toRef, createBlock, createElementBlock, unref, openBlock, resolveDynamicComponent, normalizeClass, computed, withCtx, createCommentVNode, toDisplayString, mergeProps, h, useSlots, getCurrentInstance, mergeModels, useModel, useId, createElementVNode, mergeDefaults, useCssVars, Fragment, createVNode, renderSlot, useTemplateRef, nextTick, ref, withModifiers, createSlots, renderList, normalizeProps, guardReactiveProps } from 'vue';
2
2
  import { useLocalStorage, useDark, usePreferredDark } from '@vueuse/core';
3
3
 
4
4
  import './index.css';const __variableDynamicImportRuntimeHelper = (glob$1, path$13, segs) => {
@@ -79,10 +79,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
79
79
  props: {
80
80
  size: { default: "medium" },
81
81
  disabled: { type: Boolean, default: false },
82
+ title: {},
82
83
  variant: {},
83
- label: { default: void 0 },
84
- leadingIcon: { default: void 0 },
84
+ label: {},
85
+ leadingIcon: {},
85
86
  trailingIcon: {},
87
+ ariaLabel: {},
86
88
  destructive: { type: Boolean, default: false },
87
89
  toggled: { type: Boolean, default: false },
88
90
  component: { default: "button" }
@@ -115,6 +117,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
115
117
  return openBlock(), createBlock(resolveDynamicComponent(__props.component), {
116
118
  class: normalizeClass(classes.value),
117
119
  disabled: props.disabled,
120
+ title: props.title,
121
+ "aria-label": props.ariaLabel,
118
122
  onClick: _cache[0] || (_cache[0] = ($event) => onClick($event))
119
123
  }, {
120
124
  default: withCtx(() => [
@@ -131,22 +135,24 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
131
135
  }, null, 8, ["name", "size"])) : createCommentVNode("", true)
132
136
  ]),
133
137
  _: 1
134
- }, 8, ["class", "disabled"]);
138
+ }, 8, ["class", "disabled", "title", "aria-label"]);
135
139
  };
136
140
  }
137
141
  });
138
142
 
139
- const BaseButton = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-67f7d3ae"]]);
143
+ const BaseButton = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-18cd4b75"]]);
140
144
 
141
145
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
142
146
  __name: "KdsButton",
143
147
  props: {
144
148
  size: {},
145
149
  disabled: { type: Boolean },
150
+ title: {},
146
151
  variant: { default: "filled" },
147
152
  label: {},
148
153
  leadingIcon: {},
149
154
  trailingIcon: {},
155
+ ariaLabel: {},
150
156
  destructive: { type: Boolean }
151
157
  },
152
158
  emits: ["click"],
@@ -194,10 +200,12 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
194
200
  props: {
195
201
  size: {},
196
202
  disabled: { type: Boolean },
203
+ title: {},
197
204
  variant: { default: "filled" },
198
205
  label: {},
199
206
  leadingIcon: {},
200
207
  trailingIcon: {},
208
+ ariaLabel: {},
201
209
  destructive: { type: Boolean },
202
210
  to: {},
203
211
  download: { type: Boolean, default: void 0 },
@@ -228,10 +236,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
228
236
  props: /* @__PURE__ */ mergeModels({
229
237
  size: {},
230
238
  disabled: { type: Boolean },
239
+ title: {},
231
240
  variant: { default: "outlined" },
232
241
  label: {},
233
242
  leadingIcon: {},
234
- trailingIcon: {}
243
+ trailingIcon: {},
244
+ ariaLabel: {}
235
245
  }, {
236
246
  "modelValue": { type: Boolean, ...{ default: false } },
237
247
  "modelModifiers": {}
@@ -256,7 +266,7 @@ const _hoisted_3$2 = {
256
266
  key: 0,
257
267
  class: "content"
258
268
  };
259
- const _hoisted_4 = { class: "label" };
269
+ const _hoisted_4$1 = { class: "label" };
260
270
  const _hoisted_5 = ["id"];
261
271
  const _sfc_main$4 = /* @__PURE__ */ defineComponent({
262
272
  __name: "KdsCheckbox",
@@ -324,7 +334,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
324
334
  }, null, 8, ["name"])) : createCommentVNode("", true)
325
335
  ]),
326
336
  props.label || props.helperText ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
327
- createElementVNode("div", _hoisted_4, toDisplayString(props.label), 1),
337
+ createElementVNode("div", _hoisted_4$1, toDisplayString(props.label), 1),
328
338
  props.helperText ? (openBlock(), createElementBlock("div", {
329
339
  key: 0,
330
340
  id: `${unref(id)}-helper`,
@@ -530,22 +540,41 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
530
540
 
531
541
  const KdsDataType = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f7d93fdf"]]);
532
542
 
543
+ const modalLayoutPropsDefault = {
544
+ title: "",
545
+ variant: "padded",
546
+ overflow: "auto",
547
+ icon: void 0
548
+ };
549
+ const modalPropsDefault = {
550
+ active: false,
551
+ height: "auto",
552
+ width: "medium",
553
+ closedby: "closerequest",
554
+ ...modalLayoutPropsDefault
555
+ };
556
+
533
557
  const _hoisted_1$2 = { class: "modal-header" };
534
558
  const _hoisted_2$1 = { class: "modal-header-title" };
535
- const _hoisted_3$1 = {
559
+ const _hoisted_3$1 = ["data-variant"];
560
+ const _hoisted_4 = {
536
561
  key: 0,
537
562
  class: "modal-footer"
538
563
  };
539
564
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
540
565
  ...{ inheritAttrs: false },
541
566
  __name: "KdsModalLayout",
542
- props: {
567
+ props: /* @__PURE__ */ mergeDefaults({
543
568
  title: {},
544
569
  variant: {},
545
570
  icon: {},
571
+ overflow: {},
546
572
  onClose: { type: Function }
547
- },
573
+ }, modalLayoutPropsDefault),
548
574
  setup(__props) {
575
+ useCssVars((_ctx) => ({
576
+ "v7613d0dd": _ctx.overflow
577
+ }));
549
578
  const props = __props;
550
579
  return (_ctx, _cache) => {
551
580
  return openBlock(), createElementBlock(Fragment, null, [
@@ -565,11 +594,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
565
594
  }, null, 8, ["onClick"])
566
595
  ]),
567
596
  createElementVNode("div", {
568
- class: normalizeClass(["modal-body", `modal-body-variant-${__props.variant}`])
597
+ class: "modal-body",
598
+ "data-variant": __props.variant
569
599
  }, [
570
600
  renderSlot(_ctx.$slots, "body", {}, void 0, true)
571
- ], 2),
572
- _ctx.$slots.footer ? (openBlock(), createElementBlock("footer", _hoisted_3$1, [
601
+ ], 8, _hoisted_3$1),
602
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("footer", _hoisted_4, [
573
603
  renderSlot(_ctx.$slots, "footer", {}, void 0, true)
574
604
  ])) : createCommentVNode("", true)
575
605
  ], 64);
@@ -577,22 +607,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
577
607
  }
578
608
  });
579
609
 
580
- const KdsModalLayout = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2a54ec89"]]);
610
+ const KdsModalLayout = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-c600bf4b"]]);
581
611
 
582
612
  const _hoisted_1$1 = ["closedby"];
583
613
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
584
614
  __name: "KdsModal",
585
- props: {
586
- icon: { default: void 0 },
587
- title: { default: "" },
588
- variant: { default: "default" },
589
- width: { default: "medium" },
590
- height: { default: "auto" },
591
- active: { type: Boolean, default: false },
592
- closedby: { default: "closerequest" }
593
- },
615
+ props: /* @__PURE__ */ mergeDefaults({
616
+ icon: {},
617
+ title: {},
618
+ variant: {},
619
+ width: {},
620
+ height: {},
621
+ active: { type: Boolean },
622
+ closedby: {},
623
+ overflow: {}
624
+ }, modalPropsDefault),
594
625
  emits: ["close", "closed"],
595
626
  setup(__props, { emit: __emit }) {
627
+ useCssVars((_ctx) => ({
628
+ "v5f410792": _ctx.overflow
629
+ }));
596
630
  const props = __props;
597
631
  const emit = __emit;
598
632
  const dialog = useTemplateRef("dialogElement");
@@ -636,7 +670,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
636
670
  return renderDialog.value ? (openBlock(), createElementBlock("dialog", {
637
671
  key: 0,
638
672
  ref: "dialogElement",
639
- class: normalizeClass(["kds-modal", `width-${__props.width}`, `height-${__props.height}`]),
673
+ class: normalizeClass([
674
+ "kds-modal",
675
+ `width-${__props.width}`,
676
+ `height-${__props.height}`,
677
+ `overflow-${__props.overflow}`
678
+ ]),
640
679
  closedby: __props.closedby,
641
680
  onCancel: withModifiers(onClose, ["prevent"])
642
681
  }, [
@@ -644,12 +683,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
644
683
  title: __props.title,
645
684
  icon: __props.icon,
646
685
  variant: __props.variant,
686
+ overflow: __props.overflow,
647
687
  onClose
648
688
  }, () => [
649
689
  createVNode(KdsModalLayout, {
650
690
  title: __props.title,
651
691
  icon: __props.icon,
652
692
  variant: __props.variant,
693
+ overflow: __props.overflow,
653
694
  onClose
654
695
  }, {
655
696
  body: withCtx(() => [
@@ -659,14 +700,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
659
700
  renderSlot(_ctx.$slots, "footer", {}, void 0, true)
660
701
  ]),
661
702
  _: 3
662
- }, 8, ["title", "icon", "variant"])
703
+ }, 8, ["title", "icon", "variant", "overflow"])
663
704
  ], true)
664
705
  ], 42, _hoisted_1$1)) : createCommentVNode("", true);
665
706
  };
666
707
  }
667
708
  });
668
709
 
669
- const KdsModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7dc0f65d"]]);
710
+ const KdsModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-a80b4b47"]]);
670
711
 
671
712
  const createUnwrappedPromise = () => {
672
713
  let resolve = () => {
@@ -713,11 +754,22 @@ const close = () => {
713
754
  const isTemplateBasedConfirm = (config) => {
714
755
  return "component" in config;
715
756
  };
757
+ const updateConfig = (config) => {
758
+ if (!isActive.value || !activeModalConfig.value || activeModalConfig.value.type === "confirm") {
759
+ consola.warn("useKdsDynamicModal: invalid invocation of updateConfig");
760
+ return;
761
+ }
762
+ activeModalConfig.value.value = {
763
+ ...activeModalConfig.value.value,
764
+ ...config
765
+ };
766
+ };
716
767
  const internal = {
717
768
  confirm,
718
769
  close,
719
770
  isTemplateBasedConfirm,
720
- onClosed
771
+ onClosed,
772
+ updateConfig
721
773
  };
722
774
  const useKdsDynamicModal = () => {
723
775
  function askConfirmation(config) {
@@ -787,16 +839,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
787
839
  }
788
840
  };
789
841
  const defaultVariant = (type) => type === "cancel" ? "transparent" : "filled";
790
- return (_ctx, _cache) => {
791
- return openBlock(), createBlock(KdsModal, {
792
- class: "confirm-modal",
793
- active: unref(isActive),
794
- title: unref(config)?.value.title,
795
- closedby: unref(config)?.value.closedby,
796
- icon: unref(config)?.value.icon,
842
+ const kdsModalProps = computed(() => {
843
+ if (!config.value) {
844
+ return {};
845
+ }
846
+ const { icon, title, height, width, variant, overflow, closedby } = config.value.value;
847
+ return {
848
+ icon,
849
+ title,
850
+ height,
851
+ width,
852
+ variant,
853
+ overflow,
854
+ closedby,
797
855
  onClose,
798
- onClosed: unref(internal).onClosed
799
- }, createSlots({ _: 2 }, [
856
+ onClosed: internal.onClosed,
857
+ active: isActive.value
858
+ };
859
+ });
860
+ return (_ctx, _cache) => {
861
+ return openBlock(), createBlock(KdsModal, mergeProps({ class: "confirm-modal" }, kdsModalProps.value), createSlots({ _: 2 }, [
800
862
  unref(config)?.type === "confirm" ? {
801
863
  name: "body",
802
864
  fn: withCtx(() => [
@@ -836,16 +898,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
836
898
  unref(config)?.type === "dynamic" ? {
837
899
  name: "default",
838
900
  fn: withCtx((slotProps) => [
839
- (openBlock(), createBlock(resolveDynamicComponent(unref(config).value.component), normalizeProps(guardReactiveProps(slotProps)), null, 16))
901
+ (openBlock(), createBlock(resolveDynamicComponent(unref(config).value.component), normalizeProps(guardReactiveProps({
902
+ ...slotProps,
903
+ context: unref(config).value.context,
904
+ updateConfig: unref(internal).updateConfig
905
+ })), null, 16))
840
906
  ]),
841
907
  key: "2"
842
908
  } : void 0
843
- ]), 1032, ["active", "title", "closedby", "icon", "onClosed"]);
909
+ ]), 1040);
844
910
  };
845
911
  }
846
912
  });
847
913
 
848
- const KdsDynamicModalProvider = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c868f587"]]);
914
+ const KdsDynamicModalProvider = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bd3a851b"]]);
849
915
 
850
916
  const KDS_DARK_MODE_STORAGE_KEY = "KNIME_DARK_MODE";
851
917
  const defaultMode = "light";