@loafacto/ui 0.12.4 → 0.12.5

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,7 +1,7 @@
1
1
  import type { LfOption } from '../types';
2
2
  type __VLS_Props = {
3
- /** 문자열 배열도 받는다 — 값과 표시가 같을 때 `{value,label}` 을 두 번 쓰지 않으려고. */
4
- options?: (LfOption | string)[];
3
+ /** 문자열·숫자 배열도 받는다 — 값과 표시가 같을 때 `{value,label}` 을 두 번 쓰지 않으려고. */
4
+ options?: (LfOption | string | number)[];
5
5
  label?: string;
6
6
  hint?: string;
7
7
  error?: string;
@@ -14,16 +14,21 @@ type __VLS_Props = {
14
14
  size?: 'sm' | 'md';
15
15
  };
16
16
  type __VLS_ModelProps = {
17
- modelValue?: string | number;
17
+ /**
18
+ * `v-model.number` 를 받는다. 컴포넌트의 v-model 에 붙은 수식어는 브라우저가 아니라
19
+ * 컴포넌트가 처리해야 한다 — 그냥 두면 `<LfTextField v-model.number="n">` 이 문자열을
20
+ * 돌려주고, 저장 직전에야 "1" + 1 = "11" 로 드러난다.
21
+ */
22
+ modelValue?: string | number | null;
18
23
  };
19
24
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
20
25
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
- "update:modelValue": (value: string | number) => any;
26
+ "update:modelValue": (value: string | number | null) => any;
22
27
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
23
- "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
28
+ "onUpdate:modelValue"?: ((value: string | number | null) => any) | undefined;
24
29
  }>, {
25
30
  size: "sm" | "md";
26
- options: (LfOption | string)[];
31
+ options: (LfOption | string | number)[];
27
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
33
  declare const _default: typeof __VLS_export;
29
34
  export default _default;
@@ -16,15 +16,22 @@ type __VLS_Props = {
16
16
  clearable?: boolean;
17
17
  /** 비밀번호 보기 토글. `type="password"` 와 함께 쓴다. */
18
18
  revealable?: boolean;
19
+ /** 값 뒤에 붙는 단위. "GB", "ms" 같은 것. */
20
+ suffix?: string;
19
21
  };
20
22
  type __VLS_ModelProps = {
21
- modelValue?: string | number;
23
+ /**
24
+ * `v-model.number` 를 받는다. 컴포넌트의 v-model 에 붙은 수식어는 브라우저가 아니라
25
+ * 컴포넌트가 처리해야 한다 — 그냥 두면 `<LfTextField v-model.number="n">` 이 문자열을
26
+ * 돌려주고, 저장 직전에야 "1" + 1 = "11" 로 드러난다.
27
+ */
28
+ modelValue?: string | number | null;
22
29
  };
23
30
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
24
31
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
- "update:modelValue": (value: string | number) => any;
32
+ "update:modelValue": (value: string | number | null) => any;
26
33
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
27
- "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
34
+ "onUpdate:modelValue"?: ((value: string | number | null) => any) | undefined;
28
35
  }>, {
29
36
  size: "sm" | "md";
30
37
  type: "text" | "password" | "email" | "search" | "url" | "tel" | "number" | "date" | "datetime-local" | "time";
@@ -0,0 +1,9 @@
1
+ export declare function useSplitAttrs(): {
2
+ rootAttrs: import("vue").ComputedRef<{
3
+ class: import("vue").ClassValue;
4
+ style: import("vue").StyleValue;
5
+ }>;
6
+ controlAttrs: import("vue").ComputedRef<{
7
+ [x: string]: unknown;
8
+ }>;
9
+ };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readonly, ref, openBlock, createElementBlock, createStaticVNode, createElementVNode, defineComponent, computed, watch, onBeforeUnmount, normalizeClass, normalizeStyle, createCommentVNode, Fragment, toDisplayString, createVNode, renderList, renderSlot, unref, onUnmounted, createBlock, Teleport, TransitionGroup, withCtx, withModifiers, Transition, useTemplateRef, onMounted, nextTick, createTextVNode, withDirectives, withKeys, vModelText, resolveDynamicComponent, useModel, useId, mergeProps, vModelDynamic, mergeModels, vModelSelect, vModelCheckbox, vModelRadio, useSlots } from "vue";
1
+ import { readonly, ref, openBlock, createElementBlock, createStaticVNode, createElementVNode, defineComponent, computed, watch, onBeforeUnmount, normalizeClass, normalizeStyle, createCommentVNode, Fragment, toDisplayString, createVNode, renderList, renderSlot, unref, onUnmounted, createBlock, Teleport, TransitionGroup, withCtx, withModifiers, Transition, useTemplateRef, onMounted, nextTick, createTextVNode, withDirectives, withKeys, vModelText, resolveDynamicComponent, useAttrs, useModel, useId, mergeProps, isRef, vModelDynamic, mergeModels, vModelSelect, vModelCheckbox, vModelRadio, useSlots } from "vue";
2
2
  import { a as applyTheme, D as DARK_THEME, L as LIGHT_THEME } from "./applyTheme-8AxcQbPB.js";
