nuxt-hs-ui 1.0.10 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/dist/module.d.mts +10 -2
- package/dist/module.d.ts +10 -2
- package/dist/module.json +5 -2
- package/dist/module.mjs +90 -51
- package/dist/runtime/assets/flatpickr-dark.css +1 -0
- package/dist/runtime/assets/flatpickr-month-select-style.css +1 -0
- package/dist/runtime/assets/tabulator-custom.css +1 -0
- package/dist/runtime/assets/tabulator.css +1 -0
- package/dist/runtime/assets/vue-select.css +1 -0
- package/dist/runtime/components/{hs-fc/btn/line-loading.vue → form/btn-line-loading.vue} +28 -42
- package/dist/runtime/components/form/btn.vue +488 -0
- package/dist/runtime/components/form/check-box.vue +352 -0
- package/dist/runtime/components/form/check-list.vue +354 -0
- package/dist/runtime/components/form/datepicker copy.vue +770 -0
- package/dist/runtime/components/form/datepicker.vue +897 -0
- package/dist/runtime/components/form/input-frame.vue +272 -0
- package/dist/runtime/components/form/radio.vue +685 -0
- package/dist/runtime/components/form/select-img-icon.vue +53 -0
- package/dist/runtime/components/form/select.vue +438 -0
- package/dist/runtime/components/form/text-box.vue +375 -0
- package/dist/runtime/components/form/textarea.vue +466 -0
- package/dist/runtime/components/form/value-box.vue +681 -0
- package/dist/runtime/components/interactive/alert.vue +113 -0
- package/dist/runtime/components/{hs-ui → interactive}/block-loading.vue +42 -59
- package/dist/runtime/components/{hs-ui/dialog/index.vue → interactive/dialog.vue} +132 -127
- package/dist/runtime/components/interactive/modal-bg.vue +82 -0
- package/dist/runtime/components/interactive/modal.vue +143 -0
- package/dist/runtime/components/{hs-ui/toast/index.vue → interactive/toast.vue} +76 -109
- package/dist/runtime/components/{hs-ui → interactive}/window-loader.vue +12 -9
- package/dist/runtime/components/{hs-ui → layout}/accordion.vue +21 -30
- package/dist/runtime/components/layout/aspect-box.vue +71 -0
- package/dist/runtime/components/layout/card-item.vue +193 -0
- package/dist/runtime/components/layout/card.vue +42 -0
- package/dist/runtime/components/layout/container.vue +40 -0
- package/dist/runtime/components/misc/breadcrumb.vue +96 -0
- package/dist/runtime/components/misc/tabulator.vue +187 -0
- package/dist/runtime/components/misc/view-name-display-target.vue +39 -0
- package/dist/runtime/components/misc/view-name-display.vue +90 -0
- package/dist/runtime/composables/use-hs-dialog.d.ts +40 -0
- package/dist/runtime/composables/{use-hs-ui-dialog.js → use-hs-dialog.js} +15 -10
- package/dist/runtime/composables/{use-hs-form-focus.d.ts → use-hs-focus.d.ts} +1 -1
- package/dist/runtime/composables/{use-hs-form-focus.js → use-hs-focus.js} +2 -4
- package/dist/runtime/composables/use-hs-misc.d.ts +22 -0
- package/dist/runtime/composables/use-hs-misc.js +62 -0
- package/dist/runtime/composables/use-hs-modal.d.ts +31 -0
- package/dist/runtime/{components/hs-ui/modal/use-ui-modal.js → composables/use-hs-modal.js} +18 -16
- package/dist/runtime/composables/use-hs-multi-lang.d.ts +14 -6
- package/dist/runtime/composables/use-hs-multi-lang.js +44 -11
- package/dist/runtime/composables/{use-hs-ui-toast.d.ts → use-hs-toast.d.ts} +3 -3
- package/dist/runtime/composables/{use-hs-ui-toast.js → use-hs-toast.js} +4 -5
- package/dist/runtime/composables/{use-hs-ui-window-loader.d.ts → use-hs-window-loader.d.ts} +1 -1
- package/dist/runtime/composables/{use-hs-ui-window-loader.js → use-hs-window-loader.js} +1 -2
- package/dist/runtime/plugin/v-select.d.ts +2 -0
- package/dist/runtime/plugin/v-select.js +5 -0
- package/dist/runtime/style.css +22 -1
- package/dist/runtime/tailwind.css +78 -0
- package/dist/runtime/types/app.config.d.ts +5 -0
- package/dist/runtime/{components/hs-ui/dialog/index.type.d.ts → types/dialog.d.ts} +3 -3
- package/dist/runtime/{components/hs-ui/toast/index.type.d.ts → types/toast.d.ts} +1 -2
- package/dist/runtime/{components/hs-ui/toast/index.type.js → types/toast.js} +0 -1
- package/dist/runtime/utils/class-style.d.ts +6 -0
- package/dist/runtime/utils/class-style.js +27 -0
- package/dist/runtime/utils/com.d.ts +6 -0
- package/dist/runtime/{lib → utils}/com.js +1 -4
- package/dist/runtime/utils/dayjs.d.ts +53 -0
- package/dist/runtime/utils/dayjs.js +124 -0
- package/dist/runtime/utils/float.d.ts +2 -0
- package/dist/runtime/utils/float.js +35 -0
- package/dist/runtime/utils/multi-lang-object.d.ts +17 -0
- package/dist/runtime/utils/multi-lang-object.js +34 -0
- package/dist/runtime/{lib → utils}/multi-lang.d.ts +1 -1
- package/dist/runtime/{lib → utils}/multi-lang.js +31 -27
- package/dist/runtime/{lib → utils}/number.d.ts +2 -4
- package/dist/runtime/{lib → utils}/number.js +29 -69
- package/dist/runtime/utils/object.d.ts +46 -0
- package/dist/runtime/utils/object.js +107 -0
- package/dist/runtime/utils/select-item.d.ts +31 -0
- package/dist/runtime/utils/select.d.ts +14 -0
- package/dist/runtime/utils/select.js +36 -0
- package/dist/runtime/utils/string.d.ts +39 -0
- package/dist/runtime/utils/string.js +125 -0
- package/dist/runtime/utils/tabulator.d.ts +108 -0
- package/dist/runtime/utils/tabulator.js +296 -0
- package/dist/runtime/utils/theme.d.ts +21 -0
- package/dist/runtime/utils/theme.js +31 -0
- package/dist/runtime/utils/tv.d.ts +101 -0
- package/dist/runtime/utils/tv.js +26 -0
- package/dist/runtime/utils/wareki.d.ts +3 -0
- package/dist/runtime/utils/wareki.js +106 -0
- package/dist/types.d.mts +1 -17
- package/dist/types.d.ts +1 -17
- package/package.json +99 -37
- package/dist/runtime/components/hs-fc/btn/index.vue +0 -510
- package/dist/runtime/components/hs-ui/aspect-box.vue +0 -83
- package/dist/runtime/components/hs-ui/card-item.vue +0 -141
- package/dist/runtime/components/hs-ui/card.vue +0 -54
- package/dist/runtime/components/hs-ui/container.vue +0 -50
- package/dist/runtime/components/hs-ui/modal/bg.vue +0 -94
- package/dist/runtime/components/hs-ui/modal/index.vue +0 -206
- package/dist/runtime/components/hs-ui/modal/use-ui-modal.d.ts +0 -20
- package/dist/runtime/components/v-test.vue +0 -60
- package/dist/runtime/composables/use-hs-ui-dialog.d.ts +0 -22
- package/dist/runtime/lib/class-style.d.ts +0 -8
- package/dist/runtime/lib/class-style.js +0 -59
- package/dist/runtime/lib/com.d.ts +0 -14
- package/dist/runtime/lib/prefix.d.ts +0 -2
- package/dist/runtime/lib/prefix.js +0 -17
- package/dist/runtime/lib/theme.d.ts +0 -2
- package/dist/runtime/lib/theme.js +0 -21
- /package/dist/runtime/{components/hs-ui/dialog/index.type.js → types/dialog.js} +0 -0
- /package/dist/runtime/{components/hs-fc/hoge → utils/select-item.js} +0 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/* ----------------------------------------------------------------------------
|
|
3
|
+
// src\runtime\components\form\value-box.vue
|
|
4
|
+
// ----------------------------------------------------------------------------
|
|
5
|
+
// ValueBox
|
|
6
|
+
// ValueBoxValueBox
|
|
7
|
+
----------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
// [ node_modules ]
|
|
10
|
+
import BigNumber from "bignumber.js";
|
|
11
|
+
// [ NUXT ]
|
|
12
|
+
import {
|
|
13
|
+
reactive,
|
|
14
|
+
ref,
|
|
15
|
+
watch,
|
|
16
|
+
computed,
|
|
17
|
+
useId,
|
|
18
|
+
onMounted,
|
|
19
|
+
nextTick,
|
|
20
|
+
} from "#imports";
|
|
21
|
+
// [ utils ]
|
|
22
|
+
import type { ClassType } from "../../utils/class-style";
|
|
23
|
+
import { InsertComma } from "../../utils/number";
|
|
24
|
+
import { FloatNullable } from "../../utils/float";
|
|
25
|
+
// [ composables ]
|
|
26
|
+
import { useHsFocus } from "../../composables/use-hs-focus";
|
|
27
|
+
import { useHsToast } from "../../composables/use-hs-toast";
|
|
28
|
+
import { useHsMisc } from "../../composables/use-hs-misc";
|
|
29
|
+
// [ Components ]
|
|
30
|
+
import InputFrame from "./input-frame.vue";
|
|
31
|
+
// ----------------------------------------------------------------------------
|
|
32
|
+
// [ com > lib > * ]
|
|
33
|
+
// import { FloatNullable } from '~/com/lib/float';
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
35
|
+
const hsFocus = useHsFocus();
|
|
36
|
+
const hsMisc = useHsMisc();
|
|
37
|
+
const Toast = useHsToast();
|
|
38
|
+
// ----------------------------------------------------------------------------
|
|
39
|
+
// [ Props ]
|
|
40
|
+
type Props = {
|
|
41
|
+
// ----------------------------------------------------------------------------
|
|
42
|
+
// Input 種類別
|
|
43
|
+
nullable?: boolean;
|
|
44
|
+
unit?: string;
|
|
45
|
+
step?: number;
|
|
46
|
+
min?: number;
|
|
47
|
+
max?: number;
|
|
48
|
+
digits?: number;
|
|
49
|
+
isShowBtnControl?: boolean;
|
|
50
|
+
comma?: string;
|
|
51
|
+
enterkeyhint?: string;
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
data: number | null;
|
|
54
|
+
diff?: number | null | undefined;
|
|
55
|
+
tabindex?: string | undefined;
|
|
56
|
+
// ----------------------------------------------------------------------------
|
|
57
|
+
class?: ClassType;
|
|
58
|
+
classHeader?: ClassType;
|
|
59
|
+
classInput?: ClassType;
|
|
60
|
+
// ----------------------------------------------------------------------------
|
|
61
|
+
// 状態
|
|
62
|
+
// focus?: boolean;
|
|
63
|
+
focusColor?: string;
|
|
64
|
+
// change?: boolean;
|
|
65
|
+
changeColor?: string;
|
|
66
|
+
error?: boolean;
|
|
67
|
+
errorColor?: string;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
disabledColor?: string;
|
|
70
|
+
readonly?: boolean;
|
|
71
|
+
// ----------------------------------------------------------------------------
|
|
72
|
+
// 表示
|
|
73
|
+
label?: string;
|
|
74
|
+
// 表示-副情報
|
|
75
|
+
require?: boolean;
|
|
76
|
+
requireText?: string;
|
|
77
|
+
warn?: string;
|
|
78
|
+
warnTimeOut?: number;
|
|
79
|
+
// ----------------------------------------------------------------------------
|
|
80
|
+
// 設定
|
|
81
|
+
size?: "s" | "m" | "l";
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
uiText?: {
|
|
84
|
+
validError: {
|
|
85
|
+
title: string;
|
|
86
|
+
nullValue: string;
|
|
87
|
+
minValue: string;
|
|
88
|
+
maxValue: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
93
|
+
// ----------------------------------------------------------------------------
|
|
94
|
+
// Input 種類別
|
|
95
|
+
nullable: true,
|
|
96
|
+
unit: "",
|
|
97
|
+
step: 1,
|
|
98
|
+
min: -9999999999,
|
|
99
|
+
max: 9999999999,
|
|
100
|
+
digits: 0,
|
|
101
|
+
isShowBtnControl: false,
|
|
102
|
+
comma: ",",
|
|
103
|
+
enterkeyhint: undefined,
|
|
104
|
+
|
|
105
|
+
// ----------------------------------------------------------------------------
|
|
106
|
+
diff: undefined,
|
|
107
|
+
tabindex: undefined,
|
|
108
|
+
// ----------------------------------------------------------------------------
|
|
109
|
+
class: "",
|
|
110
|
+
classHeader: "",
|
|
111
|
+
classInput: "",
|
|
112
|
+
// ----------------------------------------------------------------------------
|
|
113
|
+
// 状態
|
|
114
|
+
// focus: false,
|
|
115
|
+
focusColor: "shadow-[inset_0px_0px_1px_2px_#0d8ee4]",
|
|
116
|
+
// change: false,
|
|
117
|
+
changeColor: "shadow-[inset_0px_0px_1px_2px_#fd9831be]",
|
|
118
|
+
error: false,
|
|
119
|
+
errorColor: "shadow-[inset_0px_0px_1px_2px_#d80000dc]",
|
|
120
|
+
disabled: false,
|
|
121
|
+
disabledColor: "",
|
|
122
|
+
readonly: false,
|
|
123
|
+
// ----------------------------------------------------------------------------
|
|
124
|
+
// 表示
|
|
125
|
+
label: "",
|
|
126
|
+
// 表示-副情報
|
|
127
|
+
require: false,
|
|
128
|
+
requireText: "必須",
|
|
129
|
+
warn: "",
|
|
130
|
+
warnTimeOut: 300,
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
// 設定
|
|
133
|
+
size: "m",
|
|
134
|
+
// ----------------------------------------------------------------------------
|
|
135
|
+
uiText: () => {
|
|
136
|
+
return {
|
|
137
|
+
validError: {
|
|
138
|
+
title: "入力値の警告",
|
|
139
|
+
nullValue: "数値以外は許可されていません。",
|
|
140
|
+
minValue: "[{value}]以下の数値は入力できません",
|
|
141
|
+
maxValue: "[{value}]以上の数値は入力できません",
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// ----------------------------------------------------------------------------
|
|
148
|
+
// [ emit ]
|
|
149
|
+
type Emits = {
|
|
150
|
+
ref: [element: HTMLElement];
|
|
151
|
+
focus: [elm: HTMLElement];
|
|
152
|
+
blur: [elm: HTMLElement];
|
|
153
|
+
// ----------------------------
|
|
154
|
+
"update:data": [value: number | null];
|
|
155
|
+
"value-change": [after: number | null, before: number | null];
|
|
156
|
+
// ----------------------------
|
|
157
|
+
keydown: [event: KeyboardEvent];
|
|
158
|
+
keyup: [event: KeyboardEvent];
|
|
159
|
+
// ----------------------------
|
|
160
|
+
};
|
|
161
|
+
const emit = defineEmits<Emits>();
|
|
162
|
+
// ----------------------------------------------------------------------------
|
|
163
|
+
// [ getCurrentInstance ]
|
|
164
|
+
const uid = useId();
|
|
165
|
+
|
|
166
|
+
// ----------------------------------------------------------------------------
|
|
167
|
+
// [ reactive ]
|
|
168
|
+
interface State {
|
|
169
|
+
value: string;
|
|
170
|
+
inputMode: string;
|
|
171
|
+
}
|
|
172
|
+
const state = reactive<State>({
|
|
173
|
+
value: "",
|
|
174
|
+
inputMode: "text",
|
|
175
|
+
});
|
|
176
|
+
// ----------------------------------------------------------------------------
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
state.inputMode = hsMisc.state.isMobile === true ? "numeric" : "text";
|
|
179
|
+
});
|
|
180
|
+
watch(
|
|
181
|
+
() => hsMisc.state.isMobile,
|
|
182
|
+
() => {
|
|
183
|
+
state.inputMode = hsMisc.state.isMobile === true ? "numeric" : "text";
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// ----------------------------------------------------------------------------
|
|
188
|
+
/**
|
|
189
|
+
* 表示(カンマ表示)
|
|
190
|
+
*/
|
|
191
|
+
const displayText = computed(() => {
|
|
192
|
+
if (props.data === null) return "";
|
|
193
|
+
return InsertComma(props.data, props.digits, "0", props.comma);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 値が適正かチェックする
|
|
198
|
+
*/
|
|
199
|
+
const validCheck = (
|
|
200
|
+
val: number | null
|
|
201
|
+
): { result: boolean; message: string; value: number | null } => {
|
|
202
|
+
if (val === null) {
|
|
203
|
+
if (props.nullable === false) {
|
|
204
|
+
return {
|
|
205
|
+
result: false,
|
|
206
|
+
value: 0,
|
|
207
|
+
message: props.uiText.validError.nullValue,
|
|
208
|
+
};
|
|
209
|
+
} else {
|
|
210
|
+
return { result: true, value: null, message: "" };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (val < props.min) {
|
|
214
|
+
return {
|
|
215
|
+
result: false,
|
|
216
|
+
value: props.min,
|
|
217
|
+
message: props.uiText.validError.minValue.replace(
|
|
218
|
+
/\{value\}/g,
|
|
219
|
+
String(props.min)
|
|
220
|
+
),
|
|
221
|
+
// `[${props.min}]以下の数値は入力できません`,
|
|
222
|
+
};
|
|
223
|
+
} else if (props.max < val) {
|
|
224
|
+
return {
|
|
225
|
+
result: false,
|
|
226
|
+
value: props.max,
|
|
227
|
+
message: props.uiText.validError.maxValue.replace(
|
|
228
|
+
/\{value\}/g,
|
|
229
|
+
String(props.min)
|
|
230
|
+
),
|
|
231
|
+
// message: `[${props.max}]以上の数値は入力できません`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return { result: true, value: val, message: "" };
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 更新を親コンポーネントに伝える
|
|
239
|
+
* @param val
|
|
240
|
+
*/
|
|
241
|
+
const updateData = async (val: number | null, f = true) => {
|
|
242
|
+
// console.log('updateData', val);
|
|
243
|
+
const before = props.data;
|
|
244
|
+
let updateValue: number | null = null;
|
|
245
|
+
if (val !== null) {
|
|
246
|
+
updateValue = val;
|
|
247
|
+
} else if (props.nullable === false) {
|
|
248
|
+
updateValue = 0;
|
|
249
|
+
} else {
|
|
250
|
+
updateValue = null;
|
|
251
|
+
}
|
|
252
|
+
emit("update:data", updateValue);
|
|
253
|
+
await nextTick();
|
|
254
|
+
if (f) emit("value-change", updateValue, before);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 要素のイベント stepValue
|
|
259
|
+
*/
|
|
260
|
+
const stepValue = (isUp: boolean) => {
|
|
261
|
+
if (props.disabled === true) return;
|
|
262
|
+
if (props.readonly === true) return;
|
|
263
|
+
let nextValue = 0;
|
|
264
|
+
const inputValue = FloatNullable(props.data, props.digits);
|
|
265
|
+
const step = isUp === true ? props.step : props.step * -1;
|
|
266
|
+
if (inputValue === null) {
|
|
267
|
+
nextValue = step;
|
|
268
|
+
if (isUp === true) {
|
|
269
|
+
if (nextValue < props.min || props.max < nextValue) {
|
|
270
|
+
nextValue = props.max;
|
|
271
|
+
}
|
|
272
|
+
} else if (nextValue < props.min || props.max < nextValue) {
|
|
273
|
+
nextValue = props.min;
|
|
274
|
+
}
|
|
275
|
+
} else if (props.digits > 0 || step < 1) {
|
|
276
|
+
if (isUp === true) {
|
|
277
|
+
nextValue = BigNumber(inputValue).plus(BigNumber(props.step)).toNumber();
|
|
278
|
+
} else {
|
|
279
|
+
nextValue = BigNumber(inputValue).minus(BigNumber(props.step)).toNumber();
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
nextValue = inputValue + step;
|
|
283
|
+
}
|
|
284
|
+
const validCheckResult = validCheck(nextValue);
|
|
285
|
+
// console.log({ validCheckResult });
|
|
286
|
+
if (validCheckResult.result === true) {
|
|
287
|
+
updateData(validCheckResult.value);
|
|
288
|
+
// } else {
|
|
289
|
+
// emit('warn', validCheckResult.message, '入力値の警告', props.toastTime);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const isArrowUp = computed(() => {
|
|
294
|
+
if (props.data === null) return true;
|
|
295
|
+
if (props.data + props.step <= props.max) return true;
|
|
296
|
+
return false;
|
|
297
|
+
});
|
|
298
|
+
const isArrowDown = computed(() => {
|
|
299
|
+
if (props.data === null) return true;
|
|
300
|
+
if (props.min <= props.data - props.step) return true;
|
|
301
|
+
return false;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 全角数値を半角数値へ変換する
|
|
306
|
+
*/
|
|
307
|
+
const hankakuToZenkaku = (str: string) => {
|
|
308
|
+
return (str + "").replace(/[0-9]/g, (s) => {
|
|
309
|
+
return String.fromCharCode(s.charCodeAt(0) - 0xfee0);
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* 入力値の変更を起点としてチェック
|
|
315
|
+
*/
|
|
316
|
+
const checkValueByInput = () => {
|
|
317
|
+
const inputText = hankakuToZenkaku(state.value)
|
|
318
|
+
.replace(/ー/g, "-")
|
|
319
|
+
.replace(/[^(0-9)|.\-+]+/g, "");
|
|
320
|
+
const inputValue = FloatNullable(inputText, props.digits);
|
|
321
|
+
const validCheckResult = validCheck(inputValue);
|
|
322
|
+
|
|
323
|
+
// console.log(uid, { moto: state.value, inputText, inputValue, validCheckResult });
|
|
324
|
+
if (validCheckResult.value === null) {
|
|
325
|
+
state.value = "";
|
|
326
|
+
} else {
|
|
327
|
+
state.value = validCheckResult.value.toFixed(props.digits);
|
|
328
|
+
}
|
|
329
|
+
if (props.data !== validCheckResult.value) {
|
|
330
|
+
updateData(validCheckResult.value);
|
|
331
|
+
}
|
|
332
|
+
if (validCheckResult.result === false) {
|
|
333
|
+
Toast.Warning(
|
|
334
|
+
validCheckResult.message,
|
|
335
|
+
props.uiText.validError.title,
|
|
336
|
+
props.warnTimeOut
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* prop.data からのデータ入力
|
|
343
|
+
*/
|
|
344
|
+
const setValueByPropsData = () => {
|
|
345
|
+
const val = FloatNullable(props.data, props.digits);
|
|
346
|
+
if (props.data !== val) {
|
|
347
|
+
// 小数点許容確認とデータ修正
|
|
348
|
+
updateData(val, false);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const validCheckResult = validCheck(val);
|
|
352
|
+
if (validCheckResult.result === true) {
|
|
353
|
+
if (validCheckResult.value === null) {
|
|
354
|
+
state.value = "";
|
|
355
|
+
} else {
|
|
356
|
+
state.value = validCheckResult.value.toFixed(props.digits);
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
updateData(validCheckResult.value, false);
|
|
360
|
+
Toast.Warning(
|
|
361
|
+
validCheckResult.message,
|
|
362
|
+
props.uiText.validError.title,
|
|
363
|
+
props.warnTimeOut
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* 要素のイベント keydown
|
|
370
|
+
*/
|
|
371
|
+
const keydown = (e: KeyboardEvent) => {
|
|
372
|
+
emit("keydown", e);
|
|
373
|
+
if (
|
|
374
|
+
!props.isShowBtnControl &&
|
|
375
|
+
(e.key === "ArrowUp" || e.key === "ArrowDown")
|
|
376
|
+
) {
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (e.key === "ArrowUp") {
|
|
381
|
+
stepValue(true);
|
|
382
|
+
} else if (e.key === "ArrowDown") {
|
|
383
|
+
stepValue(false);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 要素のイベント keydown
|
|
389
|
+
*/
|
|
390
|
+
const onWheel = (e: WheelEvent) => {
|
|
391
|
+
if (!props.isShowBtnControl) return;
|
|
392
|
+
if (props.disabled === true) return;
|
|
393
|
+
if (props.readonly === true) return;
|
|
394
|
+
if (e.deltaY < 0) {
|
|
395
|
+
stepValue(true);
|
|
396
|
+
} else if (e.deltaY > 0) {
|
|
397
|
+
stepValue(false);
|
|
398
|
+
}
|
|
399
|
+
e.preventDefault();
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// [ ref ]
|
|
403
|
+
const inputElement = ref();
|
|
404
|
+
const setRef = (elm: any) => {
|
|
405
|
+
inputElement.value = elm;
|
|
406
|
+
emit("ref", elm as HTMLInputElement);
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* 強制focus
|
|
411
|
+
*/
|
|
412
|
+
const elmFocus = () => {
|
|
413
|
+
inputElement.value.focus();
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// [ focus, blur ]
|
|
417
|
+
|
|
418
|
+
interface FocusState {
|
|
419
|
+
isActivate: boolean;
|
|
420
|
+
isMmousedown: boolean;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const focusState = reactive<FocusState>({
|
|
424
|
+
isActivate: false,
|
|
425
|
+
isMmousedown: false,
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* コントロールのFocus判定
|
|
430
|
+
*/
|
|
431
|
+
const computedActivate = computed(() => {
|
|
432
|
+
if (hsFocus.state.id !== uid) return false;
|
|
433
|
+
if (props.disabled === true) return false;
|
|
434
|
+
if (props.readonly === true) return false;
|
|
435
|
+
if (focusState.isActivate) return true;
|
|
436
|
+
if (focusState.isMmousedown) return true;
|
|
437
|
+
return false;
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* focus, blur イベント
|
|
442
|
+
*/
|
|
443
|
+
watch(computedActivate, (value) => {
|
|
444
|
+
if (value === true) {
|
|
445
|
+
// クリックでの遷移の場合に
|
|
446
|
+
// 一つ前のコントロールのblurイベントよりも早くfocusが発生しないようにする対策で10ミリ秒処理をずらす
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
emit("focus", inputElement.value);
|
|
449
|
+
}, 10);
|
|
450
|
+
} else {
|
|
451
|
+
emit("blur", inputElement.value);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
const zeroFlag = ref(false);
|
|
456
|
+
const onFocus = () => {
|
|
457
|
+
zeroFlag.value = false;
|
|
458
|
+
if (props.disabled === true) return;
|
|
459
|
+
if (props.readonly === true) return;
|
|
460
|
+
hsFocus.state.id = uid;
|
|
461
|
+
focusState.isActivate = true;
|
|
462
|
+
if (state.inputMode === "text") {
|
|
463
|
+
// inputElement.value.select();
|
|
464
|
+
} else if (state.value === "0") {
|
|
465
|
+
zeroFlag.value = true;
|
|
466
|
+
state.value = "";
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
// const instance = getCurrentInstance(); // コンポーネント固有のUIDを取得する
|
|
470
|
+
// const uid = instance != null ? String(instance.uid) : '';
|
|
471
|
+
// const id = useId();
|
|
472
|
+
const onBlur = () => {
|
|
473
|
+
try {
|
|
474
|
+
if (props.disabled === true) return;
|
|
475
|
+
if (props.readonly === true) return;
|
|
476
|
+
if (zeroFlag.value && state.value === "") {
|
|
477
|
+
state.value = "0";
|
|
478
|
+
}
|
|
479
|
+
focusState.isActivate = false;
|
|
480
|
+
focusState.isMmousedown = false;
|
|
481
|
+
// await Sleep(50);
|
|
482
|
+
checkValueByInput();
|
|
483
|
+
} catch (err) {
|
|
484
|
+
console.error(err);
|
|
485
|
+
} finally {
|
|
486
|
+
zeroFlag.value = true;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// ----------------------------------------------------------------------------
|
|
491
|
+
// 更新の有無判定
|
|
492
|
+
const isChangeData = computed(() => {
|
|
493
|
+
if (props.diff === undefined) return false;
|
|
494
|
+
if (props.diff !== props.data) return true;
|
|
495
|
+
return false;
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// tabindex
|
|
499
|
+
const tabindex = computed(() => {
|
|
500
|
+
if (props.disabled === true) return -1;
|
|
501
|
+
return props.tabindex;
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// [ locked ]
|
|
505
|
+
const locked = computed(() => {
|
|
506
|
+
if (props.disabled === true) return true;
|
|
507
|
+
if (props.readonly === true) return true;
|
|
508
|
+
return false;
|
|
509
|
+
});
|
|
510
|
+
// ----------------------------------------------------------------------------
|
|
511
|
+
|
|
512
|
+
onMounted(() => {
|
|
513
|
+
setValueByPropsData();
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
watch(
|
|
517
|
+
() => props.data,
|
|
518
|
+
() => {
|
|
519
|
+
setValueByPropsData();
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
// ----------------------------------------------------------------------------
|
|
523
|
+
</script>
|
|
524
|
+
|
|
525
|
+
<template>
|
|
526
|
+
<InputFrame
|
|
527
|
+
:class="props.class"
|
|
528
|
+
:class-header="props.classHeader"
|
|
529
|
+
:class-input="[props.classInput]"
|
|
530
|
+
:focus="computedActivate"
|
|
531
|
+
:focus-color="props.focusColor"
|
|
532
|
+
:change="isChangeData"
|
|
533
|
+
:change-color="props.changeColor"
|
|
534
|
+
:error="props.error"
|
|
535
|
+
:error-color="props.errorColor"
|
|
536
|
+
:disabled="props.disabled"
|
|
537
|
+
:disabled-color="props.disabledColor"
|
|
538
|
+
:readonly="props.readonly"
|
|
539
|
+
:label="props.label"
|
|
540
|
+
:require="props.require"
|
|
541
|
+
:require-text="props.requireText"
|
|
542
|
+
:warn="props.warn"
|
|
543
|
+
:warn-time-out="props.warnTimeOut"
|
|
544
|
+
:size="props.size"
|
|
545
|
+
@click="elmFocus"
|
|
546
|
+
>
|
|
547
|
+
<div class="flex items-end justify-end">
|
|
548
|
+
<div class="flex-1">
|
|
549
|
+
<input
|
|
550
|
+
:ref="(e) => setRef(e)"
|
|
551
|
+
v-model="state.value"
|
|
552
|
+
type="text"
|
|
553
|
+
:inputmode="hsMisc.state.isMobile ? 'numeric' : 'text'"
|
|
554
|
+
class="pe-[4px] w-full"
|
|
555
|
+
:class="[
|
|
556
|
+
//
|
|
557
|
+
computedActivate ? 'opacity-100' : 'opacity-0',
|
|
558
|
+
// { isShow: computedActivate },
|
|
559
|
+
]"
|
|
560
|
+
maxlength="20"
|
|
561
|
+
:enterkeyhint="props.enterkeyhint"
|
|
562
|
+
:disabled="props.disabled"
|
|
563
|
+
:readonly="props.readonly"
|
|
564
|
+
:tabindex="tabindex"
|
|
565
|
+
@wheel="onWheel"
|
|
566
|
+
@keydown="keydown"
|
|
567
|
+
@keyup="(e) => emit('keyup', e)"
|
|
568
|
+
@blur="onBlur()"
|
|
569
|
+
@focus="onFocus()"
|
|
570
|
+
/>
|
|
571
|
+
<input
|
|
572
|
+
type="text"
|
|
573
|
+
class="displayText pe-[4px] w-full"
|
|
574
|
+
:class="[
|
|
575
|
+
//
|
|
576
|
+
computedActivate ? 'opacity-0' : 'opacity-100',
|
|
577
|
+
{ readonly: props.readonly },
|
|
578
|
+
]"
|
|
579
|
+
:value="displayText"
|
|
580
|
+
:disabled="props.disabled"
|
|
581
|
+
:tabindex="-1"
|
|
582
|
+
readonly
|
|
583
|
+
/>
|
|
584
|
+
</div>
|
|
585
|
+
<div v-if="props.unit.length !== 0" class="flex-none unit">
|
|
586
|
+
{{ props.unit }}
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
<template #right-icons>
|
|
590
|
+
<div v-if="props.isShowBtnControl === true" class="u-d-icon" @click.stop>
|
|
591
|
+
<div
|
|
592
|
+
:class="[{ activate: isArrowUp && !locked }]"
|
|
593
|
+
@click="stepValue(true)"
|
|
594
|
+
>
|
|
595
|
+
<i class="fas fa-caret-up"></i>
|
|
596
|
+
</div>
|
|
597
|
+
<div
|
|
598
|
+
:class="[{ activate: isArrowDown && !locked }]"
|
|
599
|
+
@click="stepValue(false)"
|
|
600
|
+
>
|
|
601
|
+
<i class="fas fa-caret-down"></i>
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
</template>
|
|
605
|
+
</InputFrame>
|
|
606
|
+
</template>
|
|
607
|
+
|
|
608
|
+
<style scoped>
|
|
609
|
+
input {
|
|
610
|
+
background-color: transparent;
|
|
611
|
+
-webkit-appearance: none;
|
|
612
|
+
-moz-appearance: none;
|
|
613
|
+
appearance: none;
|
|
614
|
+
border: 0px;
|
|
615
|
+
outline: none;
|
|
616
|
+
text-align: right;
|
|
617
|
+
color: inherit;
|
|
618
|
+
}
|
|
619
|
+
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button {
|
|
620
|
+
-webkit-appearance: none !important;
|
|
621
|
+
margin: 0 !important;
|
|
622
|
+
}
|
|
623
|
+
input.isShow {
|
|
624
|
+
pointer-events: all;
|
|
625
|
+
}
|
|
626
|
+
input.displayText {
|
|
627
|
+
position: absolute;
|
|
628
|
+
inset: 0 0 0 0;
|
|
629
|
+
margin-top: auto;
|
|
630
|
+
margin-bottom: auto;
|
|
631
|
+
pointer-events: none;
|
|
632
|
+
}
|
|
633
|
+
input.displayText.readonly {
|
|
634
|
+
pointer-events: all;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.unit {
|
|
638
|
+
color: #696969;
|
|
639
|
+
align-items: flex-end;
|
|
640
|
+
align-self: flex-end;
|
|
641
|
+
margin: 0px 0px 2px 4px;
|
|
642
|
+
font-size: min(0.8em, 1rem);
|
|
643
|
+
-moz-user-select: none;
|
|
644
|
+
-webkit-user-select: none;
|
|
645
|
+
-ms-user-select: none;
|
|
646
|
+
user-select: none;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.u-d-icon {
|
|
650
|
+
width: 2em;
|
|
651
|
+
overflow: hidden;
|
|
652
|
+
display: flex;
|
|
653
|
+
flex-direction: column;
|
|
654
|
+
}
|
|
655
|
+
.u-d-icon > div {
|
|
656
|
+
flex: 1 1 auto;
|
|
657
|
+
display: flex;
|
|
658
|
+
justify-content: center;
|
|
659
|
+
align-items: center;
|
|
660
|
+
height: 50%;
|
|
661
|
+
cursor: pointer;
|
|
662
|
+
background-color: transparent;
|
|
663
|
+
color: #cccccc;
|
|
664
|
+
padding: 0 10px;
|
|
665
|
+
pointer-events: none;
|
|
666
|
+
font-size: min(0.9em, 1rem);
|
|
667
|
+
}
|
|
668
|
+
.u-d-icon > div.activate {
|
|
669
|
+
cursor: pointer;
|
|
670
|
+
background-color: transparent;
|
|
671
|
+
color: #f68708;
|
|
672
|
+
transition: all 300ms;
|
|
673
|
+
pointer-events: all;
|
|
674
|
+
}
|
|
675
|
+
.u-d-icon > div.activate:hover {
|
|
676
|
+
background-color: rgba(246, 135, 8, 0.2980392157);
|
|
677
|
+
}
|
|
678
|
+
.u-d-icon > div:first-child {
|
|
679
|
+
border-bottom: solid 1px gray;
|
|
680
|
+
}
|
|
681
|
+
</style>
|