cleek 2.2.4 → 2.3.0

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/cleek.es.js CHANGED
@@ -18,6 +18,20 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { defineComponent, ref, openBlock, createElementBlock, createElementVNode, renderSlot, normalizeClass, createCommentVNode, computed as computed$2, normalizeStyle, unref as unref$1, watch, h, createBlock, Teleport, createVNode, createTextVNode, toDisplayString, withCtx, onMounted, nextTick as nextTick$1, onBeforeUnmount, getCurrentInstance, withDirectives, isRef as isRef$1, vModelDynamic, Fragment, renderList, mergeProps, withKeys, withModifiers, pushScopeId, popScopeId, vModelRadio, vModelSelect, vModelCheckbox, vModelText } from "vue";
21
+ var defaultCleekOptions = {
22
+ colors: {
23
+ primary: "#559933",
24
+ secondary: "#559933",
25
+ success: "#559933",
26
+ warning: "#559933",
27
+ danger: "#559933",
28
+ dark: "#559933",
29
+ light: "#559933"
30
+ },
31
+ button: {
32
+ type: "filled"
33
+ }
34
+ };
21
35
  var ckDropdown_vue_vue_type_style_index_0_scoped_true_lang = "";
22
36
  var _export_sfc = (sfc, props) => {
23
37
  const target = sfc.__vccOpts || sfc;
@@ -11542,7 +11556,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
11542
11556
  props: {
11543
11557
  title: { type: String, default: void 0 },
11544
11558
  disabled: { type: Boolean, default: false },
11545
- type: { type: String, default: "outlined", validator: validators.buttonType },
11559
+ type: { type: String, default: void 0, validator: validators.buttonType },
11546
11560
  color: { type: String, default: "primary" },
11547
11561
  align: { type: String, default: "left", validator: validators.align },
11548
11562
  size: { type: String, default: "m", validator: validators.size },
@@ -11560,12 +11574,21 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
11560
11574
  setup(__props, { emit: emits }) {
11561
11575
  const props = __props;
11562
11576
  const { windowWidth } = useWindowWidth();
11577
+ const defaultButtonType = "outlined";
11578
+ let $cleekOptions;
11563
11579
  const isMounted = ref(false);
11580
+ const realButtonType = computed$2(() => {
11581
+ if (props.type)
11582
+ return props.type;
11583
+ if (!isMounted.value && $cleekOptions)
11584
+ return $cleekOptions.button.type;
11585
+ return defaultButtonType;
11586
+ });
11564
11587
  const computedClass = computed$2(() => {
11565
11588
  const classList2 = [];
11566
11589
  classList2.push(functions.getGroupClass(props));
11567
11590
  if (props.color !== "primary") {
11568
- if (props.type === "filled") {
11591
+ if (realButtonType.value === "filled") {
11569
11592
  classList2.push(`ck-component__bg-color--${props.color}`);
11570
11593
  } else {
11571
11594
  classList2.push(`ck-component__border-color--${props.color}`);
@@ -11574,12 +11597,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
11574
11597
  if (props.align === "center" || props.align === "right") {
11575
11598
  classList2.push(`ck-button__align--${props.align}`);
11576
11599
  }
11577
- if (isMounted.value)
11578
- ;
11579
- let type = props.type;
11580
- if (!validators.buttonType(props.type))
11581
- type = "outlined";
11582
- classList2.push(`type-${type}`);
11600
+ classList2.push(`type-${realButtonType.value}`);
11583
11601
  if (props.size)
11584
11602
  classList2.push(`rs-component-size__${props.size}`);
11585
11603
  return classList2;
@@ -11596,7 +11614,10 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
11596
11614
  }
11597
11615
  onMounted(() => {
11598
11616
  getCurrentInstance().ctx;
11599
- isMounted.value = true;
11617
+ $cleekOptions = functions.getCleekOptions(getCurrentInstance);
11618
+ setTimeout(() => {
11619
+ isMounted.value = true;
11620
+ }, 3e3);
11600
11621
  });
11601
11622
  return (_ctx, _cache) => {
11602
11623
  return openBlock(), createElementBlock("button", {
@@ -11610,22 +11631,22 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
11610
11631
  }, [
11611
11632
  __props.icon ? (openBlock(), createBlock(ckIcon, {
11612
11633
  key: 0,
11613
- class: "ck-button__icon-left",
11634
+ class: normalizeClass(["ck-button__icon-left", { "just-icon": !_ctx.$slots.default }]),
11614
11635
  icon: __props.icon,
11615
11636
  "icon-pack": __props.iconPack
11616
- }, null, 8, ["icon", "icon-pack"])) : createCommentVNode("", true),
11637
+ }, null, 8, ["icon", "icon-pack", "class"])) : createCommentVNode("", true),
11617
11638
  renderSlot(_ctx.$slots, "default", {}, void 0, true),
11618
11639
  __props.iconRight ? (openBlock(), createBlock(ckIcon, {
11619
11640
  key: 1,
11620
- class: "ck-button__icon-right",
11641
+ class: normalizeClass(["ck-button__icon-right", { "just-icon": !_ctx.$slots.default }]),
11621
11642
  icon: __props.iconRight,
11622
11643
  "icon-pack": __props.iconPack
11623
- }, null, 8, ["icon", "icon-pack"])) : createCommentVNode("", true)
11644
+ }, null, 8, ["icon", "icon-pack", "class"])) : createCommentVNode("", true)
11624
11645
  ], 14, _hoisted_1$g);
11625
11646
  };
11626
11647
  }
