nuxt-hs-ui 1.0.9 → 2.0.1

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 (112) hide show
  1. package/README.md +11 -4
  2. package/dist/module.d.mts +10 -2
  3. package/dist/module.d.ts +10 -2
  4. package/dist/module.json +5 -2
  5. package/dist/module.mjs +87 -51
  6. package/dist/runtime/assets/flatpickr-dark.css +1 -0
  7. package/dist/runtime/assets/flatpickr-month-select-style.css +1 -0
  8. package/dist/runtime/assets/tabulator-custom.css +1 -0
  9. package/dist/runtime/assets/tabulator.css +1 -0
  10. package/dist/runtime/assets/vue-select.css +1 -0
  11. package/dist/runtime/components/{hs-fc/btn/line-loading.vue → form/btn-line-loading.vue} +30 -45
  12. package/dist/runtime/components/form/btn.vue +488 -0
  13. package/dist/runtime/components/form/check-box.vue +352 -0
  14. package/dist/runtime/components/form/check-list.vue +354 -0
  15. package/dist/runtime/components/form/datepicker copy.vue +770 -0
  16. package/dist/runtime/components/form/datepicker.vue +897 -0
  17. package/dist/runtime/components/form/input-frame.vue +272 -0
  18. package/dist/runtime/components/form/radio.vue +685 -0
  19. package/dist/runtime/components/form/select-img-icon.vue +53 -0
  20. package/dist/runtime/components/form/select.vue +438 -0
  21. package/dist/runtime/components/form/text-box.vue +375 -0
  22. package/dist/runtime/components/form/textarea.vue +466 -0
  23. package/dist/runtime/components/form/value-box.vue +681 -0
  24. package/dist/runtime/components/interactive/alert.vue +113 -0
  25. package/dist/runtime/components/{hs-ui → interactive}/block-loading.vue +42 -59
  26. package/dist/runtime/components/{hs-ui/dialog/index.vue → interactive/dialog.vue} +132 -127
  27. package/dist/runtime/components/interactive/modal-bg.vue +82 -0
  28. package/dist/runtime/components/interactive/modal.vue +143 -0
  29. package/dist/runtime/components/{hs-ui/toast/index.vue → interactive/toast.vue} +76 -109
  30. package/dist/runtime/components/{hs-ui → interactive}/window-loader.vue +12 -9
  31. package/dist/runtime/components/{hs-ui → layout}/accordion.vue +21 -30
  32. package/dist/runtime/components/layout/aspect-box.vue +71 -0
  33. package/dist/runtime/components/layout/card-item.vue +193 -0
  34. package/dist/runtime/components/layout/card.vue +42 -0
  35. package/dist/runtime/components/layout/container.vue +40 -0
  36. package/dist/runtime/components/misc/breadcrumb.vue +96 -0
  37. package/dist/runtime/components/misc/tabulator.vue +187 -0
  38. package/dist/runtime/components/misc/view-name-display-target.vue +39 -0
  39. package/dist/runtime/components/misc/view-name-display.vue +90 -0
  40. package/dist/runtime/composables/use-hs-dialog.d.ts +40 -0
  41. package/dist/runtime/composables/{use-hs-ui-dialog.js → use-hs-dialog.js} +15 -10
  42. package/dist/runtime/composables/{use-hs-form-focus.d.ts → use-hs-focus.d.ts} +1 -1
  43. package/dist/runtime/composables/{use-hs-form-focus.js → use-hs-focus.js} +2 -4
  44. package/dist/runtime/composables/use-hs-misc.d.ts +22 -0
  45. package/dist/runtime/composables/use-hs-misc.js +62 -0
  46. package/dist/runtime/composables/use-hs-modal.d.ts +31 -0
  47. package/dist/runtime/{components/hs-ui/modal/use-ui-modal.js → composables/use-hs-modal.js} +18 -16
  48. package/dist/runtime/composables/use-hs-multi-lang.d.ts +14 -6
  49. package/dist/runtime/composables/use-hs-multi-lang.js +44 -11
  50. package/dist/runtime/composables/{use-hs-ui-toast.d.ts → use-hs-toast.d.ts} +3 -3
  51. package/dist/runtime/composables/{use-hs-ui-toast.js → use-hs-toast.js} +4 -5
  52. package/dist/runtime/composables/{use-hs-ui-window-loader.d.ts → use-hs-window-loader.d.ts} +1 -1
  53. package/dist/runtime/composables/{use-hs-ui-window-loader.js → use-hs-window-loader.js} +1 -2
  54. package/dist/runtime/plugin/v-select.d.ts +2 -0
  55. package/dist/runtime/plugin/v-select.js +5 -0
  56. package/dist/runtime/style.css +22 -1
  57. package/dist/runtime/tailwind.css +78 -0
  58. package/dist/runtime/types/app.config.d.ts +5 -0
  59. package/dist/runtime/{components/hs-ui/dialog/index.type.d.ts → types/dialog.d.ts} +3 -3
  60. package/dist/runtime/{components/hs-ui/toast/index.type.d.ts → types/toast.d.ts} +1 -2
  61. package/dist/runtime/{components/hs-ui/toast/index.type.js → types/toast.js} +0 -1
  62. package/dist/runtime/utils/class-style.d.ts +6 -0
  63. package/dist/runtime/utils/class-style.js +27 -0
  64. package/dist/runtime/utils/com.d.ts +6 -0
  65. package/dist/runtime/{lib → utils}/com.js +1 -4
  66. package/dist/runtime/utils/dayjs.d.ts +53 -0
  67. package/dist/runtime/utils/dayjs.js +124 -0
  68. package/dist/runtime/utils/float.d.ts +2 -0
  69. package/dist/runtime/utils/float.js +35 -0
  70. package/dist/runtime/utils/multi-lang-object.d.ts +17 -0
  71. package/dist/runtime/utils/multi-lang-object.js +34 -0
  72. package/dist/runtime/{lib → utils}/multi-lang.d.ts +1 -1
  73. package/dist/runtime/{lib → utils}/multi-lang.js +31 -27
  74. package/dist/runtime/{lib → utils}/number.d.ts +2 -4
  75. package/dist/runtime/{lib → utils}/number.js +29 -69
  76. package/dist/runtime/utils/object.d.ts +46 -0
  77. package/dist/runtime/utils/object.js +107 -0
  78. package/dist/runtime/utils/select-item.d.ts +31 -0
  79. package/dist/runtime/utils/select.d.ts +14 -0
  80. package/dist/runtime/utils/select.js +36 -0
  81. package/dist/runtime/utils/string.d.ts +39 -0
  82. package/dist/runtime/utils/string.js +125 -0
  83. package/dist/runtime/utils/tabulator.d.ts +108 -0
  84. package/dist/runtime/utils/tabulator.js +296 -0
  85. package/dist/runtime/utils/theme.d.ts +21 -0
  86. package/dist/runtime/utils/theme.js +31 -0
  87. package/dist/runtime/utils/tv.d.ts +101 -0
  88. package/dist/runtime/utils/tv.js +26 -0
  89. package/dist/runtime/utils/wareki.d.ts +3 -0
  90. package/dist/runtime/utils/wareki.js +106 -0
  91. package/dist/types.d.mts +1 -17
  92. package/dist/types.d.ts +1 -17
  93. package/package.json +99 -37
  94. package/dist/runtime/components/hs-fc/btn/index.vue +0 -510
  95. package/dist/runtime/components/hs-ui/aspect-box.vue +0 -83
  96. package/dist/runtime/components/hs-ui/card-item.vue +0 -141
  97. package/dist/runtime/components/hs-ui/card.vue +0 -54
  98. package/dist/runtime/components/hs-ui/container.vue +0 -50
  99. package/dist/runtime/components/hs-ui/modal/bg.vue +0 -94
  100. package/dist/runtime/components/hs-ui/modal/index.vue +0 -206
  101. package/dist/runtime/components/hs-ui/modal/use-ui-modal.d.ts +0 -20
  102. package/dist/runtime/components/v-test.vue +0 -60
  103. package/dist/runtime/composables/use-hs-ui-dialog.d.ts +0 -22
  104. package/dist/runtime/lib/class-style.d.ts +0 -8
  105. package/dist/runtime/lib/class-style.js +0 -59
  106. package/dist/runtime/lib/com.d.ts +0 -14
  107. package/dist/runtime/lib/prefix.d.ts +0 -2
  108. package/dist/runtime/lib/prefix.js +0 -17
  109. package/dist/runtime/lib/theme.d.ts +0 -2
  110. package/dist/runtime/lib/theme.js +0 -21
  111. /package/dist/runtime/{components/hs-ui/dialog/index.type.js → types/dialog.js} +0 -0
  112. /package/dist/runtime/{components/hs-fc/hoge → utils/select-item.js} +0 -0
