nuxt-hs-ui 2.12.7 → 4.0.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.
Files changed (131) hide show
  1. package/README.md +202 -14
  2. package/dist/module.d.mts +3 -4
  3. package/dist/module.json +9 -6
  4. package/dist/module.mjs +109 -99
  5. package/dist/runtime/assets/flatpickr-dark.css +1 -1
  6. package/dist/runtime/assets/main.css +1 -0
  7. package/dist/runtime/assets/tabulator-custom.css +1 -1
  8. package/dist/runtime/components/form/_select/hidden-item-toggle.vue +28 -0
  9. package/dist/runtime/components/form/_select/hidden-item-toggle.vue.d.ts +10 -0
  10. package/dist/runtime/components/form/_select/item-container.vue +63 -0
  11. package/dist/runtime/components/form/_select/item-container.vue.d.ts +19 -0
  12. package/dist/runtime/components/form/_select/item-label.vue +31 -0
  13. package/dist/runtime/components/form/_select/item-label.vue.d.ts +13 -0
  14. package/dist/runtime/components/form/_select/item-row.vue +62 -0
  15. package/dist/runtime/components/form/_select/item-row.vue.d.ts +34 -0
  16. package/dist/runtime/components/form/btn-line-loading.vue +62 -81
  17. package/dist/runtime/components/form/btn-line-loading.vue.d.ts +14 -0
  18. package/dist/runtime/components/form/btn.vue +411 -494
  19. package/dist/runtime/components/form/btn.vue.d.ts +0 -0
  20. package/dist/runtime/components/form/check-box.vue +200 -315
  21. package/dist/runtime/components/form/check-box.vue.d.ts +71 -0
  22. package/dist/runtime/components/form/check-list.vue +234 -364
  23. package/dist/runtime/components/form/check-list.vue.d.ts +99 -0
  24. package/dist/runtime/components/form/combo-box.vue +340 -0
  25. package/dist/runtime/components/form/combo-box.vue.d.ts +69 -0
  26. package/dist/runtime/components/form/datepicker.vue +717 -883
  27. package/dist/runtime/components/form/datepicker.vue.d.ts +122 -0
  28. package/dist/runtime/components/form/input-frame.vue +174 -258
  29. package/dist/runtime/components/form/input-frame.vue.d.ts +88 -0
  30. package/dist/runtime/components/form/radio.vue +451 -614
  31. package/dist/runtime/components/form/radio.vue.d.ts +62 -0
  32. package/dist/runtime/components/form/select-img-icon.vue +38 -53
  33. package/dist/runtime/components/form/select-img-icon.vue.d.ts +15 -0
  34. package/dist/runtime/components/form/select.vue +733 -579
  35. package/dist/runtime/components/form/select.vue.d.ts +63 -0
  36. package/dist/runtime/components/form/text-box.vue +266 -365
  37. package/dist/runtime/components/form/text-box.vue.d.ts +105 -0
  38. package/dist/runtime/components/form/textarea.vue +338 -421
  39. package/dist/runtime/components/form/textarea.vue.d.ts +98 -0
  40. package/dist/runtime/components/form/value-box.vue +512 -641
  41. package/dist/runtime/components/form/value-box.vue.d.ts +128 -0
  42. package/dist/runtime/components/interactive/alert.vue +49 -113
  43. package/dist/runtime/components/interactive/alert.vue.d.ts +30 -0
  44. package/dist/runtime/components/interactive/block-loading.vue +91 -119
  45. package/dist/runtime/components/interactive/block-loading.vue.d.ts +22 -0
  46. package/dist/runtime/components/interactive/dialog.vue +252 -407
  47. package/dist/runtime/components/interactive/dialog.vue.d.ts +3 -0
  48. package/dist/runtime/components/interactive/modal-bg.vue +72 -82
  49. package/dist/runtime/components/interactive/modal-bg.vue.d.ts +11 -0
  50. package/dist/runtime/components/interactive/modal.vue +121 -169
  51. package/dist/runtime/components/interactive/modal.vue.d.ts +38 -0
  52. package/dist/runtime/components/interactive/toast.vue +164 -206
  53. package/dist/runtime/components/interactive/toast.vue.d.ts +3 -0
  54. package/dist/runtime/components/interactive/window-loader.vue +61 -84
  55. package/dist/runtime/components/interactive/window-loader.vue.d.ts +3 -0
  56. package/dist/runtime/components/layout/accordion-down.vue +72 -0
  57. package/dist/runtime/components/layout/accordion-down.vue.d.ts +26 -0
  58. package/dist/runtime/components/layout/accordion.vue +47 -78
  59. package/dist/runtime/components/layout/accordion.vue.d.ts +22 -0
  60. package/dist/runtime/components/layout/aspect-box.vue +29 -58
  61. package/dist/runtime/components/layout/aspect-box.vue.d.ts +29 -0
  62. package/dist/runtime/components/layout/card-item.vue +148 -193
  63. package/dist/runtime/components/layout/card-item.vue.d.ts +0 -0
  64. package/dist/runtime/components/layout/card.vue +27 -42
  65. package/dist/runtime/components/layout/card.vue.d.ts +23 -0
  66. package/dist/runtime/components/layout/container.vue +25 -40
  67. package/dist/runtime/components/layout/container.vue.d.ts +35 -0
  68. package/dist/runtime/components/layout/divider-h.vue +30 -50
  69. package/dist/runtime/components/layout/divider-h.vue.d.ts +18 -0
  70. package/dist/runtime/components/misc/breadcrumb.vue +47 -95
  71. package/dist/runtime/components/misc/breadcrumb.vue.d.ts +22 -0
  72. package/dist/runtime/components/misc/tabulator.vue +122 -190
  73. package/dist/runtime/components/misc/tabulator.vue.d.ts +28 -0
  74. package/dist/runtime/components/misc/view-name-display.vue +53 -68
  75. package/dist/runtime/components/misc/view-name-display.vue.d.ts +14 -0
  76. package/dist/runtime/components/test.vue +13 -0
  77. package/dist/runtime/components/test.vue.d.ts +3 -0
  78. package/dist/runtime/composables/test.d.ts +8 -0
  79. package/dist/runtime/composables/test.js +12 -0
  80. package/dist/runtime/composables/use-hs-dialog.d.ts +3 -20
  81. package/dist/runtime/composables/use-hs-dialog.js +3 -9
  82. package/dist/runtime/composables/use-hs-is-mobile.d.ts +8 -2
  83. package/dist/runtime/composables/use-hs-is-mobile.js +43 -25
  84. package/dist/runtime/composables/use-hs-misc.d.ts +8 -38
  85. package/dist/runtime/composables/use-hs-misc.js +9 -61
  86. package/dist/runtime/composables/use-hs-modal.js +1 -3
  87. package/dist/runtime/composables/use-hs-multi-lang.d.ts +23 -40
  88. package/dist/runtime/composables/use-hs-multi-lang.js +30 -74
  89. package/dist/runtime/composables/use-hs-scroll-lock.d.ts +1 -1
  90. package/dist/runtime/composables/use-hs-scroll-lock.js +2 -1
  91. package/dist/runtime/composables/use-hs-toast.d.ts +2 -2
  92. package/dist/runtime/composables/use-hs-toast.js +12 -4
  93. package/dist/runtime/composables/use-pinia.d.ts +1 -0
  94. package/dist/runtime/composables/use-pinia.js +2 -0
  95. package/dist/runtime/plugin.d.ts +2 -0
  96. package/dist/runtime/plugin.js +4 -0
  97. package/dist/runtime/server/tsconfig.json +3 -3
  98. package/dist/runtime/types/dialog.d.ts +11 -20
  99. package/dist/runtime/types/dialog.js +2 -1
  100. package/dist/runtime/types/flatpickr/default.js +2 -23
  101. package/dist/runtime/types/flatpickr/ja.js +3 -37
  102. package/dist/runtime/types/toast.d.ts +1 -1
  103. package/dist/runtime/utils/dayjs.d.ts +8 -6
  104. package/dist/runtime/utils/dayjs.js +12 -5
  105. package/dist/runtime/utils/modal.d.ts +9 -28
  106. package/dist/runtime/utils/modal.js +7 -36
  107. package/dist/runtime/utils/multi-lang-object.d.ts +2 -2
  108. package/dist/runtime/utils/multi-lang-object.js +1 -5
  109. package/dist/runtime/utils/multi-lang.js +12 -22
  110. package/dist/runtime/utils/object.js +1 -1
  111. package/dist/runtime/utils/select-item.d.ts +3 -1
  112. package/dist/runtime/utils/stop-watch.js +6 -4
  113. package/dist/runtime/utils/string.js +4 -4
  114. package/dist/runtime/utils/tabulator.d.ts +1 -42
  115. package/dist/runtime/utils/tabulator.js +2 -99
  116. package/dist/runtime/utils/theme.d.ts +20 -20
  117. package/dist/runtime/utils/theme.js +180 -30
  118. package/dist/runtime/utils/tv.d.ts +1 -101
  119. package/dist/runtime/utils/tv.js +0 -22
  120. package/dist/types.d.mts +3 -1
  121. package/package.json +61 -119
  122. package/dist/module.cjs +0 -5
  123. package/dist/module.d.ts +0 -16
  124. package/dist/runtime/assets/vue-select.css +0 -1
  125. package/dist/runtime/components/misc/view-name-display-target.vue +0 -39
  126. package/dist/runtime/plugin/v-select.d.ts +0 -2
  127. package/dist/runtime/plugin/v-select.js +0 -5
  128. package/dist/runtime/style.css +0 -22
  129. package/dist/runtime/tailwind.css +0 -78
  130. package/dist/runtime/types/app.config.d.ts +0 -5
  131. package/dist/types.d.ts +0 -1
