@cregis/ui 0.1.0 → 0.1.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.
@@ -1,9 +1,9 @@
1
- import { defineComponent as k, computed as y, createElementBlock as r, openBlock as s, createElementVNode as c, createCommentVNode as h, mergeProps as x, createBlock as L, renderSlot as v, resolveDynamicComponent as Q, normalizeClass as g, toDisplayString as w, unref as j, ref as z, watch as E, normalizeStyle as $, withDirectives as q, vModelDynamic as X, withModifiers as _, vModelText as ee, createVNode as K, withCtx as O, createTextVNode as N, nextTick as Y, reactive as te, provide as ae, toRef as ie, Fragment as ne, renderList as le, inject as se, onMounted as oe, onUnmounted as re } from "vue";
2
- import { EdsLoad as de, EdsCloseCircleFill as ce } from "@cregis/icon";
3
- const ue = {
1
+ import { defineComponent as k, computed as y, createElementBlock as r, openBlock as s, createElementVNode as u, createCommentVNode as h, mergeProps as p, createBlock as z, renderSlot as v, resolveDynamicComponent as Y, normalizeClass as g, toDisplayString as $, unref as W, ref as C, watch as S, normalizeStyle as x, withDirectives as F, vModelDynamic as j, withModifiers as Z, vModelText as G, createVNode as D, withCtx as P, createTextVNode as T, nextTick as M, reactive as H, provide as J, toRef as Q, Fragment as X, renderList as _, inject as ee, onMounted as te, onUnmounted as ae } from "vue";
2
+ import { EdsLoad as ie, EdsCloseCircleFill as le } from "@cregis/icon";
3
+ const ne = {
4
4
  key: 0,
5
5
  class: "cregis-button__icon-wrapper"
6
- }, me = ["disabled"], be = ["disabled"], fe = ["disabled"], p = /* @__PURE__ */ k({
6
+ }, se = ["disabled"], oe = ["disabled"], re = ["disabled"], B = /* @__PURE__ */ k({
7
7
  name: "Button",
8
8
  inheritAttrs: !1,
9
9
  __name: "Button",
@@ -22,7 +22,7 @@ const ue = {
22
22
  affix: { type: Boolean }
23
23
  },
24
24
  setup(e) {
25
- const t = e, i = y(() => t.size === "large" ? "20px" : t.size === "medium" ? "16px" : "12px"), d = y(() => t.size === "large" || t.size === "medium" ? "16px" : "12px"), n = y(() => {
25
+ const t = e, i = y(() => t.size === "large" ? "20px" : t.size === "medium" ? "16px" : "12px"), d = y(() => t.size === "large" || t.size === "medium" ? "16px" : "12px"), l = y(() => {
26
26
  if (t.plain || t.text)
27
27
  switch (t.type) {
28
28
  case "primary":
@@ -39,8 +39,8 @@ const ue = {
39
39
  else
40
40
  return t.type === "secondary" ? "var(--material-foreground-base-secondary)" : t.type === "foreground" ? "var(--text-face-primary)" : t.type === "sameWhite" ? "var(--text-same-black)" : "var(--material-same-white)";
41
41
  });
42
- return (a, o) => e.icon || a.$slots.icon ? (s(), r("div", ue, [
43
- c("button", x(a.$attrs, {
42
+ return (a, o) => e.icon || a.$slots.icon ? (s(), r("div", ne, [
43
+ u("button", p(a.$attrs, {
44
44
  class: ["cregis-button__icon", {
45
45
  [`cregis-button__icon--${e.iconType}`]: e.iconType,
46
46
  [`cregis-button__icon--${e.size}`]: e.size,
@@ -48,17 +48,17 @@ const ue = {
48
48
  }],
49
49
  disabled: e.disabled || e.loading
50
50
  }), [
51
- e.icon ? (s(), L(Q(e.icon), {
51
+ e.icon ? (s(), z(Y(e.icon), {
52
52
  key: 0,
53
53
  size: i.value,
54
54
  "stroke-width": 3
55
55
  }, null, 8, ["size"])) : v(a.$slots, "icon", { key: 1 })
56
- ], 16, me),
56
+ ], 16, se),
57
57
  e.iconText ? (s(), r("span", {
58
58
  key: 0,
59
59
  class: g(["cregis-button__icon-text", { "is-disabled": e.disabled }])
60
- }, w(e.iconText), 3)) : h("", !0)
61
- ])) : e.link ? (s(), r("button", x({ key: 1 }, a.$attrs, {
60
+ }, $(e.iconText), 3)) : h("", !0)
61
+ ])) : e.link ? (s(), r("button", p({ key: 1 }, a.$attrs, {
62
62
  class: ["cregis-button__link", {
63
63
  [`cregis-button__link--${e.type}`]: e.type,
64
64
  [`cregis-button__link--${e.size}`]: e.size,
@@ -67,7 +67,7 @@ const ue = {
67
67
  disabled: e.disabled || e.loading
68
68
  }), [
69
69
  v(a.$slots, "default")
70
- ], 16, be)) : (s(), r("button", x({
70
+ ], 16, oe)) : (s(), r("button", p({
71
71
  key: 2,
72
72
  ref: "buttonRef"
73
73
  }, a.$attrs, {
@@ -83,25 +83,25 @@ const ue = {
83
83
  }],
84
84
  disabled: e.disabled || e.loading
85
85
  }), [
86
- e.loading ? (s(), L(j(de), {
86
+ e.loading ? (s(), z(W(ie), {
87
87
  key: 0,
88
88
  class: "loading",
89
89
  size: d.value,
90
- color: n.value,
90
+ color: l.value,
91
91
  "stroke-width": 3
92
92
  }, null, 8, ["size", "color"])) : v(a.$slots, "default", { key: 1 })
93
- ], 16, fe));
93
+ ], 16, re));
94
94
  }
95
- }), ge = {
95
+ }), de = {
96
96
  key: 0,
97
97
  class: "cregis-input__prefix"
98
- }, ye = ["type", "placeholder", "disabled"], he = {
98
+ }, ue = ["type", "placeholder", "disabled"], ce = {
99
99
  key: 2,
100
100
  class: "cregis-input__suffix"
101
- }, ve = ["disabled", "placeholder", "rows"], ke = {
101
+ }, me = ["disabled", "placeholder", "rows"], be = {
102
102
  key: 0,
103
103
  class: "cregis-textarea__buttons"
104
- }, T = /* @__PURE__ */ k({
104
+ }, ze = /* @__PURE__ */ k({
105
105
  name: "Input",
106
106
  inheritAttrs: !1,
107
107
  __name: "Input",
@@ -119,92 +119,92 @@ const ue = {
119
119
  },
120
120
  emits: ["update:modelValue", "input", "change", "focus", "blur", "clear"],
121
121
  setup(e, { expose: t, emit: i }) {
122
- const d = e, n = i, a = z(d.modelValue);
123
- E(
122
+ const d = e, l = i, a = C(d.modelValue);
123
+ S(
124
124
  () => d.modelValue,
125
- (l) => {
126
- a.value = l;
125
+ (n) => {
126
+ a.value = n;
127
127
  }
128
128
  );
129
- const o = z(), u = z(0), f = z(!1);
130
- let C = null;
131
- const G = async () => {
132
- await Y(), o.value?.focus();
133
- }, A = async () => {
134
- n("update:modelValue", a.value), n("input", a.value), await Y(), U();
135
- }, F = () => {
136
- n("change", a.value);
137
- }, D = (l) => {
138
- f.value = !0, n("focus", l);
139
- }, P = (l) => {
140
- f.value = !1, n("blur", l);
141
- }, M = y(() => d.clearable && !d.disabled && !!a.value && f.value), W = () => {
142
- a.value = "", n("update:modelValue", ""), n("clear"), n("input", ""), n("change", "");
143
- }, U = () => {
144
- C && cancelAnimationFrame(C), C = requestAnimationFrame(() => {
129
+ const o = C(), c = C(0), f = C(!1);
130
+ let w = null;
131
+ const q = async () => {
132
+ await M(), o.value?.focus();
133
+ }, V = async () => {
134
+ l("update:modelValue", a.value), l("input", a.value), await M(), E();
135
+ }, R = () => {
136
+ l("change", a.value);
137
+ }, I = (n) => {
138
+ f.value = !0, l("focus", n);
139
+ }, L = (n) => {
140
+ f.value = !1, l("blur", n);
141
+ }, N = y(() => d.clearable && !d.disabled && !!a.value && f.value), A = () => {
142
+ a.value = "", l("update:modelValue", ""), l("clear"), l("input", ""), l("change", "");
143
+ }, E = () => {
144
+ w && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
145
145
  if (!o.value || o.value.tagName !== "INPUT") return;
146
- const l = o.value, b = l.value, m = document.createElement("span");
147
- m.style.position = "absolute", m.style.visibility = "hidden", m.style.whiteSpace = "pre", m.style.font = window.getComputedStyle(l).font, m.style.letterSpacing = window.getComputedStyle(l).letterSpacing, m.textContent = b || " ", document.body.appendChild(m), u.value = m.getBoundingClientRect().width, document.body.removeChild(m);
146
+ const n = o.value, b = n.value, m = document.createElement("span");
147
+ m.style.position = "absolute", m.style.visibility = "hidden", m.style.whiteSpace = "pre", m.style.font = window.getComputedStyle(n).font, m.style.letterSpacing = window.getComputedStyle(n).letterSpacing, m.textContent = b || " ", document.body.appendChild(m), c.value = m.getBoundingClientRect().width, document.body.removeChild(m);
148
148
  });
149
- }, H = y(() => {
150
- const l = {};
151
- return u.value > 0 && (l.position = "absolute", l.left = `${u.value + 16}px`), l;
152
- }), J = async () => {
149
+ }, K = y(() => {
150
+ const n = {};
151
+ return c.value > 0 && (n.position = "absolute", n.left = `${c.value + 16}px`), n;
152
+ }), O = async () => {
153
153
  try {
154
154
  a.value = await navigator.clipboard.readText();
155
- } catch (l) {
156
- console.error("paste error:", l);
155
+ } catch (n) {
156
+ console.error("paste error:", n);
157
157
  }
158
158
  };
159
159
  return t({
160
- focus: G,
161
- updateTextWidth: U
162
- }), (l, b) => e.type !== "textarea" ? (s(), r("div", {
160
+ focus: q,
161
+ updateTextWidth: E
162
+ }), (n, b) => e.type !== "textarea" ? (s(), r("div", {
163
163
  key: 0,
164
164
  class: g(["cregis-input", {
165
165
  [`cregis-input--${e.size}`]: e.size,
166
166
  "is-disabled": e.disabled,
167
- "is-prefix": l.$slots.prefix,
168
- "is-suffix": l.$slots.suffix
167
+ "is-prefix": n.$slots.prefix,
168
+ "is-suffix": n.$slots.suffix
169
169
  }]),
170
- style: $([{ width: e.width }, e.inputStyle])
170
+ style: x([{ width: e.width }, e.inputStyle])
171
171
  }, [
172
- c("div", {
172
+ u("div", {
173
173
  class: g(["cregis-input__wrapper", { "is-focus": f.value }])
174
174
  }, [
175
- l.$slots.prefix ? (s(), r("span", ge, [
176
- v(l.$slots, "prefix")
175
+ n.$slots.prefix ? (s(), r("span", de, [
176
+ v(n.$slots, "prefix")
177
177
  ])) : h("", !0),
178
- q(c("input", x({
178
+ F(u("input", p({
179
179
  class: "cregis-input__inner",
180
180
  "onUpdate:modelValue": b[0] || (b[0] = (m) => a.value = m),
181
181
  ref_key: "inputRef",
182
182
  ref: o,
183
183
  type: e.type,
184
184
  placeholder: e.placeholder
185
- }, l.$attrs, {
185
+ }, n.$attrs, {
186
186
  disabled: e.disabled,
187
- onInput: A,
188
- onChange: F,
189
- onFocus: D,
190
- onBlur: P
191
- }), null, 16, ye), [
192
- [X, a.value]
187
+ onInput: V,
188
+ onChange: R,
189
+ onFocus: I,
190
+ onBlur: L
191
+ }), null, 16, ue), [
192
+ [j, a.value]
193
193
  ]),
194
194
  e.unit && a.value ? (s(), r("span", {
195
195
  key: 1,
196
- style: $(H.value),
196
+ style: x(K.value),
197
197
  class: "cregis-input__unit"
198
- }, w(e.unit), 5)) : h("", !0),
199
- l.$slots.suffix || M.value ? (s(), r("span", he, [
200
- v(l.$slots, "suffix"),
201
- M.value ? (s(), L(p, {
198
+ }, $(e.unit), 5)) : h("", !0),
199
+ n.$slots.suffix || N.value ? (s(), r("span", ce, [
200
+ v(n.$slots, "suffix"),
201
+ N.value ? (s(), z(B, {
202
202
  key: 0,
203
203
  class: "cregis-input__clear-button",
204
- icon: j(ce),
204
+ icon: W(le),
205
205
  "icon-type": "square",
206
- onClick: W,
207
- onMousedown: b[1] || (b[1] = _(() => {
206
+ onClick: A,
207
+ onMousedown: b[1] || (b[1] = Z(() => {
208
208
  }, ["prevent"]))
209
209
  }, null, 8, ["icon"])) : h("", !0)
210
210
  ])) : h("", !0)
@@ -212,62 +212,55 @@ const ue = {
212
212
  ], 6)) : (s(), r("div", {
213
213
  key: 1,
214
214
  class: g(["cregis-textarea", { "is-disabled": e.disabled }]),
215
- style: $([{ width: e.width }, e.inputStyle])
215
+ style: x([{ width: e.width }, e.inputStyle])
216
216
  }, [
217
- q(c("textarea", x({ class: "cregis-textarea__wrapper" }, l.$attrs, {
217
+ F(u("textarea", p({ class: "cregis-textarea__wrapper" }, n.$attrs, {
218
218
  ref_key: "inputRef",
219
219
  ref: o,
220
220
  disabled: e.disabled,
221
221
  placeholder: e.placeholder,
222
222
  rows: e.rows,
223
223
  "onUpdate:modelValue": b[2] || (b[2] = (m) => a.value = m),
224
- onInput: A,
225
- onChange: F,
226
- onFocus: D,
227
- onBlur: P
228
- }), null, 16, ve), [
229
- [ee, a.value]
224
+ onInput: V,
225
+ onChange: R,
226
+ onFocus: I,
227
+ onBlur: L
228
+ }), null, 16, me), [
229
+ [G, a.value]
230
230
  ]),
231
- e.disabled ? h("", !0) : (s(), r("div", ke, [
232
- K(p, {
231
+ e.disabled ? h("", !0) : (s(), r("div", be, [
232
+ D(B, {
233
233
  class: "cregis-textarea__button",
234
234
  link: "",
235
235
  size: "small",
236
- onClick: J
236
+ onClick: O
237
237
  }, {
238
- default: O(() => [...b[3] || (b[3] = [
239
- N(" Paste ", -1)
238
+ default: P(() => [...b[3] || (b[3] = [
239
+ T(" Paste ", -1)
240
240
  ])]),
241
241
  _: 1
242
242
  }),
243
- K(p, {
243
+ D(B, {
244
244
  class: "cregis-textarea__button",
245
245
  link: "",
246
246
  size: "small",
247
247
  disabled: !a.value,
248
- onClick: W
248
+ onClick: A
249
249
  }, {
250
- default: O(() => [...b[4] || (b[4] = [
251
- N(" Clear ", -1)
250
+ default: P(() => [...b[4] || (b[4] = [
251
+ T(" Clear ", -1)
252
252
  ])]),
253
253
  _: 1
254
254
  }, 8, ["disabled"])
255
255
  ]))
256
256
  ], 6));
257
257
  }
258
- });
259
- T.install = (e) => {
260
- e.component(T.name, T);
261
- };
262
- p.install = (e) => {
263
- e.component(p.name, p);
264
- };
265
- const pe = ["width", "height"], xe = {
258
+ }), fe = ["width", "height"], ge = {
266
259
  stroke: "none",
267
260
  "stroke-width": "1",
268
261
  fill: "none",
269
262
  "fill-rule": "evenodd"
270
- }, $e = { transform: "translate(-394.000000, -457.000000)" }, we = { transform: "translate(394.000000, 457.000000)" }, Ce = ["width", "height"], ze = /* @__PURE__ */ k({
263
+ }, ye = { transform: "translate(-394.000000, -457.000000)" }, he = { transform: "translate(394.000000, 457.000000)" }, ve = ["width", "height"], ke = /* @__PURE__ */ k({
271
264
  __name: "checked-basis",
272
265
  props: {
273
266
  size: { default: "16px" }
@@ -281,16 +274,16 @@ const pe = ["width", "height"], xe = {
281
274
  xmlns: "http://www.w3.org/2000/svg",
282
275
  "xmlns:xlink": "http://www.w3.org/1999/xlink"
283
276
  }, [
284
- c("g", xe, [
285
- c("g", $e, [
286
- c("g", we, [
287
- c("rect", {
277
+ u("g", ge, [
278
+ u("g", ye, [
279
+ u("g", he, [
280
+ u("rect", {
288
281
  x: "0",
289
282
  y: "0",
290
283
  width: e.size,
291
284
  height: e.size
292
- }, null, 8, Ce),
293
- i[0] || (i[0] = c("path", {
285
+ }, null, 8, ve),
286
+ i[0] || (i[0] = u("path", {
294
287
  d: "M6.67713976,13.5709642 C7.12567714,13.5709642 7.468039,13.3943662 7.70422535,13.0411701 L13.7562297,3.77789816 C13.8407367,3.65005417 13.9024919,3.52546046 13.9414951,3.40411701 C13.9804984,3.28277356 14,3.16468039 14,3.04983749 C14,2.74647887 13.8976165,2.49566631 13.6928494,2.29739978 C13.4880823,2.09913326 13.2307692,2 12.9209101,2 C12.7063922,2 12.5265439,2.04225352 12.3813651,2.12676056 C12.2361863,2.21126761 12.0975081,2.35536295 11.9653304,2.55904659 L6.65113759,10.9512459 L3.95016251,7.60346696 C3.71830986,7.32177681 3.43011918,7.18093174 3.08559047,7.18093174 C2.77139762,7.18093174 2.51191766,7.28169014 2.3071506,7.48320693 C2.10238353,7.68472373 2,7.93824485 2,8.24377031 C2,8.38028169 2.02329361,8.51083424 2.06988082,8.63542795 C2.11646804,8.76002167 2.19826652,8.88949079 2.31527627,9.02383532 L5.67280607,13.0899242 C5.94149512,13.4106176 6.27627302,13.5709642 6.67713976,13.5709642 Z",
295
288
  fill: "currentColor",
296
289
  "fill-rule": "nonzero"
@@ -298,12 +291,12 @@ const pe = ["width", "height"], xe = {
298
291
  ])
299
292
  ])
300
293
  ])
301
- ], 8, pe));
294
+ ], 8, fe));
302
295
  }
303
- }), Te = {
296
+ }), pe = {
304
297
  key: 0,
305
298
  class: "cregis-checkbox--indeterminate"
306
- }, B = /* @__PURE__ */ k({
299
+ }, Te = /* @__PURE__ */ k({
307
300
  name: "Checkbox",
308
301
  __name: "Checkbox",
309
302
  props: {
@@ -315,27 +308,27 @@ const pe = ["width", "height"], xe = {
315
308
  },
316
309
  emits: ["update:modelValue", "change"],
317
310
  setup(e, { emit: t }) {
318
- const i = e, d = t, n = y(() => i.modelValue), a = () => {
319
- i.disabled || d("update:modelValue", !n.value);
311
+ const i = e, d = t, l = y(() => i.modelValue), a = () => {
312
+ i.disabled || d("update:modelValue", !l.value);
320
313
  };
321
- return E(
322
- () => n.value,
314
+ return S(
315
+ () => l.value,
323
316
  () => {
324
- d("change", n.value);
317
+ d("change", l.value);
325
318
  }
326
- ), (o, u) => (s(), r("div", {
319
+ ), (o, c) => (s(), r("div", {
327
320
  class: "cregis-checkbox__wrapper",
328
321
  onClick: a
329
322
  }, [
330
- c("div", {
323
+ u("div", {
331
324
  class: g(["cregis-checkbox", {
332
325
  "is-disabled": e.disabled,
333
- "is-checked": n.value,
326
+ "is-checked": l.value,
334
327
  "is-circle": e.circle,
335
328
  "is-indeterminate": e.indeterminate
336
329
  }])
337
330
  }, [
338
- e.indeterminate ? (s(), r("div", Te)) : (s(), L(ze, {
331
+ e.indeterminate ? (s(), r("div", pe)) : (s(), z(ke, {
339
332
  key: 1,
340
333
  size: "10px"
341
334
  }))
@@ -345,16 +338,12 @@ const pe = ["width", "height"], xe = {
345
338
  class: g(["cregis-checkbox__label", { "is-disabled": e.disabled }])
346
339
  }, [
347
340
  v(o.$slots, "default", {}, () => [
348
- N(w(e.label), 1)
341
+ T($(e.label), 1)
349
342
  ])
350
343
  ], 2)) : h("", !0)
351
344
  ]));
352
345
  }
353
- });
354
- B.install = (e) => {
355
- e.component(B.name, B);
356
- };
357
- const S = /* @__PURE__ */ k({
346
+ }), Be = /* @__PURE__ */ k({
358
347
  name: "Radio",
359
348
  __name: "Radio",
360
349
  props: {
@@ -365,36 +354,32 @@ const S = /* @__PURE__ */ k({
365
354
  },
366
355
  emits: ["update:modelValue", "change"],
367
356
  setup(e, { emit: t }) {
368
- const i = e, d = t, n = y(() => i.modelValue === i.value), a = () => {
357
+ const i = e, d = t, l = y(() => i.modelValue === i.value), a = () => {
369
358
  i.disabled || (d("update:modelValue", i.value), d("change", i.value));
370
359
  };
371
- return (o, u) => (s(), r("div", {
360
+ return (o, c) => (s(), r("div", {
372
361
  class: "cregis-radio__wrapper",
373
362
  onClick: a
374
363
  }, [
375
- c("div", {
364
+ u("div", {
376
365
  class: g(["cregis-radio", {
377
366
  "is-disabled": e.disabled,
378
- "is-checked": n.value
367
+ "is-checked": l.value
379
368
  }])
380
- }, [...u[0] || (u[0] = [
381
- c("div", { class: "cregis-radio__inner" }, null, -1)
369
+ }, [...c[0] || (c[0] = [
370
+ u("div", { class: "cregis-radio__inner" }, null, -1)
382
371
  ])], 2),
383
372
  o.$slots.default || e.label ? (s(), r("span", {
384
373
  key: 0,
385
374
  class: g(["cregis-radio__label", { "is-disabled": e.disabled }])
386
375
  }, [
387
376
  v(o.$slots, "default", {}, () => [
388
- N(w(e.label), 1)
377
+ T($(e.label), 1)
389
378
  ])
390
379
  ], 2)) : h("", !0)
391
380
  ]));
392
381
  }
393
- });
394
- S.install = (e) => {
395
- e.component(S.name, S);
396
- };
397
- const V = /* @__PURE__ */ k({
382
+ }), Se = /* @__PURE__ */ k({
398
383
  name: "Divider",
399
384
  __name: "Divider",
400
385
  props: {
@@ -408,8 +393,8 @@ const V = /* @__PURE__ */ k({
408
393
  setup(e) {
409
394
  const t = e, i = y(() => {
410
395
  if (Array.isArray(t.margin)) {
411
- const [n, a] = t.margin;
412
- return t.direction === "horizontal" ? `${n} 0 ${a} 0` : `0 ${a} 0 ${n}`;
396
+ const [l, a] = t.margin;
397
+ return t.direction === "horizontal" ? `${l} 0 ${a} 0` : `0 ${a} 0 ${l}`;
413
398
  } else
414
399
  return t.direction === "horizontal" ? `${t.margin} 0` : `0 ${t.margin}`;
415
400
  }), d = y(() => t.direction === "horizontal" ? {
@@ -425,18 +410,14 @@ const V = /* @__PURE__ */ k({
425
410
  borderLeftColor: t.color,
426
411
  margin: i.value
427
412
  });
428
- return (n, a) => (s(), r("div", {
413
+ return (l, a) => (s(), r("div", {
429
414
  class: g(["cregis-divider", {
430
415
  [`cregis-divider--${e.direction}`]: e.direction
431
416
  }]),
432
- style: $(d.value)
417
+ style: x(d.value)
433
418
  }, null, 6));
434
419
  }
435
- });
436
- V.install = (e) => {
437
- e.component(V.name, V);
438
- };
439
- const Z = Symbol("TABS_KEY"), Be = ["onClick"], Se = { style: { display: "none" } }, R = /* @__PURE__ */ k({
420
+ }), U = Symbol("TABS_KEY"), xe = ["onClick"], $e = { style: { display: "none" } }, Ve = /* @__PURE__ */ k({
440
421
  name: "Tabs",
441
422
  __name: "Tabs",
442
423
  props: {
@@ -446,11 +427,11 @@ const Z = Symbol("TABS_KEY"), Be = ["onClick"], Se = { style: { display: "none"
446
427
  },
447
428
  emits: ["update:modelValue"],
448
429
  setup(e) {
449
- const t = e, i = te([]), d = (o) => {
450
- i.some((u) => u.name === o.name) || i.push(o);
451
- }, n = (o) => {
452
- const u = i.findIndex((f) => f.name === o);
453
- u !== -1 && i.splice(u, 1);
430
+ const t = e, i = H([]), d = (o) => {
431
+ i.some((c) => c.name === o.name) || i.push(o);
432
+ }, l = (o) => {
433
+ const c = i.findIndex((f) => f.name === o);
434
+ c !== -1 && i.splice(c, 1);
454
435
  }, a = y(() => t.type === "card" ? t.size === "large" ? {
455
436
  borderRadius: "13px"
456
437
  } : t.size === "medium" ? {
@@ -460,30 +441,30 @@ const Z = Symbol("TABS_KEY"), Be = ["onClick"], Se = { style: { display: "none"
460
441
  } : {
461
442
  borderRadius: 0
462
443
  });
463
- return ae(Z, {
464
- activeName: ie(t, "modelValue"),
444
+ return J(U, {
445
+ activeName: Q(t, "modelValue"),
465
446
  registerTab: d,
466
- unregisterTab: n
467
- }), (o, u) => (s(), r("div", {
447
+ unregisterTab: l
448
+ }), (o, c) => (s(), r("div", {
468
449
  class: g(["cregis-tabs", {
469
450
  [`cregis-tabs--${e.type}`]: e.type,
470
451
  [`cregis-tabs--${e.size}`]: e.size
471
452
  }])
472
453
  }, [
473
- (s(!0), r(ne, null, le(i, (f) => (s(), r("div", {
454
+ (s(!0), r(X, null, _(i, (f) => (s(), r("div", {
474
455
  key: f.name,
475
456
  class: g(["cregis-tabs__item", { "is-active": e.modelValue === f.name }]),
476
- style: $(a.value),
477
- onClick: (C) => o.$emit("update:modelValue", f.name)
457
+ style: x(a.value),
458
+ onClick: (w) => o.$emit("update:modelValue", f.name)
478
459
  }, [
479
- c("span", null, w(f.label), 1)
480
- ], 14, Be))), 128)),
481
- c("div", Se, [
460
+ u("span", null, $(f.label), 1)
461
+ ], 14, xe))), 128)),
462
+ u("div", $e, [
482
463
  v(o.$slots, "default")
483
464
  ])
484
465
  ], 2));
485
466
  }
486
- }), I = /* @__PURE__ */ k({
467
+ }), Re = /* @__PURE__ */ k({
487
468
  name: "TabPane",
488
469
  __name: "TabPane",
489
470
  props: {
@@ -491,42 +472,28 @@ const Z = Symbol("TABS_KEY"), Be = ["onClick"], Se = { style: { display: "none"
491
472
  name: {}
492
473
  },
493
474
  setup(e) {
494
- const t = e, i = se(Z);
475
+ const t = e, i = ee(U);
495
476
  if (!i) throw new Error("TabPane must be used within Tabs");
496
- return oe(() => {
477
+ return te(() => {
497
478
  i.registerTab({ label: t.label, name: t.name });
498
- }), E(
479
+ }), S(
499
480
  () => t.label,
500
481
  (d) => {
501
482
  i.unregisterTab(t.name), i.registerTab({ label: d, name: t.name });
502
483
  }
503
- ), re(() => {
484
+ ), ae(() => {
504
485
  i.unregisterTab(t.name);
505
486
  }), () => {
506
487
  };
507
488
  }
508
489
  });
509
- R.install = (e) => {
510
- e.component(R.name, R);
511
- };
512
- I.install = (e) => {
513
- e.component(I.name, I);
514
- };
515
- const Ve = [T, p, B, S, V, R, I], Re = (e) => {
516
- Ve.forEach((t) => {
517
- e.component(t.name, t);
518
- });
519
- }, Ne = {
520
- install: Re
521
- };
522
490
  export {
523
- p as Button,
524
- B as Checkbox,
525
- V as Divider,
526
- T as Input,
527
- S as Radio,
528
- I as TabPane,
529
- R as Tabs,
530
- Ne as default,
531
- Re as install
491
+ B as Button,
492
+ Te as Checkbox,
493
+ Se as Divider,
494
+ ze as Input,
495
+ Be as Radio,
496
+ U as TABS_KEY,
497
+ Re as TabPane,
498
+ Ve as Tabs
532
499
  };
@@ -1,10 +1,11 @@
1
- import { App } from 'vue';
2
1
  import { Component } from 'vue';
3
2
  import { ComponentOptionsMixin } from 'vue';
4
3
  import { ComponentProvideOptions } from 'vue';
5
4
  import { CSSProperties } from 'vue';
6
5
  import { DefineComponent } from 'vue';
6
+ import { InjectionKey } from 'vue';
7
7
  import { PublicProps } from 'vue';
8
+ import { Ref } from 'vue';
8
9
 
9
10
  declare const __VLS_component: DefineComponent<InputProps, {
10
11
  focus: () => Promise<void>;
@@ -163,7 +164,7 @@ declare type __VLS_WithTemplateSlots_5<T, S> = T & {
163
164
 
164
165
  export declare const Button: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
165
166
 
166
- declare interface ButtonProps {
167
+ export declare interface ButtonProps {
167
168
  type?: ButtonType;
168
169
  size?: ButtonSize;
169
170
  plain?: boolean;
@@ -178,13 +179,18 @@ declare interface ButtonProps {
178
179
  affix?: boolean;
179
180
  }
180
181
 
181
- declare type ButtonSize = 'extraSmall' | 'small' | 'medium' | 'large';
182
+ export declare type ButtonSize = 'extraSmall' | 'small' | 'medium' | 'large';
182
183
 
183
- declare type ButtonType = 'primary' | 'secondary' | 'danger' | 'foreground' | 'sameWhite';
184
+ export declare type ButtonType = 'primary' | 'secondary' | 'danger' | 'foreground' | 'sameWhite';
184
185
 
185
186
  export declare const Checkbox: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
186
187
 
187
- declare interface CheckboxProps {
188
+ export declare interface CheckboxEmits {
189
+ (e: 'update:modelValue', value: boolean | number): void;
190
+ (e: 'change', value: boolean | number): void;
191
+ }
192
+
193
+ export declare interface CheckboxProps {
188
194
  modelValue: boolean | number;
189
195
  label?: string;
190
196
  disabled?: boolean;
@@ -192,11 +198,6 @@ declare interface CheckboxProps {
192
198
  indeterminate?: boolean;
193
199
  }
194
200
 
195
- declare const _default: {
196
- install: (app: App) => void;
197
- };
198
- export default _default;
199
-
200
201
  export declare const Divider: DefineComponent<DividerProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<DividerProps> & Readonly<{}>, {
201
202
  color: string;
202
203
  direction: "horizontal" | "vertical";
@@ -205,7 +206,7 @@ export declare const Divider: DefineComponent<DividerProps, {}, {}, {}, {}, Comp
205
206
  margin: string | [string, string];
206
207
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
207
208
 
208
- declare interface DividerProps {
209
+ export declare interface DividerProps {
209
210
  direction?: 'horizontal' | 'vertical';
210
211
  borderStyle?: 'solid' | 'dashed' | 'dotted';
211
212
  lineThickness?: string;
@@ -214,11 +215,20 @@ declare interface DividerProps {
214
215
  length?: string;
215
216
  }
216
217
 
217
- declare type IconButtonType = 'rectangle' | 'square' | 'circle' | 'professional';
218
+ export declare type IconButtonType = 'rectangle' | 'square' | 'circle' | 'professional';
218
219
 
219
220
  export declare const Input: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
220
221
 
221
- declare interface InputProps {
222
+ export declare interface InputEmits {
223
+ (e: 'update:modelValue', value: StringOrNumber): void;
224
+ (e: 'input', value: StringOrNumber): void;
225
+ (e: 'change', value: StringOrNumber): void;
226
+ (e: 'focus', value: FocusEvent): void;
227
+ (e: 'blur', value: FocusEvent): void;
228
+ (e: 'clear'): void;
229
+ }
230
+
231
+ export declare interface InputProps {
222
232
  type?: 'text' | 'number' | 'textarea';
223
233
  modelValue: StringOrNumber;
224
234
  size?: 'small' | 'medium' | 'large';
@@ -231,33 +241,48 @@ declare interface InputProps {
231
241
  rows?: number;
232
242
  }
233
243
 
234
- export declare const install: (app: App) => void;
235
-
236
244
  export declare const Radio: __VLS_WithTemplateSlots_4<typeof __VLS_component_4, __VLS_TemplateResult_4["slots"]>;
237
245
 
238
- declare interface RadioProps {
246
+ export declare interface RadioEmits {
247
+ (e: 'update:modelValue', value: RadioValue): void;
248
+ (e: 'change', value: RadioValue): void;
249
+ }
250
+
251
+ export declare interface RadioProps {
239
252
  modelValue: RadioValue;
240
253
  value: RadioValue;
241
254
  label?: string;
242
255
  disabled?: boolean;
243
256
  }
244
257
 
245
- declare type RadioValue = boolean | string | number;
258
+ export declare type RadioValue = boolean | string | number;
246
259
 
247
260
  declare type StringOrNumber = string | number;
248
261
 
249
262
  export declare const TabPane: DefineComponent<TabPaneProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<TabPaneProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
250
263
 
251
- declare interface TabPaneProps {
264
+ export declare interface TabPaneProps {
252
265
  label: string;
253
266
  name: string | number;
254
267
  }
255
268
 
256
269
  export declare const Tabs: __VLS_WithTemplateSlots_5<typeof __VLS_component_5, __VLS_TemplateResult_5["slots"]>;
257
270
 
258
- declare type TabSize = 'small' | 'medium' | 'large';
271
+ export declare const TABS_KEY: InjectionKey<TabsContext>;
272
+
273
+ export declare interface TabsContext {
274
+ activeName: Ref<string | number>;
275
+ registerTab: (pane: TabPaneProps) => void;
276
+ unregisterTab: (name: string | number) => void;
277
+ }
278
+
279
+ export declare interface TabsEmits {
280
+ (e: 'update:modelValue', name: string | number): void;
281
+ }
282
+
283
+ export declare type TabSize = 'small' | 'medium' | 'large';
259
284
 
260
- declare interface TabsProps {
285
+ export declare interface TabsProps {
261
286
  modelValue: string | number;
262
287
  type?: 'default' | 'card';
263
288
  size?: TabSize;
@@ -1 +1 @@
1
- (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@cregis/icon")):typeof define=="function"&&define.amd?define(["exports","vue","@cregis/icon"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.CregisUI={},c.Vue,c.CregisIcon))})(this,(function(c,e,$){"use strict";const I={key:0,class:"cregis-button__icon-wrapper"},D=["disabled"],P=["disabled"],L=["disabled"],f=e.defineComponent({name:"Button",inheritAttrs:!1,__name:"Button",props:{type:{default:"primary"},size:{default:"medium"},plain:{type:Boolean},text:{type:Boolean},disabled:{type:Boolean},loading:{type:Boolean},block:{type:Boolean},link:{type:Boolean},icon:{},iconType:{default:"rectangle"},iconText:{},affix:{type:Boolean}},setup(t){const n=t,a=e.computed(()=>n.size==="large"?"20px":n.size==="medium"?"16px":"12px"),r=e.computed(()=>n.size==="large"||n.size==="medium"?"16px":"12px"),i=e.computed(()=>{if(n.plain||n.text)switch(n.type){case"primary":return"var(--material-vibrant-brand-primary)";case"secondary":return"var(--material-foreground-base-secondary)";case"danger":return"var(--material-vibrant-error-primary)";case"foreground":return"var(--material-foreground-base-primary)";case"sameWhite":return"var(--material-same-black)"}else return n.type==="secondary"?"var(--material-foreground-base-secondary)":n.type==="foreground"?"var(--text-face-primary)":n.type==="sameWhite"?"var(--text-same-black)":"var(--material-same-white)"});return(l,s)=>t.icon||l.$slots.icon?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("button",e.mergeProps(l.$attrs,{class:["cregis-button__icon",{[`cregis-button__icon--${t.iconType}`]:t.iconType,[`cregis-button__icon--${t.size}`]:t.size,"is-disabled":t.disabled}],disabled:t.disabled||t.loading}),[t.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon),{key:0,size:a.value,"stroke-width":3},null,8,["size"])):e.renderSlot(l.$slots,"icon",{key:1})],16,D),t.iconText?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-button__icon-text",{"is-disabled":t.disabled}])},e.toDisplayString(t.iconText),3)):e.createCommentVNode("",!0)])):t.link?(e.openBlock(),e.createElementBlock("button",e.mergeProps({key:1},l.$attrs,{class:["cregis-button__link",{[`cregis-button__link--${t.type}`]:t.type,[`cregis-button__link--${t.size}`]:t.size,"is-disabled":t.disabled}],disabled:t.disabled||t.loading}),[e.renderSlot(l.$slots,"default")],16,P)):(e.openBlock(),e.createElementBlock("button",e.mergeProps({key:2,ref:"buttonRef"},l.$attrs,{class:["cregis-button",{[`cregis-button--${t.type}`]:t.type,[`cregis-button--${t.size}`]:t.size,"is-plain":t.plain,"is-text":t.text,"is-disabled":t.disabled,"is-loading":t.loading,"is-block":t.block,"is-affix":t.affix}],disabled:t.disabled||t.loading}),[t.loading?(e.openBlock(),e.createBlock(e.unref($.EdsLoad),{key:0,class:"loading",size:r.value,color:i.value,"stroke-width":3},null,8,["size","color"])):e.renderSlot(l.$slots,"default",{key:1})],16,L))}}),A={key:0,class:"cregis-input__prefix"},F=["type","placeholder","disabled"],M={key:2,class:"cregis-input__suffix"},W=["disabled","placeholder","rows"],U={key:0,class:"cregis-textarea__buttons"},g=e.defineComponent({name:"Input",inheritAttrs:!1,__name:"Input",props:{type:{default:"text"},modelValue:{},size:{default:"medium"},width:{default:"300px"},placeholder:{default:"please input"},disabled:{type:Boolean},clearable:{type:Boolean},inputStyle:{},unit:{},rows:{default:3}},emits:["update:modelValue","input","change","focus","blur","clear"],setup(t,{expose:n,emit:a}){const r=t,i=a,l=e.ref(r.modelValue);e.watch(()=>r.modelValue,o=>{l.value=o});const s=e.ref(),d=e.ref(0),b=e.ref(!1);let B=null;const _=async()=>{await e.nextTick(),s.value?.focus()},z=async()=>{i("update:modelValue",l.value),i("input",l.value),await e.nextTick(),R()},V=()=>{i("change",l.value)},S=o=>{b.value=!0,i("focus",o)},T=o=>{b.value=!1,i("blur",o)},E=e.computed(()=>r.clearable&&!r.disabled&&!!l.value&&b.value),N=()=>{l.value="",i("update:modelValue",""),i("clear"),i("input",""),i("change","")},R=()=>{B&&cancelAnimationFrame(B),B=requestAnimationFrame(()=>{if(!s.value||s.value.tagName!=="INPUT")return;const o=s.value,u=o.value,m=document.createElement("span");m.style.position="absolute",m.style.visibility="hidden",m.style.whiteSpace="pre",m.style.font=window.getComputedStyle(o).font,m.style.letterSpacing=window.getComputedStyle(o).letterSpacing,m.textContent=u||" ",document.body.appendChild(m),d.value=m.getBoundingClientRect().width,document.body.removeChild(m)})},v=e.computed(()=>{const o={};return d.value>0&&(o.position="absolute",o.left=`${d.value+16}px`),o}),ee=async()=>{try{l.value=await navigator.clipboard.readText()}catch(o){console.error("paste error:",o)}};return n({focus:_,updateTextWidth:R}),(o,u)=>t.type!=="textarea"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cregis-input",{[`cregis-input--${t.size}`]:t.size,"is-disabled":t.disabled,"is-prefix":o.$slots.prefix,"is-suffix":o.$slots.suffix}]),style:e.normalizeStyle([{width:t.width},t.inputStyle])},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-input__wrapper",{"is-focus":b.value}])},[o.$slots.prefix?(e.openBlock(),e.createElementBlock("span",A,[e.renderSlot(o.$slots,"prefix")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({class:"cregis-input__inner","onUpdate:modelValue":u[0]||(u[0]=m=>l.value=m),ref_key:"inputRef",ref:s,type:t.type,placeholder:t.placeholder},o.$attrs,{disabled:t.disabled,onInput:z,onChange:V,onFocus:S,onBlur:T}),null,16,F),[[e.vModelDynamic,l.value]]),t.unit&&l.value?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle(v.value),class:"cregis-input__unit"},e.toDisplayString(t.unit),5)):e.createCommentVNode("",!0),o.$slots.suffix||E.value?(e.openBlock(),e.createElementBlock("span",M,[e.renderSlot(o.$slots,"suffix"),E.value?(e.openBlock(),e.createBlock(f,{key:0,class:"cregis-input__clear-button",icon:e.unref($.EdsCloseCircleFill),"icon-type":"square",onClick:N,onMousedown:u[1]||(u[1]=e.withModifiers(()=>{},["prevent"]))},null,8,["icon"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2)],6)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["cregis-textarea",{"is-disabled":t.disabled}]),style:e.normalizeStyle([{width:t.width},t.inputStyle])},[e.withDirectives(e.createElementVNode("textarea",e.mergeProps({class:"cregis-textarea__wrapper"},o.$attrs,{ref_key:"inputRef",ref:s,disabled:t.disabled,placeholder:t.placeholder,rows:t.rows,"onUpdate:modelValue":u[2]||(u[2]=m=>l.value=m),onInput:z,onChange:V,onFocus:S,onBlur:T}),null,16,W),[[e.vModelText,l.value]]),t.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(f,{class:"cregis-textarea__button",link:"",size:"small",onClick:ee},{default:e.withCtx(()=>[...u[3]||(u[3]=[e.createTextVNode(" Paste ",-1)])]),_:1}),e.createVNode(f,{class:"cregis-textarea__button",link:"",size:"small",disabled:!l.value,onClick:N},{default:e.withCtx(()=>[...u[4]||(u[4]=[e.createTextVNode(" Clear ",-1)])]),_:1},8,["disabled"])]))],6))}});g.install=t=>{t.component(g.name,g)},f.install=t=>{t.component(f.name,f)};const q=["width","height"],j={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},O={transform:"translate(-394.000000, -457.000000)"},K={transform:"translate(394.000000, 457.000000)"},Y=["width","height"],Z=e.defineComponent({__name:"checked-basis",props:{size:{default:"16px"}},setup(t){return(n,a)=>(e.openBlock(),e.createElementBlock("svg",{width:t.size,height:t.size,viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createElementVNode("g",j,[e.createElementVNode("g",O,[e.createElementVNode("g",K,[e.createElementVNode("rect",{x:"0",y:"0",width:t.size,height:t.size},null,8,Y),a[0]||(a[0]=e.createElementVNode("path",{d:"M6.67713976,13.5709642 C7.12567714,13.5709642 7.468039,13.3943662 7.70422535,13.0411701 L13.7562297,3.77789816 C13.8407367,3.65005417 13.9024919,3.52546046 13.9414951,3.40411701 C13.9804984,3.28277356 14,3.16468039 14,3.04983749 C14,2.74647887 13.8976165,2.49566631 13.6928494,2.29739978 C13.4880823,2.09913326 13.2307692,2 12.9209101,2 C12.7063922,2 12.5265439,2.04225352 12.3813651,2.12676056 C12.2361863,2.21126761 12.0975081,2.35536295 11.9653304,2.55904659 L6.65113759,10.9512459 L3.95016251,7.60346696 C3.71830986,7.32177681 3.43011918,7.18093174 3.08559047,7.18093174 C2.77139762,7.18093174 2.51191766,7.28169014 2.3071506,7.48320693 C2.10238353,7.68472373 2,7.93824485 2,8.24377031 C2,8.38028169 2.02329361,8.51083424 2.06988082,8.63542795 C2.11646804,8.76002167 2.19826652,8.88949079 2.31527627,9.02383532 L5.67280607,13.0899242 C5.94149512,13.4106176 6.27627302,13.5709642 6.67713976,13.5709642 Z",fill:"currentColor","fill-rule":"nonzero"},null,-1))])])])],8,q))}}),G={key:0,class:"cregis-checkbox--indeterminate"},y=e.defineComponent({name:"Checkbox",__name:"Checkbox",props:{modelValue:{type:[Boolean,Number],default:!1},label:{},disabled:{type:Boolean,default:!1},circle:{type:Boolean},indeterminate:{type:Boolean}},emits:["update:modelValue","change"],setup(t,{emit:n}){const a=t,r=n,i=e.computed(()=>a.modelValue),l=()=>{a.disabled||r("update:modelValue",!i.value)};return e.watch(()=>i.value,()=>{r("change",i.value)}),(s,d)=>(e.openBlock(),e.createElementBlock("div",{class:"cregis-checkbox__wrapper",onClick:l},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-checkbox",{"is-disabled":t.disabled,"is-checked":i.value,"is-circle":t.circle,"is-indeterminate":t.indeterminate}])},[t.indeterminate?(e.openBlock(),e.createElementBlock("div",G)):(e.openBlock(),e.createBlock(Z,{key:1,size:"10px"}))],2),s.$slots.default||t.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-checkbox__label",{"is-disabled":t.disabled}])},[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)])],2)):e.createCommentVNode("",!0)]))}});y.install=t=>{t.component(y.name,y)};const h=e.defineComponent({name:"Radio",__name:"Radio",props:{modelValue:{type:[Boolean,String,Number]},value:{type:[Boolean,String,Number]},label:{},disabled:{type:Boolean}},emits:["update:modelValue","change"],setup(t,{emit:n}){const a=t,r=n,i=e.computed(()=>a.modelValue===a.value),l=()=>{a.disabled||(r("update:modelValue",a.value),r("change",a.value))};return(s,d)=>(e.openBlock(),e.createElementBlock("div",{class:"cregis-radio__wrapper",onClick:l},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-radio",{"is-disabled":t.disabled,"is-checked":i.value}])},[...d[0]||(d[0]=[e.createElementVNode("div",{class:"cregis-radio__inner"},null,-1)])],2),s.$slots.default||t.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-radio__label",{"is-disabled":t.disabled}])},[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)])],2)):e.createCommentVNode("",!0)]))}});h.install=t=>{t.component(h.name,h)};const k=e.defineComponent({name:"Divider",__name:"Divider",props:{direction:{default:"horizontal"},borderStyle:{default:"solid"},lineThickness:{default:"1px"},color:{default:"var(--line-module)"},margin:{default:"8px"},length:{}},setup(t){const n=t,a=e.computed(()=>{if(Array.isArray(n.margin)){const[i,l]=n.margin;return n.direction==="horizontal"?`${i} 0 ${l} 0`:`0 ${l} 0 ${i}`}else return n.direction==="horizontal"?`${n.margin} 0`:`0 ${n.margin}`}),r=e.computed(()=>n.direction==="horizontal"?{width:n.length||"100%",borderTopWidth:n.lineThickness,borderTopStyle:n.borderStyle,borderTopColor:n.color,margin:a.value}:{height:n.length||"1rem",borderLeftWidth:n.lineThickness,borderLeftStyle:n.borderStyle,borderLeftColor:n.color,margin:a.value});return(i,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["cregis-divider",{[`cregis-divider--${t.direction}`]:t.direction}]),style:e.normalizeStyle(r.value)},null,6))}});k.install=t=>{t.component(k.name,k)};const x=Symbol("TABS_KEY"),H=["onClick"],J={style:{display:"none"}},p=e.defineComponent({name:"Tabs",__name:"Tabs",props:{modelValue:{},type:{default:"default"},size:{default:"medium"}},emits:["update:modelValue"],setup(t){const n=t,a=e.reactive([]),r=s=>{a.some(d=>d.name===s.name)||a.push(s)},i=s=>{const d=a.findIndex(b=>b.name===s);d!==-1&&a.splice(d,1)},l=e.computed(()=>n.type==="card"?n.size==="large"?{borderRadius:"13px"}:n.size==="medium"?{borderRadius:"11px"}:{borderRadius:"9px"}:{borderRadius:0});return e.provide(x,{activeName:e.toRef(n,"modelValue"),registerTab:r,unregisterTab:i}),(s,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["cregis-tabs",{[`cregis-tabs--${t.type}`]:t.type,[`cregis-tabs--${t.size}`]:t.size}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,b=>(e.openBlock(),e.createElementBlock("div",{key:b.name,class:e.normalizeClass(["cregis-tabs__item",{"is-active":t.modelValue===b.name}]),style:e.normalizeStyle(l.value),onClick:B=>s.$emit("update:modelValue",b.name)},[e.createElementVNode("span",null,e.toDisplayString(b.label),1)],14,H))),128)),e.createElementVNode("div",J,[e.renderSlot(s.$slots,"default")])],2))}}),C=e.defineComponent({name:"TabPane",__name:"TabPane",props:{label:{},name:{}},setup(t){const n=t,a=e.inject(x);if(!a)throw new Error("TabPane must be used within Tabs");return e.onMounted(()=>{a.registerTab({label:n.label,name:n.name})}),e.watch(()=>n.label,r=>{a.unregisterTab(n.name),a.registerTab({label:r,name:n.name})}),e.onUnmounted(()=>{a.unregisterTab(n.name)}),()=>{}}});p.install=t=>{t.component(p.name,p)},C.install=t=>{t.component(C.name,C)};const Q=[g,f,y,h,k,p,C],w=t=>{Q.forEach(n=>{t.component(n.name,n)})},X={install:w};c.Button=f,c.Checkbox=y,c.Divider=k,c.Input=g,c.Radio=h,c.TabPane=C,c.Tabs=p,c.default=X,c.install=w,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@cregis/icon")):typeof define=="function"&&define.amd?define(["exports","vue","@cregis/icon"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.CregisUI={},d.Vue,d.CregisIcon))})(this,(function(d,e,k){"use strict";const z={key:0,class:"cregis-button__icon-wrapper"},V=["disabled"],S=["disabled"],T=["disabled"],f=e.defineComponent({name:"Button",inheritAttrs:!1,__name:"Button",props:{type:{default:"primary"},size:{default:"medium"},plain:{type:Boolean},text:{type:Boolean},disabled:{type:Boolean},loading:{type:Boolean},block:{type:Boolean},link:{type:Boolean},icon:{},iconType:{default:"rectangle"},iconText:{},affix:{type:Boolean}},setup(t){const l=t,a=e.computed(()=>l.size==="large"?"20px":l.size==="medium"?"16px":"12px"),r=e.computed(()=>l.size==="large"||l.size==="medium"?"16px":"12px"),i=e.computed(()=>{if(l.plain||l.text)switch(l.type){case"primary":return"var(--material-vibrant-brand-primary)";case"secondary":return"var(--material-foreground-base-secondary)";case"danger":return"var(--material-vibrant-error-primary)";case"foreground":return"var(--material-foreground-base-primary)";case"sameWhite":return"var(--material-same-black)"}else return l.type==="secondary"?"var(--material-foreground-base-secondary)":l.type==="foreground"?"var(--text-face-primary)":l.type==="sameWhite"?"var(--text-same-black)":"var(--material-same-white)"});return(n,s)=>t.icon||n.$slots.icon?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("button",e.mergeProps(n.$attrs,{class:["cregis-button__icon",{[`cregis-button__icon--${t.iconType}`]:t.iconType,[`cregis-button__icon--${t.size}`]:t.size,"is-disabled":t.disabled}],disabled:t.disabled||t.loading}),[t.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon),{key:0,size:a.value,"stroke-width":3},null,8,["size"])):e.renderSlot(n.$slots,"icon",{key:1})],16,V),t.iconText?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-button__icon-text",{"is-disabled":t.disabled}])},e.toDisplayString(t.iconText),3)):e.createCommentVNode("",!0)])):t.link?(e.openBlock(),e.createElementBlock("button",e.mergeProps({key:1},n.$attrs,{class:["cregis-button__link",{[`cregis-button__link--${t.type}`]:t.type,[`cregis-button__link--${t.size}`]:t.size,"is-disabled":t.disabled}],disabled:t.disabled||t.loading}),[e.renderSlot(n.$slots,"default")],16,S)):(e.openBlock(),e.createElementBlock("button",e.mergeProps({key:2,ref:"buttonRef"},n.$attrs,{class:["cregis-button",{[`cregis-button--${t.type}`]:t.type,[`cregis-button--${t.size}`]:t.size,"is-plain":t.plain,"is-text":t.text,"is-disabled":t.disabled,"is-loading":t.loading,"is-block":t.block,"is-affix":t.affix}],disabled:t.disabled||t.loading}),[t.loading?(e.openBlock(),e.createBlock(e.unref(k.EdsLoad),{key:0,class:"loading",size:r.value,color:i.value,"stroke-width":3},null,8,["size","color"])):e.renderSlot(n.$slots,"default",{key:1})],16,T))}}),E={key:0,class:"cregis-input__prefix"},N=["type","placeholder","disabled"],R={key:2,class:"cregis-input__suffix"},I=["disabled","placeholder","rows"],D={key:0,class:"cregis-textarea__buttons"},P=e.defineComponent({name:"Input",inheritAttrs:!1,__name:"Input",props:{type:{default:"text"},modelValue:{},size:{default:"medium"},width:{default:"300px"},placeholder:{default:"please input"},disabled:{type:Boolean},clearable:{type:Boolean},inputStyle:{},unit:{},rows:{default:3}},emits:["update:modelValue","input","change","focus","blur","clear"],setup(t,{expose:l,emit:a}){const r=t,i=a,n=e.ref(r.modelValue);e.watch(()=>r.modelValue,o=>{n.value=o});const s=e.ref(),c=e.ref(0),b=e.ref(!1);let g=null;const J=async()=>{await e.nextTick(),s.value?.focus()},h=async()=>{i("update:modelValue",n.value),i("input",n.value),await e.nextTick(),w()},p=()=>{i("change",n.value)},B=o=>{b.value=!0,i("focus",o)},C=o=>{b.value=!1,i("blur",o)},$=e.computed(()=>r.clearable&&!r.disabled&&!!n.value&&b.value),x=()=>{n.value="",i("update:modelValue",""),i("clear"),i("input",""),i("change","")},w=()=>{g&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{if(!s.value||s.value.tagName!=="INPUT")return;const o=s.value,u=o.value,m=document.createElement("span");m.style.position="absolute",m.style.visibility="hidden",m.style.whiteSpace="pre",m.style.font=window.getComputedStyle(o).font,m.style.letterSpacing=window.getComputedStyle(o).letterSpacing,m.textContent=u||" ",document.body.appendChild(m),c.value=m.getBoundingClientRect().width,document.body.removeChild(m)})},Q=e.computed(()=>{const o={};return c.value>0&&(o.position="absolute",o.left=`${c.value+16}px`),o}),X=async()=>{try{n.value=await navigator.clipboard.readText()}catch(o){console.error("paste error:",o)}};return l({focus:J,updateTextWidth:w}),(o,u)=>t.type!=="textarea"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cregis-input",{[`cregis-input--${t.size}`]:t.size,"is-disabled":t.disabled,"is-prefix":o.$slots.prefix,"is-suffix":o.$slots.suffix}]),style:e.normalizeStyle([{width:t.width},t.inputStyle])},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-input__wrapper",{"is-focus":b.value}])},[o.$slots.prefix?(e.openBlock(),e.createElementBlock("span",E,[e.renderSlot(o.$slots,"prefix")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({class:"cregis-input__inner","onUpdate:modelValue":u[0]||(u[0]=m=>n.value=m),ref_key:"inputRef",ref:s,type:t.type,placeholder:t.placeholder},o.$attrs,{disabled:t.disabled,onInput:h,onChange:p,onFocus:B,onBlur:C}),null,16,N),[[e.vModelDynamic,n.value]]),t.unit&&n.value?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle(Q.value),class:"cregis-input__unit"},e.toDisplayString(t.unit),5)):e.createCommentVNode("",!0),o.$slots.suffix||$.value?(e.openBlock(),e.createElementBlock("span",R,[e.renderSlot(o.$slots,"suffix"),$.value?(e.openBlock(),e.createBlock(f,{key:0,class:"cregis-input__clear-button",icon:e.unref(k.EdsCloseCircleFill),"icon-type":"square",onClick:x,onMousedown:u[1]||(u[1]=e.withModifiers(()=>{},["prevent"]))},null,8,["icon"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2)],6)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["cregis-textarea",{"is-disabled":t.disabled}]),style:e.normalizeStyle([{width:t.width},t.inputStyle])},[e.withDirectives(e.createElementVNode("textarea",e.mergeProps({class:"cregis-textarea__wrapper"},o.$attrs,{ref_key:"inputRef",ref:s,disabled:t.disabled,placeholder:t.placeholder,rows:t.rows,"onUpdate:modelValue":u[2]||(u[2]=m=>n.value=m),onInput:h,onChange:p,onFocus:B,onBlur:C}),null,16,I),[[e.vModelText,n.value]]),t.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",D,[e.createVNode(f,{class:"cregis-textarea__button",link:"",size:"small",onClick:X},{default:e.withCtx(()=>[...u[3]||(u[3]=[e.createTextVNode(" Paste ",-1)])]),_:1}),e.createVNode(f,{class:"cregis-textarea__button",link:"",size:"small",disabled:!n.value,onClick:x},{default:e.withCtx(()=>[...u[4]||(u[4]=[e.createTextVNode(" Clear ",-1)])]),_:1},8,["disabled"])]))],6))}}),L=["width","height"],A={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},F={transform:"translate(-394.000000, -457.000000)"},M={transform:"translate(394.000000, 457.000000)"},W=["width","height"],U=e.defineComponent({__name:"checked-basis",props:{size:{default:"16px"}},setup(t){return(l,a)=>(e.openBlock(),e.createElementBlock("svg",{width:t.size,height:t.size,viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createElementVNode("g",A,[e.createElementVNode("g",F,[e.createElementVNode("g",M,[e.createElementVNode("rect",{x:"0",y:"0",width:t.size,height:t.size},null,8,W),a[0]||(a[0]=e.createElementVNode("path",{d:"M6.67713976,13.5709642 C7.12567714,13.5709642 7.468039,13.3943662 7.70422535,13.0411701 L13.7562297,3.77789816 C13.8407367,3.65005417 13.9024919,3.52546046 13.9414951,3.40411701 C13.9804984,3.28277356 14,3.16468039 14,3.04983749 C14,2.74647887 13.8976165,2.49566631 13.6928494,2.29739978 C13.4880823,2.09913326 13.2307692,2 12.9209101,2 C12.7063922,2 12.5265439,2.04225352 12.3813651,2.12676056 C12.2361863,2.21126761 12.0975081,2.35536295 11.9653304,2.55904659 L6.65113759,10.9512459 L3.95016251,7.60346696 C3.71830986,7.32177681 3.43011918,7.18093174 3.08559047,7.18093174 C2.77139762,7.18093174 2.51191766,7.28169014 2.3071506,7.48320693 C2.10238353,7.68472373 2,7.93824485 2,8.24377031 C2,8.38028169 2.02329361,8.51083424 2.06988082,8.63542795 C2.11646804,8.76002167 2.19826652,8.88949079 2.31527627,9.02383532 L5.67280607,13.0899242 C5.94149512,13.4106176 6.27627302,13.5709642 6.67713976,13.5709642 Z",fill:"currentColor","fill-rule":"nonzero"},null,-1))])])])],8,L))}}),q={key:0,class:"cregis-checkbox--indeterminate"},j=e.defineComponent({name:"Checkbox",__name:"Checkbox",props:{modelValue:{type:[Boolean,Number],default:!1},label:{},disabled:{type:Boolean,default:!1},circle:{type:Boolean},indeterminate:{type:Boolean}},emits:["update:modelValue","change"],setup(t,{emit:l}){const a=t,r=l,i=e.computed(()=>a.modelValue),n=()=>{a.disabled||r("update:modelValue",!i.value)};return e.watch(()=>i.value,()=>{r("change",i.value)}),(s,c)=>(e.openBlock(),e.createElementBlock("div",{class:"cregis-checkbox__wrapper",onClick:n},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-checkbox",{"is-disabled":t.disabled,"is-checked":i.value,"is-circle":t.circle,"is-indeterminate":t.indeterminate}])},[t.indeterminate?(e.openBlock(),e.createElementBlock("div",q)):(e.openBlock(),e.createBlock(U,{key:1,size:"10px"}))],2),s.$slots.default||t.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-checkbox__label",{"is-disabled":t.disabled}])},[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)])],2)):e.createCommentVNode("",!0)]))}}),K=e.defineComponent({name:"Radio",__name:"Radio",props:{modelValue:{type:[Boolean,String,Number]},value:{type:[Boolean,String,Number]},label:{},disabled:{type:Boolean}},emits:["update:modelValue","change"],setup(t,{emit:l}){const a=t,r=l,i=e.computed(()=>a.modelValue===a.value),n=()=>{a.disabled||(r("update:modelValue",a.value),r("change",a.value))};return(s,c)=>(e.openBlock(),e.createElementBlock("div",{class:"cregis-radio__wrapper",onClick:n},[e.createElementVNode("div",{class:e.normalizeClass(["cregis-radio",{"is-disabled":t.disabled,"is-checked":i.value}])},[...c[0]||(c[0]=[e.createElementVNode("div",{class:"cregis-radio__inner"},null,-1)])],2),s.$slots.default||t.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["cregis-radio__label",{"is-disabled":t.disabled}])},[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)])],2)):e.createCommentVNode("",!0)]))}}),O=e.defineComponent({name:"Divider",__name:"Divider",props:{direction:{default:"horizontal"},borderStyle:{default:"solid"},lineThickness:{default:"1px"},color:{default:"var(--line-module)"},margin:{default:"8px"},length:{}},setup(t){const l=t,a=e.computed(()=>{if(Array.isArray(l.margin)){const[i,n]=l.margin;return l.direction==="horizontal"?`${i} 0 ${n} 0`:`0 ${n} 0 ${i}`}else return l.direction==="horizontal"?`${l.margin} 0`:`0 ${l.margin}`}),r=e.computed(()=>l.direction==="horizontal"?{width:l.length||"100%",borderTopWidth:l.lineThickness,borderTopStyle:l.borderStyle,borderTopColor:l.color,margin:a.value}:{height:l.length||"1rem",borderLeftWidth:l.lineThickness,borderLeftStyle:l.borderStyle,borderLeftColor:l.color,margin:a.value});return(i,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["cregis-divider",{[`cregis-divider--${t.direction}`]:t.direction}]),style:e.normalizeStyle(r.value)},null,6))}}),y=Symbol("TABS_KEY"),Y=["onClick"],Z={style:{display:"none"}},G=e.defineComponent({name:"Tabs",__name:"Tabs",props:{modelValue:{},type:{default:"default"},size:{default:"medium"}},emits:["update:modelValue"],setup(t){const l=t,a=e.reactive([]),r=s=>{a.some(c=>c.name===s.name)||a.push(s)},i=s=>{const c=a.findIndex(b=>b.name===s);c!==-1&&a.splice(c,1)},n=e.computed(()=>l.type==="card"?l.size==="large"?{borderRadius:"13px"}:l.size==="medium"?{borderRadius:"11px"}:{borderRadius:"9px"}:{borderRadius:0});return e.provide(y,{activeName:e.toRef(l,"modelValue"),registerTab:r,unregisterTab:i}),(s,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["cregis-tabs",{[`cregis-tabs--${t.type}`]:t.type,[`cregis-tabs--${t.size}`]:t.size}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,b=>(e.openBlock(),e.createElementBlock("div",{key:b.name,class:e.normalizeClass(["cregis-tabs__item",{"is-active":t.modelValue===b.name}]),style:e.normalizeStyle(n.value),onClick:g=>s.$emit("update:modelValue",b.name)},[e.createElementVNode("span",null,e.toDisplayString(b.label),1)],14,Y))),128)),e.createElementVNode("div",Z,[e.renderSlot(s.$slots,"default")])],2))}}),H=e.defineComponent({name:"TabPane",__name:"TabPane",props:{label:{},name:{}},setup(t){const l=t,a=e.inject(y);if(!a)throw new Error("TabPane must be used within Tabs");return e.onMounted(()=>{a.registerTab({label:l.label,name:l.name})}),e.watch(()=>l.label,r=>{a.unregisterTab(l.name),a.registerTab({label:r,name:l.name})}),e.onUnmounted(()=>{a.unregisterTab(l.name)}),()=>{}}});d.Button=f,d.Checkbox=j,d.Divider=O,d.Input=P,d.Radio=K,d.TABS_KEY=y,d.TabPane=H,d.Tabs=G,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cregis/ui",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"