@@ -1,5 +1,5 @@
1
- import { type MultiLang } from '../../../lib/multi-lang.js';
2
- import type { Theme } from '../../../lib/theme.js';
1
+ import type { MultiLang } from "../utils/multi-lang.js";
2
+ import type { Theme } from "../utils/theme.js";
3
3
  export declare const DialogDefaultZIndex = 3000;
4
4
  export declare const DialogResult: {
5
5
  readonly left: "left";
@@ -13,7 +13,7 @@ export type DialogResult = (typeof DialogResult)[keyof typeof DialogResult];
13
13
  export interface DialogOption {
14
14
  zindex: number;
15
15
  theme: Theme;
16
- defaultBtn: 'left' | 'right' | 'cancel' | null;
16
+ defaultBtn: "left" | "right" | "cancel" | null;
17
17
  btnLeft: {
18
18
  isShow: boolean;
19
19
  title: MultiLang;
@@ -1,5 +1,4 @@
1
- import { type MultiLang } from '../../../lib/multi-lang.js';
2
- export declare const NamespaceName = "Toast";
1
+ import type { MultiLang } from "../utils/multi-lang.js";
3
2
  export declare const Theme: {
4
3
  readonly Success: "success";
5
4
  readonly Info: "info";
@@ -1,4 +1,3 @@
1
- export const NamespaceName = "Toast";
2
1
  export const Theme = {
3
2
  Success: "success",
4
3
  Info: "info",
@@ -0,0 +1,6 @@
1
+ export type ClassTypeObje = {
2
+ [key: string]: boolean;
3
+ };
4
+ export type ClassTypeArray = (string | ClassTypeObje | ClassTypeArray)[];
5
+ export type ClassType = string | ClassTypeObje | ClassTypeArray;
6
+ export declare const ClassTypeToString: (c: ClassType) => string;
@@ -0,0 +1,27 @@
1
+ const typeOf = (obj) => {
2
+ return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
3
+ };
4
+ export const ClassTypeToString = (c) => {
5
+ const valueType = typeOf(c);
6
+ if (valueType === "string") return c;
7
+ if (valueType === "undefined") return "";
8
+ if (valueType === "array") {
9
+ return c.reduce((ret, row) => {
10
+ const a = ClassTypeToString(row);
11
+ if (a) {
12
+ ret.push(a);
13
+ }
14
+ return ret;
15
+ }, []).join(" ");
16
+ }
17
+ if (valueType === "object") {
18
+ return Object.keys(c).reduce((ret, key) => {
19
+ const b = c[key];
20
+ if (b) {
21
+ ret.push(key);
22
+ }
23
+ return ret;
24
+ }, []).join(" ");
25
+ }
26
+ return "";
27
+ };
@@ -0,0 +1,6 @@
1
+ /** ユニークな文字列を生成する */
2
+ export declare const GenerateUniqeKey: (len?: number) => string;
3
+ /** 一定時間処理を待機 */
4
+ export declare const Sleep: (time: number) => Promise<unknown>;
5
+ /** マウント後にブラウザ側で実行すること */
6
+ export declare const IsMobile: () => boolean;
@@ -1,6 +1,4 @@
1
1
  import dayjs from "dayjs/esm/index";
2
- export { ClassTypeToString } from "./class-style.js";
3
- export { RemovePrefix } from "./prefix.js";
4
2
  export const GenerateUniqeKey = (len = 32) => {
5
3
  const S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
6
4
  const word = len < 14 ? 14 : len - 15;
@@ -14,8 +12,7 @@ export const Sleep = (time) => {
14
12
  });
15
13
  };
16
14
  export const IsMobile = () => {
17
- if (navigator === void 0)
18
- return false;
15
+ if (navigator === void 0) return false;
19
16
  const userAgent = navigator.userAgent.toLowerCase();
20
17
  if (/android|ipod|ipad|iphone|macintosh/.test(userAgent) && "ontouchend" in document) {
21
18
  return true;
@@ -0,0 +1,53 @@
1
+ import dayjs from "dayjs";
2
+ export type Dayjs = dayjs.Dayjs;
3
+ export type QUnitType = dayjs.QUnitType;
4
+ export type OpUnitType = dayjs.OpUnitType;
5
+ export declare const DayjsInit: () => void;
6
+ export declare const defaultTimezone = "Asia/Tokyo";
7
+ /** Dayjsオブジェクトを生成 */
8
+ export declare const Dayjs: (arg?: string | number | Dayjs | Date | null | undefined) => Dayjs;
9
+ /** 日付オブジェクト(Null許容) */
10
+ export declare const DayjsNullable: (date?: string | null | Date | undefined) => Dayjs | null;
11
+ /**
12
+ * 日付の差分を計測
13
+ * - date - diff
14
+ * @param date 文字列、日付オブジェクト
15
+ */
16
+ export declare const DayjsDiff: (date: Dayjs | null, diff: Dayjs | null, unit: QUnitType | OpUnitType) => number | null;
17
+ /**
18
+ * 時差を取得する
19
+ * - str:format()
20
+ */
21
+ export declare const GetTimeShiftValue: (date: Dayjs | null) => number;
22
+ /**
23
+ * 日付の差分を計測
24
+ * - date - diff
25
+ */
26
+ export declare const DateOnly: (date: string | null) => string | null;
27
+ /**
28
+ * 不確定な日付データをフォーマットされた日付に変換される
29
+ * @param date 文字列、日付オブジェクト
30
+ * @returns 変換OKならDayjsフォーマット文字列、それ以外は空文字
31
+ */
32
+ export declare const DayjsFormat: (date: string | null | Date, f?: string, nullText?: string) => string;
33
+ /**
34
+ * 不確定な日付データをフォーマットされた日付に変換される
35
+ * @param date 文字列、日付オブジェクト
36
+ * @returns 変換OKならDayjsフォーマット文字列、それ以外はnull
37
+ */
38
+ export declare const DayjsFormatNullable: (date: string | null | Date, f?: string) => string | null;
39
+ export declare const DayjsSetLocal: (lang?: "ja" | "en") => void;
40
+ export declare const DayjsSetTimezone: (tz?: string) => void;
41
+ export declare const DayjsBetweenWhereQuery: (arg: {
42
+ from: string | null;
43
+ to: string | null;
44
+ }) => {
45
+ gte: Date;
46
+ lte: Date;
47
+ } | {
48
+ gte: Date;
49
+ lte?: undefined;
50
+ } | {
51
+ lte: Date;
52
+ gte?: undefined;
53
+ } | null;
@@ -0,0 +1,124 @@
1
+ import dayjs from "dayjs";
2
+ import utc from "dayjs/plugin/utc.js";
3
+ import timezone from "dayjs/plugin/timezone";
4
+ import advancedFormat from "dayjs/plugin/advancedFormat";
5
+ import ja from "dayjs/locale/ja.js";
6
+ import en from "dayjs/locale/en.js";
7
+ let init = false;
8
+ export const DayjsInit = () => {
9
+ if (init) return;
10
+ init = true;
11
+ dayjs.extend(utc);
12
+ dayjs.extend(timezone);
13
+ dayjs.extend(advancedFormat);
14
+ dayjs.extend(utc);
15
+ dayjs.extend(timezone);
16
+ dayjs.tz.setDefault(defaultTimezone);
17
+ dayjs.locale(ja);
18
+ };
19
+ export const defaultTimezone = "Asia/Tokyo";
20
+ export const Dayjs = (arg) => {
21
+ if (arg === null || arg === void 0) return dayjs();
22
+ return dayjs(arg);
23
+ };
24
+ export const DayjsNullable = (date) => {
25
+ try {
26
+ if (date === void 0) return dayjs();
27
+ if (date === null) return null;
28
+ if (date === "") return null;
29
+ if (/Date/.test(Object.prototype.toString.call(date)) === true) {
30
+ return dayjs(date);
31
+ }
32
+ const ret = dayjs(String(date).replace(/\//g, "-"));
33
+ if (ret.isValid() === false) {
34
+ return null;
35
+ }
36
+ return ret;
37
+ } catch {
38
+ return null;
39
+ }
40
+ };
41
+ export const DayjsDiff = (date, diff, unit) => {
42
+ try {
43
+ if (date === null) return null;
44
+ if (diff === null) return null;
45
+ if (date.isValid() === false) return null;
46
+ if (diff.isValid() === false) return null;
47
+ return date.diff(diff, unit);
48
+ } catch {
49
+ return null;
50
+ }
51
+ };
52
+ export const GetTimeShiftValue = (date) => {
53
+ if (date === null) return 0;
54
+ const format = `YYYY-MM-DD HH:mm`;
55
+ const a = date.format(format);
56
+ const b = date.tz(defaultTimezone).format(format);
57
+ const diff = DayjsDiff(Dayjs(a), Dayjs(b), "m");
58
+ return diff === null ? 0 : diff;
59
+ };
60
+ export const DateOnly = (date) => {
61
+ if (date === null) {
62
+ return null;
63
+ }
64
+ const d = Dayjs(date);
65
+ if (d === null) {
66
+ return null;
67
+ }
68
+ const shift = GetTimeShiftValue(d);
69
+ if (shift === 0) {
70
+ return d.startOf("day").format();
71
+ } else {
72
+ return d.startOf("day").add(shift, "minute").format();
73
+ }
74
+ };
75
+ export const DayjsFormat = (date, f = "YYYY-MM-DD HH:mm:ss.SSS", nullText = "") => {
76
+ try {
77
+ if (date === null) return nullText;
78
+ if (date === "") return nullText;
79
+ if (/Date/.test(Object.prototype.toString.call(date)) === true) {
80
+ return dayjs(date).format(f);
81
+ }
82
+ date = String(date).replace(/\//g, "-");
83
+ if (dayjs(date).isValid() === false) {
84
+ return nullText;
85
+ }
86
+ return dayjs(date).format(f);
87
+ } catch {
88
+ return nullText;
89
+ }
90
+ };
91
+ export const DayjsFormatNullable = (date, f = "YYYY-MM-DD HH:mm:ss.SSS") => {
92
+ const ret = DayjsFormat(date, f, "");
93
+ if (!ret) return null;
94
+ return ret;
95
+ };
96
+ export const DayjsSetLocal = (lang) => {
97
+ if (lang === "en") {
98
+ dayjs.locale(en);
99
+ } else {
100
+ dayjs.locale(ja);
101
+ }
102
+ };
103
+ export const DayjsSetTimezone = (tz = defaultTimezone) => {
104
+ dayjs.tz.setDefault(tz);
105
+ };
106
+ export const DayjsBetweenWhereQuery = (arg) => {
107
+ const dateFrom = DayjsNullable(arg.from);
108
+ const dateTo = DayjsNullable(arg.to);
109
+ if (dateFrom && dateTo) {
110
+ return {
111
+ gte: dateFrom.toDate(),
112
+ lte: dateTo.toDate()
113
+ };
114
+ } else if (dateFrom) {
115
+ return {
116
+ gte: dateFrom.toDate()
117
+ };
118
+ } else if (dateTo) {
119
+ return {
120
+ lte: dateTo.toDate()
121
+ };
122
+ }
123
+ return null;
124
+ };
@@ -0,0 +1,2 @@
1
+ export declare const Float: (i: any, digits?: number) => number;
2
+ export declare const FloatNullable: (i: any, digits?: number) => number | null;
@@ -0,0 +1,35 @@
1
+ import BigNumber from "bignumber.js";
2
+ export const Float = (i, digits = 0) => {
3
+ try {
4
+ const str = `${String(i).replace(/(\\|,|-$)/g, "")}`;
5
+ const num = new BigNumber(str);
6
+ if (Number.isNaN(num.toNumber())) {
7
+ return 0;
8
+ } else {
9
+ return num.dp(digits).toNumber();
10
+ }
11
+ } catch (error) {
12
+ console.error(`Float(${i})`, { i, digits, error });
13
+ return 0;
14
+ }
15
+ };
16
+ export const FloatNullable = (i, digits = 0) => {
17
+ try {
18
+ if (i === null) return null;
19
+ if (i === "") return null;
20
+ BigNumber.config({
21
+ ROUNDING_MODE: BigNumber.ROUND_DOWN
22
+ // 切り上げ
23
+ });
24
+ const str = `${String(i).replace(/(\\|,|-$)/g, "")}`;
25
+ const num = new BigNumber(str);
26
+ if (Number.isNaN(num.toNumber())) {
27
+ return null;
28
+ } else {
29
+ return num.dp(digits).toNumber();
30
+ }
31
+ } catch (error) {
32
+ console.error(`FloatNullable(${i})`, { i, digits, error });
33
+ return null;
34
+ }
35
+ };
@@ -0,0 +1,17 @@
1
+ import type { SelectItem } from "./select-item.js";
2
+ export type MultiLang = string | {
3
+ [key: string]: string;
4
+ };
5
+ export type KeyNumber = {
6
+ [key: string]: number;
7
+ };
8
+ export type KeyMultilang<T extends KeyNumber> = {
9
+ [key in T[keyof T]]: MultiLang;
10
+ };
11
+ export type CodeValues<T extends KeyNumber> = T[keyof T];
12
+ export declare const MapToSelectItem: <T extends KeyNumber>(keyNumber: T, keyMultilang: KeyMultilang<T>) => readonly SelectItem[];
13
+ export declare const ValueToTextByMap: <T extends undefined | string>(keyMultilang: KeyMultilang<KeyNumber>, code: number | null, lang?: T, fallBackLang?: string | undefined) => T extends string ? string : MultiLang;
14
+ export declare const SplitList: <T extends Array<any>>(arg: {
15
+ size: number;
16
+ list: T;
17
+ }) => T[];
@@ -0,0 +1,34 @@
1
+ import { GetTextByMultiLang } from "./multi-lang.js";
2
+ import { ObjectValues } from "./object.js";
3
+ export const MapToSelectItem = (keyNumber, keyMultilang) => {
4
+ return ObjectValues(keyNumber).map((id) => {
5
+ return { id, text: keyMultilang[id] };
6
+ });
7
+ };
8
+ export const ValueToTextByMap = (keyMultilang, code, lang, fallBackLang) => {
9
+ if (code === null) return "";
10
+ if (code in keyMultilang) {
11
+ if (lang === void 0) {
12
+ return keyMultilang[code];
13
+ } else if (lang in keyMultilang[code]) {
14
+ return GetTextByMultiLang(
15
+ keyMultilang[code],
16
+ lang,
17
+ fallBackLang
18
+ );
19
+ }
20
+ }
21
+ return "";
22
+ };
23
+ export const SplitList = (arg) => {
24
+ const { list, size } = arg;
25
+ if (size < 1) return [];
26
+ const listCount = list.length;
27
+ const rowCount = Math.ceil(listCount / size);
28
+ const ret = Array.from({ length: rowCount }).fill(null).map(() => []);
29
+ list.forEach((row, index) => {
30
+ const i = Math.floor(index / size);
31
+ ret[i].push(row);
32
+ });
33
+ return ret;
34
+ };
@@ -1,7 +1,7 @@
1
1
  export type MultiLang = string | {
2
2
  [key: string]: string;
3
3
  };
4
- export declare const GetTextByMultiLang: (text: MultiLang, lang: string | undefined, fallback?: string | undefined) => string;
4
+ export declare const GetTextByMultiLang: (text: MultiLang, lang: string, fallBackLang?: string | undefined) => string;
5
5
  /**
6
6
  * 複数のマルチ言語データを結合します
7
7
  * @returns MultiLangオブジェクト
@@ -1,38 +1,38 @@
1
1
  const isObject = (value) => {
2
2
  return value !== null && typeof value === "object";
3
3
  };
4
- export const GetTextByMultiLang = (text, lang, fallback = "ja") => {
5
- if (lang === void 0) {
6
- lang = "ja";
7
- }
8
- const textIsObject = isObject(text);
9
- if (!textIsObject) {
4
+ export const GetTextByMultiLang = (text, lang, fallBackLang) => {
5
+ if (!isObject(text)) {
10
6
  return String(text);
11
7
  }
12
8
  if (lang in text) {
13
9
  return text[lang];
14
- } else if (fallback in text) {
15
- console.error(`GetTextByMultiLang :: Language fallback [${lang} -> ${fallback}]`, text);
16
- return text.ja;
10
+ } else if (fallBackLang !== void 0 && fallBackLang in text) {
11
+ console.error(
12
+ `GetTextByMultiLang :: Language fallback [${lang} -> en]`,
13
+ text
14
+ );
15
+ return text[fallBackLang] || "";
17
16
  } else {
18
- console.error(`GetTextByMultiLang :: Language Error [${lang}]`, text);
17
+ console.error(
18
+ `GetTextByMultiLang :: Language Error [${lang} -> en]`,
19
+ text
20
+ );
19
21
  return JSON.stringify(text);
20
22
  }
21
23
  };
22
24
  export const JoinMultiLang = (list, seq = "\n") => {
23
- if (Array.isArray(list) === false)
24
- return "";
25
- if (list.length === 0)
26
- return "";
27
- const temp = list.map((row) => {
28
- return { type: isObject(row) ? "object" : "string", multiLang: row };
29
- });
25
+ if (Array.isArray(list) === false) return "";
26
+ if (list.length === 0) return "";
27
+ const temp = list.map(
28
+ (row) => {
29
+ return { type: isObject(row) ? "object" : "string", multiLang: row };
30
+ }
31
+ );
30
32
  const langList = temp.reduce((ret, row) => {
31
- if (row.type === "string")
32
- return ret;
33
+ if (row.type === "string") return ret;
33
34
  Object.keys(row.multiLang).forEach((key) => {
34
- if (!ret.includes(key))
35
- ret.push(key);
35
+ if (!ret.includes(key)) ret.push(key);
36
36
  });
37
37
  return ret;
38
38
  }, []);
@@ -54,16 +54,20 @@ export const JoinMultiLang = (list, seq = "\n") => {
54
54
  langList.forEach((lang) => {
55
55
  const langText = row.multiLang;
56
56
  if (lang in langText) {
57
- if (!langText[lang])
58
- return;
57
+ if (!langText[lang]) return;
59
58
  multiData[lang].push(langText[lang]);
60
59
  } else if ("ja" in langText) {
61
- if (!langText.ja)
62
- return;
60
+ if (!langText.ja) return;
63
61
  multiData[lang].push(langText.ja);
64
- console.error(`JoinMultiLang :: Language fallback [${lang} -> ja]`, row.multiLang);
62
+ console.error(
63
+ `JoinMultiLang :: Language fallback [${lang} -> ja]`,
64
+ row.multiLang
65
+ );
65
66
  } else {
66
- console.error(`JoinMultiLang :: Language Error [${lang} -> ja]`, row.multiLang);
67
+ console.error(
68
+ `JoinMultiLang :: Language Error [${lang} -> ja]`,
69
+ row.multiLang
70
+ );
67
71
  }
68
72
  });
69
73
  }
@@ -1,3 +1,5 @@
1
+ export declare const Int: (i: any) => number;
2
+ export declare const IntNullable: (i: any) => number | null;
1
3
  /**
2
4
  * 数値をカンマを挿入した文字列に変換する
3
5
  * @param num 数値
@@ -10,7 +12,3 @@ export declare const InsertComma: (num: number | string | null, digits?: number,
10
12
  * @returns カンマが挿入された文字列
11
13
  */
12
14
  export declare const InsertCommaK: (num: number | string | null) => string;
13
- export declare const Int: (i: any) => number;
14
- export declare const IntNullable: (i: any) => number | null;
15
- export declare const Float: (i: any, digits?: number) => number;
16
- export declare const FloatNullable: (i: any, digits?: number) => number | null;
@@ -1,36 +1,3 @@
1
- import BigNumber from "bignumber.js";
2
- export const InsertComma = (num, digits = 0, nullText = "0", comma = ",") => {
3
- if (num === null || num === "") {
4
- num = nullText;
5
- return num;
6
- }
7
- const numString = String(num).replace(/,/g, "");
8
- const delimitExp = /(\d)(?=(\d{3})+$)/g;
9
- const decimalDelimitExp = /(\d)(?=(\d{3})+(\.\d+))/g;
10
- let ret = "";
11
- if (numString.includes(".")) {
12
- ret = numString.replace(decimalDelimitExp, "$1" + comma);
13
- } else {
14
- ret = numString.replace(delimitExp, "$1" + comma);
15
- }
16
- if (digits === 0)
17
- return ret;
18
- const d = Int(numString) < 0 ? digits + 1 : digits;
19
- if (numString.includes(".")) {
20
- const m = ret.replace(/\d+\./g, "");
21
- if (m.length < d) {
22
- ret = `${ret}${Array(d + 1 - m.length).join("0")}`;
23
- }
24
- } else {
25
- ret = `${ret}.${Array(digits + 1).join("0")}`;
26
- }
27
- return ret;
28
- };
29
- export const InsertCommaK = (num) => {
30
- num = Int(num) * 100;
31
- num = InsertComma(num);
32
- return num.replace(/(.*)\d{2}$/, "$1");
33
- };
34
1
  export const Int = (i) => {
35
2
  try {
36
3
  const str = String(i).replace(/(\\|,|-$)/g, "");
@@ -47,10 +14,8 @@ export const Int = (i) => {
47
14
  };
48
15
  export const IntNullable = (i) => {
49
16
  try {
50
- if (i === null)
51
- return null;
52
- if (i === "")
53
- return null;
17
+ if (i === null) return null;
18
+ if (i === "") return null;
54
19
  const str = String(i).replace(/(\\|,|-$)/g, "");
55
20
  const num = Number.parseInt(str, 10);
56
21
  if (Number.isNaN(num)) {
@@ -63,39 +28,34 @@ export const IntNullable = (i) => {
63
28
  return null;
64
29
  }
65
30
  };
66
- export const Float = (i, digits = 0) => {
67
- try {
68
- const str = `${String(i).replace(/(\\|,|-$)/g, "")}`;
69
- const num = new BigNumber(str);
70
- if (Number.isNaN(num.toNumber())) {
71
- return 0;
72
- } else {
73
- return num.dp(digits).toNumber();
74
- }
75
- } catch (error) {
76
- console.error(`Float(${i})`, { i, digits, error });
77
- return 0;
31
+ export const InsertComma = (num, digits = 0, nullText = "0", comma = ",") => {
32
+ if (num === null || num === "") {
33
+ num = nullText;
34
+ return num;
78
35
  }
79
- };
80
- export const FloatNullable = (i, digits = 0) => {
81
- try {
82
- if (i === null)
83
- return null;
84
- if (i === "")
85
- return null;
86
- BigNumber.config({
87
- ROUNDING_MODE: BigNumber.ROUND_DOWN
88
- // 切り上げ
89
- });
90
- const str = `${String(i).replace(/(\\|,|-$)/g, "")}`;
91
- const num = new BigNumber(str);
92
- if (Number.isNaN(num.toNumber())) {
93
- return null;
94
- } else {
95
- return num.dp(digits).toNumber();
36
+ const numString = String(num).replace(/,/g, "");
37
+ const delimitExp = /(\d)(?=(\d{3})+$)/g;
38
+ const decimalDelimitExp = /(\d)(?=(\d{3})+(\.\d+))/g;
39
+ let ret = "";
40
+ if (numString.includes(".")) {
41
+ ret = numString.replace(decimalDelimitExp, "$1" + comma);
42
+ } else {
43
+ ret = numString.replace(delimitExp, "$1" + comma);
44
+ }
45
+ if (digits === 0) return ret;
46
+ const d = Int(numString) < 0 ? digits + 1 : digits;
47
+ if (numString.includes(".")) {
48
+ const m = ret.replace(/\d+\./g, "");
49
+ if (m.length < d) {
50
+ ret = `${ret}${Array(d + 1 - m.length).join("0")}`;
96
51
  }
97
- } catch (error) {
98
- console.error(`FloatNullable(${i})`, { i, digits, error });
99
- return null;
52
+ } else {
53
+ ret = `${ret}.${Array(digits + 1).join("0")}`;
100
54
  }
55
+ return ret;
56
+ };
57
+ export const InsertCommaK = (num) => {
58
+ num = Int(num) * 100;
59
+ num = InsertComma(num);
60
+ return num.replace(/(.*)\d{2}$/, "$1");
101
61
  };
@@ -0,0 +1,46 @@
1
+ export declare const GetMapValue: <T>(obj: T, key: keyof T | null) => T[keyof T] | null;
2
+ /**
3
+ * オブジェクトをJSON経由でコピーします
4
+ */
5
+ export declare const ObjectCopy: <T>(obj: T) => T;
6
+ /**
7
+ * オブジェクトのキー配列を返します
8
+ */
9
+ export declare const ObjectKeys: <T>(obj: T) => (keyof T)[];
10
+ /**
11
+ * オブジェクトのキー配列を返します
12
+ */
13
+ export declare const ObjectValues: <T>(obj: T) => T[keyof T][];
14
+ /**
15
+ * オブジェクトのキー配列を返します
16
+ */
17
+ export declare const ObjectKeyToMap: <T, T2>(obj: T, initData: T2) => { [x in keyof T]: T2; };
18
+ /**
19
+ * オブジェクトのキー配列を返します
20
+ */
21
+ export declare const ObjectListKeyMap: <T>(obj: T[], key: string) => {
22
+ [x: string]: T;
23
+ };
24
+ /**
25
+ * オブジェクトの比較用
26
+ * @param a 比較オブジェクト
27
+ * @param b 比較オブジェクト
28
+ * @returns オブジェクトが異なる場合[ false ]を返す
29
+ */
30
+ export declare const ObjectCompare: (a: any, b: any) => boolean;
31
+ /**
32
+ * 配列の並び替え
33
+ * @param baseList 並び替えをするリスト
34
+ * @param idList 並び替えの基準となるリスト
35
+ * @returns 並び替え結果
36
+ */
37
+ export declare const ListIdSort: (baseList: {
38
+ id: number;
39
+ [key: string]: any;
40
+ }[], idList: number[]) => number[];
41
+ /**
42
+ * オブジェクトの階層をフラットにします。
43
+ */
44
+ export declare const FlatObj: (obj: any, flatObj?: any, prefix?: string) => {
45
+ [key: string]: any;
46
+ };