@@ -1,367 +1,268 @@
1
- <script setup lang="ts">
2
- /* ----------------------------------------------------------------------------
3
- // src\runtime\components\form\text-box.vue
4
- // ----------------------------------------------------------------------------
5
- // TextBox
6
- // TextBoxTextBox
7
- ----------------------------------------------------------------------------- */
8
-
9
- // [ tailwind ]
10
- import { twMerge } from "tailwind-merge";
11
-
12
- // [ NUXT ]
13
- import { reactive, ref, watch, computed, nextTick, useId } from "#imports";
14
-
15
- // [ utils ]
16
- import type { ClassType } from "../../utils/class-style";
17
- import type { MultiLang } from "../../utils/multi-lang";
18
- // [ composables ]
19
- import { useHsFocus } from "../../composables/use-hs-focus";
20
- // [ Components ]
21
- import InputFrame from "./input-frame.vue";
22
- // ----------------------------------------------------------------------------
23
- const fcFocus = useHsFocus();
24
- // ----------------------------------------------------------------------------
25
- // [ Props ]
26
- type Props = {
27
- // ----------------------------------------------------------------------------
28
- // Input 種類別
29
- type?: "email" | "number" | "password" | "tel" | "text" | "url";
30
- textAlign?: "left" | "center" | "right";
31
- maxLen?: number;
32
- autocomplete?: string;
33
- datalist?: string[];
34
- enterkeyhint?: string;
35
- inputmode?:
36
- | "text"
37
- | "search"
38
- | "none"
39
- | "tel"
40
- | "url"
41
- | "email"
42
- | "numeric"
43
- | "decimal"
44
- | undefined;
45
- // ----------------------------------------------------------------------------
46
- data: string | null;
47
- diff?: string | null | undefined;
48
- tabindex?: string | undefined;
49
- // ----------------------------------------------------------------------------
50
- class?: ClassType;
51
- classHeader?: ClassType;
52
- classInput?: ClassType;
53
- // ----------------------------------------------------------------------------
54
- // 状態
55
- // focus?: boolean;
56
- focusColor?: string;
57
- // change?: boolean;
58
- changeColor?: string;
59
- error?: boolean;
60
- errorColor?: string;
61
- disabled?: boolean;
62
- disabledColor?: string;
63
- readonly?: boolean;
64
- headerless?: boolean;
65
- // ----------------------------------------------------------------------------
66
- // 表示
67
- label?: MultiLang;
68
- // 表示-副情報
69
- require?: boolean;
70
- requireText?: MultiLang;
71
- warn?: string;
72
- warnTimeOut?: number;
73
- // ----------------------------------------------------------------------------
74
- // 設定
75
- size?: "s" | "m" | "l";
76
- };
77
- const props = withDefaults(defineProps<Props>(), {
78
- // ----------------------------------------------------------------------------
79
- // Input 種類別
80
- type: "text",
81
- textAlign: "left",
82
- maxLen: 0,
83
- autocomplete: "off",
84
- datalist: () => [],
85
- enterkeyhint: undefined,
86
- inputmode: undefined,
87
- // ----------------------------------------------------------------------------
88
- diff: undefined,
89
- tabindex: undefined,
90
- // ----------------------------------------------------------------------------
91
- class: "",
92
- classHeader: "",
93
- classInput: "",
94
- // ----------------------------------------------------------------------------
95
- // 状態
96
- // focus: false,
97
- focusColor: "shadow-[inset_0px_0px_1px_2px_#0d8ee4]",
98
- // change: false,
99
- changeColor: "shadow-[inset_0px_0px_1px_2px_#fd9831be]",
100
- error: false,
101
- errorColor: "shadow-[inset_0px_0px_1px_2px_#d80000dc]",
102
- disabled: false,
103
- disabledColor: "",
104
- readonly: false,
105
- headerless: false,
106
- // ----------------------------------------------------------------------------
107
- // 表示
108
- label: "",
109
- // 表示-副情報
110
- require: false,
111
- requireText: () => ({ ja: "必須", en: "Required" }),
112
- warn: "",
113
- warnTimeOut: 3000,
114
- // ----------------------------------------------------------------------------
115
- // 設定
116
- size: "m",
117
- });
118
- // ----------------------------------------------------------------------------
119
- // [ emit ]
120
- type Emits = {
121
- ref: [element: HTMLElement];
122
- focus: [elm: HTMLElement];
123
- blur: [elm: HTMLElement];
124
- // ----------------------------
125
- "update:data": [value: string];
126
- "value-change": [after: string, before: string | null];
127
- // ----------------------------
128
- keydown: [event: KeyboardEvent];
129
- keyup: [event: KeyboardEvent];
130
- // ----------------------------
131
- };
132
- const emit = defineEmits<Emits>();
133
- // ----------------------------------------------------------------------------
134
- const slots = defineSlots<{
135
- default(props: { msg: string }): any;
136
- overlay?(): any;
137
- "right-icons"?(): any;
138
- "left-icons"?(): any;
139
- }>();
140
- // ----------------------------------------------------------------------------
141
- // [ getCurrentInstance ]
142
- const uid = useId();
143
- // ----------------------------------------------------------------------------
144
-
145
- // [ reactive ]
146
- interface State {
147
- value: string;
148
- }
149
- const state = reactive<State>({
150
- value: "",
151
- });
152
- // ----------------------------------------------------------------------------
153
- watch(
154
- () => props.data,
155
- () => {
156
- setValue(props.data);
157
- }
158
- );
159
-
160
- // 更新を親コンポーネントに伝える
161
- const updateValue = async (text: string | null) => {
162
- const before = props.data;
163
- let setText = "";
164
- if (text === null) {
165
- setText = "";
166
- } else if (props.maxLen === 0 || text.length <= props.maxLen) {
167
- setText = text;
168
- } else {
169
- const CutLen = (text: string, len: number, addWard = "") => {
170
- if (text === null) return "";
171
- if (len === 0) return text;
172
- return text.substring(0, len) + addWard;
173
- };
174
- setText = CutLen(text, props.maxLen, "");
175
- }
176
- state.value = setText;
177
- emit("update:data", setText);
178
- await nextTick();
179
- emit("value-change", setText, before);
180
- };
181
-
182
- const setValue = (text: string | null) => {
183
- // console.log({ text });
184
- if (text === null) {
185
- state.value = "";
186
- return;
187
- }
188
- if (props.maxLen === 0 || text.length <= props.maxLen) {
189
- state.value = text;
190
- } else {
191
- // 文字数のオーバーフロー確定
192
- // 親コンポーネントへの更新処理に移動
193
- updateValue(text);
194
- }
195
- };
196
- setValue(props.data);
197
-
198
- // [ ref ]
199
- const inputElement = ref();
200
- const setRef = (elm: any) => {
201
- inputElement.value = elm;
202
- emit("ref", elm);
203
- };
204
-
205
- /**
206
- * 強制focus
207
- */
208
- const elmFocus = () => {
209
- if (props.disabled === true) return;
210
- if (props.readonly === true) return;
211
- inputElement.value.focus();
212
- };
213
-
214
- // [ focus, blur ]
215
- interface FocusState {
216
- isActivate: boolean;
217
- isMmousedown: boolean;
218
- }
219
-
220
- const focusState = reactive<FocusState>({
221
- isActivate: false,
222
- isMmousedown: false,
223
- });
224
-
225
- /**
226
- * コントロールのFocus判定
227
- */
228
- const computedActivate = computed(() => {
229
- if (props.disabled === true) return false;
230
- if (props.readonly === true) return false;
231
- if (fcFocus.state.id !== uid) return false;
232
- if (focusState.isActivate) return true;
233
- if (focusState.isMmousedown) return true;
234
- return false;
235
- });
236
-
237
- /**
238
- * focus, blur イベント
239
- */
240
- watch(computedActivate, (value) => {
241
- if (value === true) {
242
- setTimeout(() => {
243
- emit("focus", inputElement.value);
244
- }, 10);
245
- } else {
246
- emit("blur", inputElement.value);
247
- }
248
- });
249
-
250
- const onFocus = () => {
251
- if (props.disabled === true) return;
252
- if (props.readonly === true) return;
253
- focusState.isActivate = true;
254
- fcFocus.state.id = uid;
255
- };
256
- const onBlur = () => {
257
- focusState.isActivate = false;
258
- };
259
- // ----------------------------------------------------------------------------
260
- // 更新の有無判定
261
- const isChangeData = computed(() => {
262
- if (props.diff === undefined) return false;
263
- if (props.diff === null && props.data === "") return false;
264
- if (props.diff === "" && props.data === null) return false;
265
- if (props.diff !== props.data) return true;
266
- return false;
267
- });
268
- // tabindex
269
- const tabindex = computed(() => {
270
- if (props.disabled === true) return -1;
271
- if (props.readonly === true) return -1;
272
- return props.tabindex;
273
- });
274
-
275
- // ----------------------------------------------------------------------------
276
- const lenLabelClass = computed(() => {
277
- return [
278
- twMerge(
279
- "text-white bg-[#2fa412]",
280
- props.maxLen - state.value.length < 9 ? "bg-[#fdc90d]" : "",
281
- props.maxLen - state.value.length < 6 ? "bg-[#fd750d]" : "",
282
- props.maxLen - state.value.length < 3 ? "bg-[#fa541d]" : ""
283
- ),
284
- ];
285
- });
286
-
287
- const dataListId = ref(`textbox-list-${uid}`);
288
- // ----------------------------------------------------------------------------
289
- </script>
290
-
291
- <template>
292
- <InputFrame
293
- :class="props.class"
294
- :class-header="props.classHeader"
295
- :class-input="[props.classInput]"
296
- :focus="computedActivate"
297
- :focus-color="props.focusColor"
298
- :change="isChangeData"
299
- :change-color="props.changeColor"
300
- :error="props.error"
301
- :error-color="props.errorColor"
302
- :disabled="props.disabled"
303
- :disabled-color="props.disabledColor"
304
- :readonly="props.readonly"
305
- :label="props.label"
306
- :require="props.require"
307
- :require-text="props.requireText"
308
- :warn="props.warn"
309
- :warn-time-out="props.warnTimeOut"
310
- :size="props.size"
311
- :headerless="props.headerless"
312
- @click="elmFocus"
313
- >
314
- <template v-if="slots['left-icons']" #left-icons>
315
- <slot name="left-icons" :disabled="disabled" />
316
- </template>
317
- <template v-if="slots['right-icons']" #right-icons>
318
- <slot name="right-icons" :disabled="disabled" />
319
- </template>
320
- <template v-if="slots.overlay" #overlay>
321
- <slot name="overlay"></slot>
322
- </template>
323
- <template v-if="props.maxLen > 0" #header-right="{ defaultClass }">
324
- <div :class="[defaultClass, lenLabelClass]">
325
- {{ state.value.length }} / {{ props.maxLen }}
326
- </div>
327
- </template>
328
- <div
329
- v-if="props.disabled"
330
- class="input-d"
331
- :style="`text-align:${props.textAlign};`"
332
- >
333
- {{ state.value }}
334
- </div>
335
- <input
336
- v-else
337
- :ref="(e) => setRef(e)"
338
- v-model="state.value"
339
- :list="props.datalist.length > 0 ? dataListId : undefined"
340
- :type="props.type"
341
- :autocomplete="props.autocomplete"
342
- style="ime-mode: active"
343
- :style="`text-align:${props.textAlign};`"
344
- class="w-full"
345
- :disabled="props.disabled"
346
- :readonly="props.readonly"
347
- :tabindex="tabindex"
348
- :enterkeyhint="props.enterkeyhint"
349
- :inputmode="props.inputmode"
350
- @blur="onBlur()"
351
- @focus="onFocus()"
352
- @input="updateValue(state.value)"
353
- @keydown="(e: KeyboardEvent) => emit('keydown', e)"
354
- @keyup="(e: KeyboardEvent) => emit('keyup', e)"
355
- @click.stop=""
356
- />
357
- <datalist v-if="props.datalist.length !== 0" :id="dataListId">
358
- <template v-for="(row, index) in props.datalist" :key="index">
359
- <option :value="row" />
360
- </template>
361
- </datalist>
362
- </InputFrame>
363
- </template>
364
-
1
+ <script setup>
2
+ import { twMerge } from "tailwind-merge";
3
+ import { reactive, ref, watch, computed, nextTick, useId } from "#imports";
4
+ import { useHsFocus } from "../../composables/use-hs-focus";
5
+ import { useHsPinia } from "../../composables/use-pinia";
6
+ import { useHsMultiLang } from "../../composables/use-hs-multi-lang";
7
+ import { useHsMisc } from "../../composables/use-hs-misc";
8
+ import InputFrame from "./input-frame.vue";
9
+ const fcFocus = useHsFocus(useHsPinia());
10
+ const hsMisc = useHsMisc(useHsPinia());
11
+ const props = defineProps({
12
+ type: { type: String, required: false, default: "text" },
13
+ textAlign: { type: String, required: false, default: "left" },
14
+ maxLen: { type: Number, required: false, default: 0 },
15
+ autocomplete: { type: String, required: false, default: "off" },
16
+ datalist: { type: Array, required: false, default: () => [] },
17
+ enterkeyhint: { type: null, required: false, default: void 0 },
18
+ inputmode: { type: null, required: false, default: void 0 },
19
+ inputSize: { type: [String, Number], required: false, default: 10 },
20
+ placeholder: { type: [String, Object], required: false, default: "" },
21
+ pattern: { type: String, required: false, default: void 0 },
22
+ lang: { type: String, required: false, default: void 0 },
23
+ data: { type: [String, null], required: true },
24
+ diff: { type: null, required: false, default: void 0 },
25
+ tabindex: { type: null, required: false, default: void 0 },
26
+ class: { type: [String, Object, Array], required: false, default: "" },
27
+ classHeader: { type: [String, Object, Array], required: false, default: "" },
28
+ classInput: { type: [String, Object, Array], required: false, default: "" },
29
+ focusColor: { type: String, required: false, default: "shadow-[inset_0px_0px_1px_2px_#0d8ee4]" },
30
+ changeColor: { type: String, required: false, default: "shadow-[inset_0px_0px_1px_2px_#fd9831be]" },
31
+ error: { type: Boolean, required: false, default: false },
32
+ errorColor: { type: String, required: false, default: "shadow-[inset_0px_0px_1px_2px_#d80000dc]" },
33
+ disabled: { type: Boolean, required: false, default: false },
34
+ disabledColor: { type: String, required: false, default: "" },
35
+ readonly: { type: Boolean, required: false, default: false },
36
+ headerless: { type: Boolean, required: false, default: false },
37
+ label: { type: [String, Object], required: false, default: "" },
38
+ require: { type: Boolean, required: false, default: false },
39
+ requireText: { type: [String, Object], required: false, default: () => ({ ja: "\u5FC5\u9808", en: "Required" }) },
40
+ warn: { type: String, required: false, default: "" },
41
+ warnTimeOut: { type: Number, required: false, default: 3e3 },
42
+ size: { type: String, required: false, default: "m" }
43
+ });
44
+ const emit = defineEmits(["ref", "focus", "blur", "update:data", "value-change", "keydown", "keyup"]);
45
+ const slots = defineSlots();
46
+ const uid = useId();
47
+ const multiLang = useHsMultiLang(useHsPinia());
48
+ const tx = multiLang.tx;
49
+ const state = reactive({
50
+ value: ""
51
+ });
52
+ watch(
53
+ () => props.data,
54
+ () => {
55
+ setValue(props.data);
56
+ }
57
+ );
58
+ const updateValue = async (text) => {
59
+ const before = props.data;
60
+ let setText = "";
61
+ if (text === null) {
62
+ setText = "";
63
+ } else if (props.maxLen === 0 || text.length <= props.maxLen) {
64
+ setText = text;
65
+ } else {
66
+ const CutLen = (text2, len, addWard = "") => {
67
+ if (text2 === null) return "";
68
+ if (len === 0) return text2;
69
+ return text2.substring(0, len) + addWard;
70
+ };
71
+ setText = CutLen(text, props.maxLen, "");
72
+ }
73
+ state.value = setText;
74
+ emit("update:data", setText);
75
+ await nextTick();
76
+ emit("value-change", setText, before);
77
+ };
78
+ const setValue = (text) => {
79
+ if (text === null) {
80
+ state.value = "";
81
+ return;
82
+ }
83
+ if (props.maxLen === 0 || text.length <= props.maxLen) {
84
+ state.value = text;
85
+ } else {
86
+ updateValue(text);
87
+ }
88
+ };
89
+ setValue(props.data);
90
+ const inputElement = ref();
91
+ defineExpose({ el: inputElement });
92
+ const setRef = (elm) => {
93
+ inputElement.value = elm;
94
+ emit("ref", elm);
95
+ };
96
+ const focusState = reactive({
97
+ isActivate: false,
98
+ isMmousedown: false
99
+ });
100
+ const computedActivate = computed(() => {
101
+ if (props.disabled === true) return false;
102
+ if (props.readonly === true) return false;
103
+ if (fcFocus.state.id !== uid) return false;
104
+ if (focusState.isActivate) return true;
105
+ if (focusState.isMmousedown) return true;
106
+ return false;
107
+ });
108
+ watch(computedActivate, (value) => {
109
+ if (value === true) {
110
+ setTimeout(() => {
111
+ emit("focus", inputElement.value);
112
+ }, 10);
113
+ } else {
114
+ emit("blur", inputElement.value);
115
+ }
116
+ });
117
+ const onFocus = () => {
118
+ if (props.disabled === true) return;
119
+ if (props.readonly === true) return;
120
+ focusState.isActivate = true;
121
+ fcFocus.state.id = uid;
122
+ };
123
+ const onBlur = () => {
124
+ focusState.isActivate = false;
125
+ };
126
+ const isChangeData = computed(() => {
127
+ if (props.diff === void 0) return false;
128
+ if (props.diff === null && props.data === "") return false;
129
+ if (props.diff === "" && props.data === null) return false;
130
+ if (props.diff !== props.data) return true;
131
+ return false;
132
+ });
133
+ const tabindex = computed(() => {
134
+ if (props.disabled === true) return -1;
135
+ if (props.readonly === true) return -1;
136
+ return props.tabindex;
137
+ });
138
+ const lastLen = computed(() => {
139
+ return props.maxLen - state.value.length;
140
+ });
141
+ const lenLabelClass = computed(() => {
142
+ return [
143
+ twMerge(
144
+ "text-white bg-[#2fa412]",
145
+ lastLen.value < 9 ? "bg-[#fdc90d]" : "",
146
+ lastLen.value < 6 ? "bg-[#fd750d]" : "",
147
+ lastLen.value < 3 ? "bg-[#fa541d]" : ""
148
+ )
149
+ ];
150
+ });
151
+ const dataListId = ref(`textbox-list-${uid}`);
152
+ const placeholder = computed(() => tx(props.placeholder).value);
153
+ </script>
154
+
155
+ <template>
156
+ <InputFrame
157
+ :class="props.class"
158
+ :class-header="props.classHeader"
159
+ :class-input="[props.classInput]"
160
+ :focus="computedActivate"
161
+ :focus-color="props.focusColor"
162
+ :change="isChangeData"
163
+ :change-color="props.changeColor"
164
+ :error="props.error"
165
+ :error-color="props.errorColor"
166
+ :disabled="props.disabled"
167
+ :disabled-color="props.disabledColor"
168
+ :readonly="props.readonly"
169
+ :label="props.label"
170
+ :require="props.require"
171
+ :require-text="props.requireText"
172
+ :warn="props.warn"
173
+ :warn-time-out="props.warnTimeOut"
174
+ :size="props.size"
175
+ :headerless="props.headerless"
176
+ >
177
+ <template #overlay="{ focus, change }">
178
+ <div
179
+ v-if="props.diff !== void 0 && change"
180
+ class="absolute inset-0 bg-red/30 transition-opacity flex items-center p-1 bg-dark/20"
181
+ :class="!focus && hsMisc.capsLockState ? 'opacity-100' : 'opacity-0 pointer-events-none select-none'"
182
+ >
183
+ <div class="flex">
184
+ <Btn
185
+ variant="outlined"
186
+ theme="error"
187
+ tabindex="-1"
188
+ size="xs"
189
+ class="bg-white flex-none"
190
+ @click="updateValue(props.diff)"
191
+ >
192
+ <i class="fa-solid fa-rotate-right"></i>
193
+ </Btn>
194
+ <div v-if="props.diff" class="px-1 truncate bg-white mx-1 flex items-center">{{ props.diff }}</div>
195
+ </div>
196
+ </div>
197
+ <template v-if="slots.overlay">
198
+ <slot name="overlay" :focus="focus" :change="change"></slot>
199
+ </template>
200
+ </template>
201
+ <template v-if="slots['left-icons']" #left-icons>
202
+ <slot name="left-icons" :disabled="disabled" />
203
+ </template>
204
+ <template v-if="slots['right-icons']" #right-icons>
205
+ <slot name="right-icons" :disabled="disabled" />
206
+ </template>
207
+ <template v-if="slots['label-prepend']" #label-prepend>
208
+ <slot name="label-prepend" />
209
+ </template>
210
+ <template v-if="slots['label-append']" #label-append>
211
+ <slot name="label-append" />
212
+ </template>
213
+ <template v-if="props.maxLen > 0 || slots['header-right']" #header-right="{ defaultClass }">
214
+ <slot name="header-right" />
215
+ <div v-if="props.maxLen > 0 && lastLen < 15" :class="[defaultClass, lenLabelClass]">
216
+ {{ state.value.length }} / {{ props.maxLen }}
217
+ </div>
218
+ </template>
219
+ <template #default="{ focus }">
220
+ <span
221
+ v-if="placeholder"
222
+ class="text-black/50 pointer-events-none select-none px-1 absolute inset-0 items-center transition-opacity truncate"
223
+ :class="focus || !!state.value ? 'opacity-0' : ''"
224
+ >
225
+ <div class="truncate w-full" :style="`text-align:${props.textAlign};`">
226
+ {{ placeholder }}
227
+ </div>
228
+ </span>
229
+ <div v-if="props.disabled" class="input-d" :style="`text-align:${props.textAlign};`">
230
+ {{ state.value }}
231
+ </div>
232
+ <input
233
+ v-else
234
+ :ref="(e) => setRef(e)"
235
+ v-model="state.value"
236
+ :list="props.datalist.length > 0 ? dataListId : void 0"
237
+ :type="props.type"
238
+ :autocomplete="props.autocomplete"
239
+ style="ime-mode: active"
240
+ :style="`text-align:${props.textAlign};`"
241
+ class="w-full"
242
+ :disabled="props.disabled"
243
+ :readonly="props.readonly"
244
+ :tabindex="tabindex"
245
+ :enterkeyhint="props.enterkeyhint"
246
+ :inputmode="props.inputmode"
247
+ :size="props.inputSize"
248
+ :lang="props.lang"
249
+ :pattern="props.pattern"
250
+ @blur="onBlur()"
251
+ @focus="onFocus()"
252
+ @input="updateValue(state.value)"
253
+ @keydown="(e) => emit('keydown', e)"
254
+ @keyup="(e) => emit('keyup', e)"
255
+ @click.stop=""
256
+ />
257
+ <datalist v-if="props.datalist.length !== 0" :id="dataListId">
258
+ <template v-for="(row, index) in props.datalist" :key="index">
259
+ <option :value="row" />
260
+ </template>
261
+ </datalist>
262
+ </template>
263
+ </InputFrame>
264
+ </template>
265
+
365
266
  <style scoped>
366
267
  .input-d,
367
268
  input {
@@ -380,4 +281,4 @@ input {
380
281
  input::-webkit-calendar-picker-indicator {
381
282
  opacity: 0;
382
283
  }
383
- </style>
284
+ </style>