3
3
  import { b, c, d, e, f, h, i, l } from "./applyTheme-8AxcQbPB.js";
4
4
  import { defineStore } from "pinia";
@@ -203,7 +203,7 @@ const _hoisted_1$s = { class: "lf-topbar" };
203
203
  const _hoisted_2$o = { class: "lf-topbar__inner" };
204
204
  const _hoisted_3$j = ["aria-label", "title", "aria-expanded"];
205
205
  const _hoisted_4$h = ["href", "aria-label"];
206
- const _hoisted_5$d = ["src"];
206
+ const _hoisted_5$e = ["src"];
207
207
  const _hoisted_6$a = { class: "lf-brand__name" };
208
208
  const _hoisted_7$8 = ["aria-expanded"];
209
209
  const _hoisted_8$3 = {
@@ -417,7 +417,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
417
417
  src: __props.logoUrl,
418
418
  alt: "",
419
419
  class: "lf-brand__logo"
420
- }, null, 8, _hoisted_5$d),
420
+ }, null, 8, _hoisted_5$e),
421
421
  createElementVNode("span", _hoisted_6$a, toDisplayString(__props.brandName), 1)
422
422
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
423
423
  createVNode(BrandLockup, { class: "lf-brand__lockup" }),
@@ -637,7 +637,7 @@ const _hoisted_3$i = {
637
637
  "aria-hidden": "true"
638
638
  };
639
639
  const _hoisted_4$g = ["d"];
640
- const _hoisted_5$c = { class: "toast-message" };
640
+ const _hoisted_5$d = { class: "toast-message" };
641
641
  const _hoisted_6$9 = ["onClick"];
642
642
  const _hoisted_7$7 = {
643
643
  viewBox: "0 0 24 24",
@@ -692,7 +692,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
692
692
  fill: "currentColor"
693
693
  }, null, 8, _hoisted_4$g)
694
694
  ])),