11627
11648
  });
11628
- var ckButton = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-6a5f73e9"]]);
11649
+ var ckButton = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-73fd023c"]]);
11629
11650
  var ckLabel_vue_vue_type_style_index_0_scoped_true_lang = "";
11630
11651
  const _hoisted_1$f = ["for"];
11631
11652
  const _sfc_main$g = /* @__PURE__ */ defineComponent({
@@ -16781,33 +16802,31 @@ var components = /* @__PURE__ */ Object.freeze({
16781
16802
  lockScroll,
16782
16803
  unlockScroll
16783
16804
  });
16784
- function setDefaultColors(options) {
16785
- if (!options)
16786
- return;
16805
+ function setRootColors(colors) {
16787
16806
  var r = document.querySelector(":root");
16788
- const colorList = [
16789
- "primary",
16790
- "secondary",
16791
- "primary",
16792
- "secondary",
16793
- "success",
16794
- "warning",
16795
- "danger",
16796
- "dark",
16797
- "light"
16798
- ];
16799
- if (options.colors) {
16800
- colorList.forEach((colorName) => {
16801
- const colorValue = options.colors[colorName];
16802
- if (colorValue)
16803
- r.style.setProperty(`--${colorName}`, colorValue);
16804
- });
16807
+ for (const key in colors) {
16808
+ const colorValue = colors[key];
16809
+ r.style.setProperty(`--${key}`, colorValue);
16810
+ }
16811
+ }
16812
+ function getCleekOptions(userOptions) {
16813
+ console.log("userOptions", userOptions);
16814
+ const options = defaultCleekOptions;
16815
+ for (const category in defaultCleekOptions) {
16816
+ if (userOptions[category]) {
16817
+ for (const key in category) {
16818
+ const value = userOptions[category][key];
16819
+ if (value)
16820
+ options[category][key] = value;
16821
+ }
16822
+ }
16805
16823
  }
16824
+ setRootColors(options);
16825
+ console.log("options", options);
16826
+ return options;
16806
16827
  }
16807
16828
  const install = function installCleek(app, options) {
16808
- app.config.globalProperties.$cleekOptions = options;
16809
- console.log("arranco paquete", options);
16810
- setDefaultColors(options);
16829
+ app.config.globalProperties.$cleekOptions = getCleekOptions(options);
16811
16830
  Object.entries(components).forEach(([componentName, component]) => {
16812
16831
  app.component(componentName, component);
16813
16832
  });