695
- createElementVNode("span", _hoisted_5$c, toDisplayString(item.message), 1),
695
+ createElementVNode("span", _hoisted_5$d, toDisplayString(item.message), 1),
696
696
  createElementVNode("button", {
697
697
  type: "button",
698
698
  class: "toast-close",
@@ -823,7 +823,7 @@ const _hoisted_2$m = {
823
823
  };
824
824
  const _hoisted_3$h = { class: "app-confirm__header" };
825
825
  const _hoisted_4$f = { class: "app-confirm__title" };
826
- const _hoisted_5$b = { class: "app-confirm__body" };
826
+ const _hoisted_5$c = { class: "app-confirm__body" };
827
827
  const _hoisted_6$8 = { class: "app-confirm__message" };
828
828
  const _hoisted_7$6 = {
829
829
  key: 0,
@@ -862,7 +862,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
862
862
  createElementVNode("div", _hoisted_3$h, [
863
863
  createElementVNode("h3", _hoisted_4$f, toDisplayString(unref(store).title), 1)
864
864
  ]),
865
- createElementVNode("div", _hoisted_5$b, [
865
+ createElementVNode("div", _hoisted_5$c, [
866
866
  createElementVNode("p", _hoisted_6$8, toDisplayString(unref(store).message), 1),
867
867
  unref(store).requireText ? (openBlock(), createElementBlock("label", _hoisted_7$6, [
868
868
  createElementVNode("span", _hoisted_8$1, [
@@ -1165,13 +1165,26 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
1165
1165
  }
1166
1166
  });
1167
1167
  const LfField = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__scopeId", "data-v-38509e4d"]]);
1168
+ function useSplitAttrs() {
1169
+ const attrs = useAttrs();
1170
+ const rootAttrs = computed(() => ({ class: attrs.class, style: attrs.style }));
1171
+ const controlAttrs = computed(() => {
1172
+ const { class: _class, style: _style, ...rest } = attrs;
1173
+ return rest;
1174
+ });
1175
+ return { rootAttrs, controlAttrs };
1176
+ }
1168
1177
  const _hoisted_1$k = { class: "lf-control-wrap" };
1169
1178
  const _hoisted_2$j = {
1170
1179
  key: 0,
1171
1180
  class: "lf-control-wrap__icon lf-control-wrap__icon--left"
1172
1181
  };
1173
1182
  const _hoisted_3$e = ["id", "type", "placeholder", "disabled", "readonly", "required", "aria-invalid"];
1174
- const _hoisted_4$d = ["aria-label"];
1183
+ const _hoisted_4$d = {
1184
+ key: 1,
1185
+ class: "lf-control-wrap__suffix"
1186
+ };
1187
+ const _hoisted_5$b = ["aria-label"];
1175
1188
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
1176
1189
  ...{ inheritAttrs: false },
1177
1190
  __name: "LfTextField",
@@ -1188,15 +1201,25 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1188
1201
  icon: {},
1189
1202
  iconPath: {},
1190
1203
  clearable: { type: Boolean },
1191
- revealable: { type: Boolean }
1204
+ revealable: { type: Boolean },
1205
+ suffix: {}
1192
1206
  }, {
1193
- "modelValue": { default: "" },
1207
+ "modelValue": {
1208
+ default: ""
1209
+ },
1194
1210
  "modelModifiers": {}
1195
1211
  }),
1196
1212
  emits: ["update:modelValue"],
1197
1213
  setup(__props) {
1198
1214
  const props = __props;
1199
- const model = useModel(__props, "modelValue");
1215
+ const [model, modifiers] = useModel(__props, "modelValue", {
1216
+ set(value) {
1217
+ if (!modifiers.number || value === "" || typeof value === "number") return value;
1218
+ const n = parseFloat(String(value));
1219
+ return Number.isNaN(n) ? value : n;
1220
+ }
1221
+ });
1222
+ const { rootAttrs, controlAttrs } = useSplitAttrs();
1200
1223
  const inputId = useId();
1201
1224
  const revealed = ref(false);
1202
1225
  const hasTrailing = computed(
@@ -1206,13 +1229,13 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1206
1229
  model.value = typeof model.value === "number" ? 0 : "";
1207
1230
  }
1208
1231
  return (_ctx, _cache) => {
1209
- return openBlock(), createBlock(LfField, {
1232
+ return openBlock(), createBlock(LfField, mergeProps(unref(rootAttrs), {
1210
1233
  label: __props.label,
1211
1234
  hint: __props.hint,
1212
1235
  error: __props.error,
1213
1236
  required: __props.required,
1214
1237
  "html-for": unref(inputId)
1215
- }, {
1238
+ }), {
1216
1239
  default: withCtx(() => [
1217
1240
  createElementVNode("div", _hoisted_1$k, [
1218
1241
  __props.icon || __props.iconPath ? (openBlock(), createElementBlock("span", _hoisted_2$j, [
@@ -1222,12 +1245,13 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1222
1245
  size: "1.125rem"
1223
1246
  }, null, 8, ["name", "path"])
1224
1247
  ])) : createCommentVNode("", true),
1225
- withDirectives(createElementVNode("input", mergeProps({ id: unref(inputId) }, _ctx.$attrs, {
1226
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
1248
+ withDirectives(createElementVNode("input", mergeProps({ id: unref(inputId) }, unref(controlAttrs), {
1249
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
1227
1250
  class: ["lf-control", [
1228
1251
  { "lf-control--sm": __props.size === "sm", "lf-control--error": !!__props.error },
1229
1252
  (__props.icon || __props.iconPath) && "lf-control--has-left",
1230
- hasTrailing.value && "lf-control--has-right"
1253
+ hasTrailing.value && "lf-control--has-right",
1254
+ __props.suffix && "lf-control--has-suffix"
1231
1255
  ]],
1232
1256
  type: revealed.value ? "text" : __props.type,
1233
1257
  placeholder: __props.placeholder,
@@ -1236,10 +1260,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1236
1260
  required: __props.required,
1237
1261
  "aria-invalid": __props.error ? "true" : void 0
1238
1262
  }), null, 16, _hoisted_3$e), [
1239
- [vModelDynamic, model.value]
1263
+ [vModelDynamic, unref(model)]
1240
1264
  ]),
1265
+ __props.suffix ? (openBlock(), createElementBlock("span", _hoisted_4$d, toDisplayString(__props.suffix), 1)) : createCommentVNode("", true),
1241
1266
  __props.revealable ? (openBlock(), createElementBlock("button", {
1242
- key: 1,
1267
+ key: 2,
1243
1268
  type: "button",
1244
1269
  class: "lf-control-action",
1245
1270
  "aria-label": revealed.value ? "비밀번호 가리기" : "비밀번호 보기",
@@ -1249,8 +1274,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1249
1274
  name: revealed.value ? "visibility_off" : "visibility",
1250
1275
  size: "1.125rem"
1251
1276
  }, null, 8, ["name"])
1252
- ], 8, _hoisted_4$d)) : __props.clearable && !!model.value && !__props.disabled && !__props.readonly ? (openBlock(), createElementBlock("button", {
1253
- key: 2,
1277
+ ], 8, _hoisted_5$b)) : __props.clearable && !!unref(model) && !__props.disabled && !__props.readonly ? (openBlock(), createElementBlock("button", {
1278
+ key: 3,
1254
1279
  type: "button",
1255
1280
  class: "lf-control-action",
1256
1281
  "aria-label": "지우기",
@@ -1264,11 +1289,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1264
1289
  ])
1265
1290
  ]),
1266
1291
  _: 1
1267
- }, 8, ["label", "hint", "error", "required", "html-for"]);
1292
+ }, 16, ["label", "hint", "error", "required", "html-for"]);
1268
1293
  };
1269
1294
  }
1270
1295
  });
1271
- const LfTextField = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-e1ad8511"]]);
1296
+ const LfTextField = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-e113043f"]]);
1272
1297
  const _hoisted_1$j = ["id", "rows", "placeholder", "disabled", "readonly", "required", "maxlength", "aria-invalid"];
1273
1298
  const _hoisted_2$i = {
1274
1299
  key: 0,
@@ -1299,6 +1324,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
1299
1324
  setup(__props) {
1300
1325
  const props = __props;
1301
1326
  const model = useModel(__props, "modelValue");
1327
+ const { rootAttrs, controlAttrs } = useSplitAttrs();
1302
1328
  const inputId = useId();
1303
1329
  const el = useTemplateRef("el");
1304
1330
  function grow() {
@@ -1314,19 +1340,19 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
1314
1340
  if (props.autoGrow) void nextTick(grow);
1315
1341
  });
1316
1342
  return (_ctx, _cache) => {
1317
- return openBlock(), createBlock(LfField, {
1343
+ return openBlock(), createBlock(LfField, mergeProps(unref(rootAttrs), {
1318
1344
  label: __props.label,
1319
1345
  hint: __props.hint,
1320
1346
  error: __props.error,
1321
1347
  required: __props.required,
1322
1348
  "html-for": unref(inputId)
1323
- }, {
1349
+ }), {
1324
1350
  default: withCtx(() => [
1325
1351
  withDirectives(createElementVNode("textarea", mergeProps({
1326
1352
  id: unref(inputId),
1327
1353
  ref_key: "el",
1328
1354
  ref: el
1329
- }, _ctx.$attrs, {
1355
+ }, unref(controlAttrs), {
1330
1356
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
1331
1357
  class: ["lf-control lf-textarea", { "lf-control--sm": __props.size === "sm", "lf-control--error": !!__props.error, "lf-textarea--fixed": !__props.resize }],
1332
1358
  rows: __props.rows,
@@ -1343,11 +1369,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
1343
1369
  __props.maxlength && __props.counter ? (openBlock(), createElementBlock("p", _hoisted_2$i, toDisplayString(String(model.value ?? "").length) + " / " + toDisplayString(__props.maxlength), 1)) : createCommentVNode("", true)
1344
1370
  ]),
1345
1371
  _: 1
1346
- }, 8, ["label", "hint", "error", "required", "html-for"]);
1372
+ }, 16, ["label", "hint", "error", "required", "html-for"]);
1347
1373
  };
1348
1374
  }
1349
1375
  });
1350
- const LfTextarea = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-96f0aac7"]]);
1376
+ const LfTextarea = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-81fbed25"]]);
1351
1377
  const _hoisted_1$i = { class: "lf-control-wrap" };
1352
1378
  const _hoisted_2$h = ["id", "disabled", "required", "aria-invalid"];
1353
1379
  const _hoisted_3$d = ["disabled"];
@@ -1367,29 +1393,38 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
1367
1393
  disabled: { type: Boolean },
1368
1394
  size: { default: "md" }
1369
1395
  }, {
1370
- "modelValue": { default: "" },
1396
+ "modelValue": {
1397
+ default: ""
1398
+ },
1371
1399
  "modelModifiers": {}
1372
1400
  }),
1373
1401
  emits: ["update:modelValue"],
1374
1402
  setup(__props) {
1375
1403
  const props = __props;
1376
- const model = useModel(__props, "modelValue");
1404
+ const [model, modifiers] = useModel(__props, "modelValue", {
1405
+ set(value) {
1406
+ if (!modifiers.number || value === "" || typeof value === "number") return value;
1407
+ const n = parseFloat(String(value));
1408
+ return Number.isNaN(n) ? value : n;
1409
+ }
1410
+ });
1411
+ const { rootAttrs, controlAttrs } = useSplitAttrs();
1377
1412
  const inputId = useId();
1378
1413
  const normalized = computed(
1379
- () => props.options.map((o) => typeof o === "string" ? { value: o, label: o } : o)
1414
+ () => props.options.map((o) => typeof o === "string" || typeof o === "number" ? { value: o, label: String(o) } : o)
1380
1415
  );
1381
1416
  return (_ctx, _cache) => {
1382
- return openBlock(), createBlock(LfField, {
1417
+ return openBlock(), createBlock(LfField, mergeProps(unref(rootAttrs), {
1383
1418
  label: __props.label,
1384
1419
  hint: __props.hint,
1385
1420
  error: __props.error,
1386
1421
  required: __props.required,
1387
1422
  "html-for": unref(inputId)
1388
- }, {
1423
+ }), {
1389
1424
  default: withCtx(() => [
1390
1425
  createElementVNode("div", _hoisted_1$i, [
1391
- withDirectives(createElementVNode("select", mergeProps({ id: unref(inputId) }, _ctx.$attrs, {
1392
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
1426
+ withDirectives(createElementVNode("select", mergeProps({ id: unref(inputId) }, unref(controlAttrs), {
1427
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
1393
1428
  class: ["lf-control lf-select lf-control--has-right", { "lf-control--sm": __props.size === "sm", "lf-control--error": !!__props.error }],
1394
1429
  disabled: __props.disabled,
1395
1430
  required: __props.required,
@@ -1408,7 +1443,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
1408
1443
  }, toDisplayString(opt.label), 9, _hoisted_4$c);
1409
1444
  }), 128))
1410
1445
  ], 16, _hoisted_2$h), [
1411
- [vModelSelect, model.value]
1446
+ [vModelSelect, unref(model)]
1412
1447
  ]),
1413
1448
  createElementVNode("span", _hoisted_5$a, [
1414
1449
  createVNode(LfIcon, {
@@ -1419,11 +1454,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
1419
1454
  ])
1420
1455
  ]),
1421
1456
  _: 1
1422
- }, 8, ["label", "hint", "error", "required", "html-for"]);
1457
+ }, 16, ["label", "hint", "error", "required", "html-for"]);
1423
1458
  };
1424
1459
  }
1425
1460
  });
1426
- const LfSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-78276920"]]);
1461
+ const LfSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-e0d9d182"]]);
1427
1462
  const _hoisted_1$h = ["disabled", "value"];
1428
1463
  const _hoisted_2$g = {
1429
1464
  class: "lf-check__box",