@niyamulahsan/create-deskapp 0.0.0-stage → 1.2.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 (132) hide show
  1. package/README.md +33 -2
  2. package/bin/create.js +136 -0
  3. package/package.json +14 -4
  4. package/template/.env +13 -0
  5. package/template/.env.example +13 -0
  6. package/template/.vscode/extensions.json +6 -0
  7. package/template/.vscode/settings.json +37 -0
  8. package/template/LICENSE +21 -0
  9. package/template/README.md +29 -0
  10. package/template/biome.json +99 -0
  11. package/template/drizzle.config.ts +32 -0
  12. package/template/gitignore-stub +19 -0
  13. package/template/package.json +111 -0
  14. package/template/scripts/build-electron.mjs +55 -0
  15. package/template/scripts/dev-electron.mjs +53 -0
  16. package/template/scripts/installer.nsh +14 -0
  17. package/template/src/config/app.ts +24 -0
  18. package/template/src/core/api/bindings.generated.ts +23 -0
  19. package/template/src/core/api/generate.manifest.ts +86 -0
  20. package/template/src/core/api/registry.ts +48 -0
  21. package/template/src/core/config.ts +99 -0
  22. package/template/src/core/database/aggregate.ts +85 -0
  23. package/template/src/core/database/config.ts +48 -0
  24. package/template/src/core/database/connection.ts +114 -0
  25. package/template/src/core/database/migrate-hooks.ts +84 -0
  26. package/template/src/core/database/paginate.ts +224 -0
  27. package/template/src/core/database/reset.ts +19 -0
  28. package/template/src/core/database/seed.ts +169 -0
  29. package/template/src/core/database/status.ts +32 -0
  30. package/template/src/core/env.ts +106 -0
  31. package/template/src/core/facade.ts +59 -0
  32. package/template/src/core/maker/db/fresh.ts +8 -0
  33. package/template/src/core/maker/db/generate.ts +11 -0
  34. package/template/src/core/maker/db/helpers.ts +96 -0
  35. package/template/src/core/maker/db/migrate.ts +36 -0
  36. package/template/src/core/maker/db/mod.ts +63 -0
  37. package/template/src/core/maker/db/module-migrate.ts +53 -0
  38. package/template/src/core/maker/db/push.ts +21 -0
  39. package/template/src/core/maker/db/reset.ts +6 -0
  40. package/template/src/core/maker/db/seed.ts +7 -0
  41. package/template/src/core/maker/db/status.ts +6 -0
  42. package/template/src/core/maker/help.ts +66 -0
  43. package/template/src/core/maker/make/controller.ts +27 -0
  44. package/template/src/core/maker/make/helpers.ts +93 -0
  45. package/template/src/core/maker/make/mod.ts +68 -0
  46. package/template/src/core/maker/make/model.ts +14 -0
  47. package/template/src/core/maker/make/module.ts +62 -0
  48. package/template/src/core/maker/make/seeder.ts +21 -0
  49. package/template/src/core/maker/make/test.ts +30 -0
  50. package/template/src/core/maker/mod.ts +83 -0
  51. package/template/src/core/maker/run/mod.ts +112 -0
  52. package/template/src/core/maker/stub.ts +24 -0
  53. package/template/src/core/maker/stubs/controller/controller.controller.stub +55 -0
  54. package/template/src/core/maker/stubs/controller/controller.schema.stub +13 -0
  55. package/template/src/core/maker/stubs/model/model.stub +8 -0
  56. package/template/src/core/maker/stubs/seeder/seeder.stub +16 -0
  57. package/template/src/core/maker/stubs/test/test.stub +7 -0
  58. package/template/src/core/maker/sync-config.ts +94 -0
  59. package/template/src/core/utils/password.ts +27 -0
  60. package/template/src/core/utils/playwright.ts +121 -0
  61. package/template/src/core/utils/queue.ts +59 -0
  62. package/template/src/core/utils/scheduler.ts +70 -0
  63. package/template/src/core/utils/storage.ts +599 -0
  64. package/template/src/core/utils/validation.ts +35 -0
  65. package/template/src/database/migrations/sqlite/meta/_journal.json +1 -0
  66. package/template/src/database/schema.ts +6 -0
  67. package/template/src/icons/apple-touch-icon.png +0 -0
  68. package/template/src/icons/deskapp.png +0 -0
  69. package/template/src/icons/favicon-96x96.png +0 -0
  70. package/template/src/icons/favicon.ico +0 -0
  71. package/template/src/icons/favicon.svg +1 -0
  72. package/template/src/icons/site.webmanifest +21 -0
  73. package/template/src/icons/tray.png +0 -0
  74. package/template/src/icons/web-app-manifest-192x192.png +0 -0
  75. package/template/src/icons/web-app-manifest-512x512.png +0 -0
  76. package/template/src/main.ts +116 -0
  77. package/template/src/modules/app/controllers/demo.controller.ts +118 -0
  78. package/template/src/modules/app/controllers/net.controller.ts +48 -0
  79. package/template/src/modules/app/controllers/playwright.controller.ts +140 -0
  80. package/template/src/modules/app/controllers/storage.controller.ts +229 -0
  81. package/template/src/modules/app/controllers/window.controller.ts +107 -0
  82. package/template/src/preload.ts +35 -0
  83. package/template/src/storage/.gitkeep +1 -0
  84. package/template/src/storage/app/private/.gitkeep +1 -0
  85. package/template/src/storage/app/private/samples/.gitkeep +1 -0
  86. package/template/src/storage/app/private/samples/state.json +5 -0
  87. package/template/src/storage/app/private/uploads/.gitkeep +1 -0
  88. package/template/src/storage/app/public/.gitkeep +1 -0
  89. package/template/src/storage/app/tmp/generated/.gitkeep +1 -0
  90. package/template/src/storage/logs/.gitkeep +0 -0
  91. package/template/src/storage/logs/app.log +0 -0
  92. package/template/src/storage/logs/fatal.log +0 -0
  93. package/template/src/ui/.vscode/extensions.json +3 -0
  94. package/template/src/ui/index.html +14 -0
  95. package/template/src/ui/public/icons.svg +24 -0
  96. package/template/src/ui/src/App.vue +3 -0
  97. package/template/src/ui/src/app.ts +23 -0
  98. package/template/src/ui/src/assets/fonts/public-sans/public-sans-latin-ext.woff2 +0 -0
  99. package/template/src/ui/src/assets/fonts/public-sans/public-sans-latin.woff2 +0 -0
  100. package/template/src/ui/src/assets/images/deskapp.png +0 -0
  101. package/template/src/ui/src/assets/images/favicon/favicon.ico +0 -0
  102. package/template/src/ui/src/assets/scss/custom.scss +186 -0
  103. package/template/src/ui/src/bindings.d.ts +16 -0
  104. package/template/src/ui/src/components/Button.vue +32 -0
  105. package/template/src/ui/src/components/Checkbox.vue +29 -0
  106. package/template/src/ui/src/components/Input.vue +227 -0
  107. package/template/src/ui/src/components/Modal.vue +55 -0
  108. package/template/src/ui/src/components/Spinner.vue +42 -0
  109. package/template/src/ui/src/components/Switch.vue +65 -0
  110. package/template/src/ui/src/components/TextArea.vue +121 -0
  111. package/template/src/ui/src/components/Toast.vue +56 -0
  112. package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +98 -0
  113. package/template/src/ui/src/components/datatable/Pagination.vue +125 -0
  114. package/template/src/ui/src/components/datatable/SelectOpption.vue +35 -0
  115. package/template/src/ui/src/components/datatable/index.vue +258 -0
  116. package/template/src/ui/src/env.d.ts +13 -0
  117. package/template/src/ui/src/global.d.ts +35 -0
  118. package/template/src/ui/src/helpers/nformatter.ts +10 -0
  119. package/template/src/ui/src/pages/dashboard/index.vue +687 -0
  120. package/template/src/ui/src/plugins/gum.ts +549 -0
  121. package/template/src/ui/src/plugins/gum.ts.bak +683 -0
  122. package/template/src/ui/src/plugins/pulse.ts +148 -0
  123. package/template/src/ui/src/router/index.ts +25 -0
  124. package/template/src/ui/src/stores/example.ts +27 -0
  125. package/template/src/ui/tsconfig.json +15 -0
  126. package/template/src/ui/vite.config.ts +38 -0
  127. package/template/src/window/config.ts +71 -0
  128. package/template/src/window/dialogs.ts +67 -0
  129. package/template/src/window/manager.ts +139 -0
  130. package/template/src/window/native.ts +215 -0
  131. package/template/tsconfig.json +22 -0
  132. package/template/vitest.config.ts +34 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * bindings.d.ts - types the Electron `bindings` global exposed by preload.
3
+ *
4
+ * `bindings` is a Proxy: any `bindings.<name>` access yields a function that
5
+ * invokes `deskapp:<name>` in the main process via IPC and returns a Promise.
6
+ * Backend controllers register handlers under `<module>.<controller>.<handler>`
7
+ * (see src/core/api/registry.ts).
8
+ */
9
+
10
+ export interface Bindings {
11
+ [name: string]: (...args: unknown[]) => Promise<unknown>;
12
+ }
13
+
14
+ declare global {
15
+ const bindings: Bindings;
16
+ }
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <button class="shadow-none" :type="props.type" v-bind="$attrs">
3
+ <slot v-if="hasDefaultSlot"></slot>
4
+ <template v-else>
5
+ <span v-if="props.label" class="text-capitalize" :class="{ 'me-1': props.icon }">
6
+ {{ props.label }}
7
+ </span>
8
+ <span v-if="props.icon"><i :class="props.icon"></i></span>
9
+ </template>
10
+ </button>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed, useSlots } from "vue";
15
+
16
+ interface ButtonProps {
17
+ label?: string;
18
+ icon?: string;
19
+ type?: "button" | "submit" | "reset";
20
+ }
21
+
22
+ defineOptions({ name: "Button", inheritAttrs: false });
23
+
24
+ const slots = useSlots();
25
+ const props = withDefaults(defineProps<ButtonProps>(), {
26
+ type: "button"
27
+ });
28
+
29
+ const hasDefaultSlot = computed(() => Boolean(slots.default?.().length));
30
+ </script>
31
+
32
+ <style lang="scss" scoped></style>
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <div class="form-check mb-0" :class="props.topclass">
3
+ <input
4
+ :id="String(props.id)"
5
+ v-model="model"
6
+ class="form-check-input shadow-none border-secondary"
7
+ type="checkbox"
8
+ v-bind="$attrs" />
9
+ <label v-if="props.label" class="form-check-label" :for="String(props.id)">{{ props.label }}</label>
10
+ </div>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ defineOptions({ name: "Checkbox", inheritAttrs: false });
15
+
16
+ interface CheckboxProps {
17
+ id?: string | number;
18
+ label?: string;
19
+ topclass?: string;
20
+ }
21
+
22
+ const props = defineProps<CheckboxProps>();
23
+
24
+ type CheckboxModel = boolean | Array<string | number>;
25
+
26
+ const model = defineModel<CheckboxModel>({ default: false });
27
+ </script>
28
+
29
+ <style lang="scss" scoped></style>
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <div :class="topclass">
3
+ <div class="position-relative">
4
+ <label
5
+ :for="inputId"
6
+ class="d-flex align-items-center mb-1"
7
+ :class="{ 'd-none': !inputLabel }">
8
+ <div class="position-relative">
9
+ <span class="text-capitalize" v-html="inputLabel"></span>
10
+ <span
11
+ class="position-absolute text-danger rounded-circle bg-danger must"
12
+ :class="{ 'd-none': !props.must }"></span>
13
+ </div>
14
+ <div
15
+ class="text-end ms-auto text-primary fw-semibold"
16
+ :class="{ 'd-none': !props.hood }"
17
+ style="font-size: 12px; margin-top: 0.15rem"
18
+ v-html="hoodHtml"></div>
19
+ </label>
20
+ <input
21
+ ref="inputRef"
22
+ class="form-control"
23
+ :value="props.modelValue"
24
+ :maxlength="maxLengthAttr"
25
+ :readonly="props.readonly"
26
+ v-bind="$attrs"
27
+ :autocomplete="inputAutocomplete"
28
+ @input="updateModel" />
29
+ <div
30
+ class="position-absolute bottom-0 end-0 pe-1 text-secondary max"
31
+ :class="{ 'd-none': !max }">
32
+ {{ maxCounter }}
33
+ </div>
34
+ </div>
35
+ <div
36
+ :id="`${inputId}Help`"
37
+ class="form-text mt-1 text-danger"
38
+ :class="{ 'd-none': !props.err }">
39
+ {{ props.err }}
40
+ </div>
41
+ </div>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { computed, nextTick, onMounted, ref, useAttrs } from "vue";
46
+
47
+ const $attrs = useAttrs();
48
+ const inputRef = ref<HTMLInputElement | null>(null);
49
+ type InputCategory =
50
+ | "number"
51
+ | "decimal"
52
+ | "+decimal-"
53
+ | "mobile"
54
+ | "tax-period"
55
+ | "bin"
56
+ | "challan-number"
57
+ | string;
58
+
59
+ interface InputProps {
60
+ focus?: boolean;
61
+ must?: boolean;
62
+ err?: string | boolean;
63
+ modelValue?: string | number;
64
+ category?: InputCategory;
65
+ hood?: string | boolean | number;
66
+ readonly?: boolean;
67
+ }
68
+
69
+ const props = withDefaults(defineProps<InputProps>(), {
70
+ err: false,
71
+ modelValue: ""
72
+ });
73
+
74
+ const topclass = computed(() => ($attrs.topclass as string | undefined) || "mb-2");
75
+ const inputId = computed(() => ($attrs.id as string | undefined) || "");
76
+ const inputLabel = computed(() => ($attrs.label as string | undefined) || "");
77
+ const inputType = computed(() => ($attrs.type as string | undefined) || "text");
78
+
79
+ const max = computed<number | null>(() => {
80
+ const raw = $attrs.maxlength as string | number | undefined;
81
+ return raw != null ? Number(raw) : null;
82
+ });
83
+
84
+ const inputAutocomplete = computed(() => {
85
+ const attrAutocomplete = $attrs.autocomplete as string | undefined;
86
+ if (attrAutocomplete) {
87
+ return attrAutocomplete;
88
+ }
89
+ return ["number", "decimal"].includes(props.category ?? "") ? "off" : "on";
90
+ });
91
+
92
+ const maxLengthAttr = computed<number | undefined>(() => max.value ?? undefined);
93
+
94
+ const hoodHtml = computed(() =>
95
+ props.hood === false || props.hood == null ? "" : String(props.hood)
96
+ );
97
+
98
+ const maxCounter = computed(() => {
99
+ if (max.value == null) {
100
+ return "";
101
+ }
102
+
103
+ return max.value - String(props.modelValue).length;
104
+ });
105
+
106
+ const emit = defineEmits<(event: "update:modelValue", value: string | number) => void>();
107
+ const updateModel = (e: Event) => {
108
+ const target = e.target as HTMLInputElement;
109
+
110
+ if (props.category === "number") {
111
+ emit("update:modelValue", (target.value = target.value.replace(/[^\d]/gi, "")));
112
+ } else if (props.category === "decimal") {
113
+ let val = target.value;
114
+
115
+ // Remove everything except digits, decimal point, and minus sign
116
+ val = val.replace(/[^0-9.]/g, "");
117
+
118
+ // Allow only one decimal point
119
+ const parts = val.split(".");
120
+ if (parts.length > 2) {
121
+ val = `${parts[0]}.${parts.slice(1).join("")}`;
122
+ }
123
+
124
+ emit("update:modelValue", (target.value = val));
125
+ } else if (props.category === "+decimal-") {
126
+ let val = target.value;
127
+
128
+ // Remove everything except digits, decimal point, and minus sign
129
+ val = val.replace(/[^0-9.-]/g, ""); // if need minus sign
130
+
131
+ // Move minus sign to the front if it exists anywhere
132
+ const isNegative = val.includes("-");
133
+ val = val.replace(/-/g, ""); // remove all minus signs
134
+ if (isNegative) {
135
+ val = `-${val}`;
136
+ }
137
+
138
+ // Allow only one decimal point
139
+ const parts = val.split(".");
140
+ if (parts.length > 2) {
141
+ val = `${parts[0]}.${parts.slice(1).join("")}`;
142
+ }
143
+
144
+ emit("update:modelValue", (target.value = val));
145
+ } else if (props.category === "mobile") {
146
+ let digits = target.value.replace(/[^\d]/g, ""); // only digits
147
+ let val = digits;
148
+ if (target.value.includes("+")) {
149
+ val = `+${digits}`;
150
+ }
151
+ emit("update:modelValue", (target.value = val));
152
+ } else if (props.category === "tax-period") {
153
+ let val = target.value.replace(/[^\d-]/g, ""); // Only numbers and hyphen
154
+ val = val.replace(/-/g, ""); // Remove all hyphens
155
+ val = val.slice(0, 6); // Only 6 digits (YYYYMM)
156
+
157
+ if (val.length > 4) {
158
+ let year = val.slice(0, 4);
159
+ let month = val.slice(4, 6);
160
+
161
+ // Only correct if both month digits entered
162
+ if (month.length === 2) {
163
+ let m = parseInt(month, 10);
164
+ // Clamp month between 1 and 12
165
+ if (m < 1) m = 1;
166
+ if (m > 12) m = 12;
167
+ // Always pad to 2 digits
168
+ month = m.toString().padStart(2, "0");
169
+ }
170
+
171
+ val = `${year}-${month}`;
172
+ }
173
+
174
+ emit("update:modelValue", (target.value = val));
175
+ } else if (props.category === "bin") {
176
+ let digits = target.value.replace(/[^\d]/g, "");
177
+ digits = digits.slice(0, 14);
178
+ let formatted = digits;
179
+ if (digits.length > 9) {
180
+ formatted = `${digits.slice(0, 9)}-${digits.slice(9, 14)}`;
181
+ }
182
+ emit("update:modelValue", (target.value = formatted));
183
+ } else if (props.category === 'echallan-number') {
184
+ // Format: V + 9 digits (V000517226)
185
+ let raw = (target.value || '').toUpperCase();
186
+
187
+ // keep only digits, but allow V (we’ll force V at start)
188
+ let digits = raw.replace(/[^\d]/g, '').slice(0, 9);
189
+
190
+ // always prefix V
191
+ let formatted = `V ${digits}`;
192
+
193
+ emit('update:modelValue', (target.value = formatted));
194
+
195
+ } else if (props.category === "challan-number") {
196
+ let digits = target.value.replace(/[^\d]/g, "");
197
+ digits = digits.slice(0, 16);
198
+ let formatted = digits;
199
+ if (digits.length > 4) {
200
+ formatted = `${digits.slice(0, 4)}-${digits.slice(4, 16)}`;
201
+ }
202
+ emit("update:modelValue", (target.value = formatted));
203
+ } else {
204
+ emit("update:modelValue", target.value);
205
+ }
206
+ };
207
+
208
+ onMounted(() => {
209
+ const shouldFocus = props.focus !== false && props.focus !== undefined;
210
+ if (!shouldFocus) return;
211
+
212
+ nextTick(() => inputRef.value?.focus());
213
+ });
214
+ </script>
215
+
216
+ <style lang="scss" scoped>
217
+ .must {
218
+ width: 4px;
219
+ height: 4px;
220
+ margin-left: 2px;
221
+ margin-top: 5px;
222
+ }
223
+
224
+ .max {
225
+ font-size: 0.6rem;
226
+ }
227
+ </style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <Teleport to="#modal-show">
3
+ <div :id="props.id" ref="modal" class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
4
+ :aria-labelledby="`${props.id}Label`">
5
+ <div :class="`modal-dialog modal-dialog-centered modal-dialog-scrollable modal-${props.size}`">
6
+ <div class="modal-content border">
7
+ <div class="modal-header">
8
+ <div class="d-flex w-100 justify-content-between align-items-center">
9
+ <h5 id="modalScrollableTitle" class="modal-title me-3">{{ props.title }}</h5>
10
+ <button ref="closeButton" type="button" class="btn-close shadow-none" data-bs-dismiss="modal"
11
+ aria-label="Close"></button>
12
+ <slot name="modal-header-extra"></slot>
13
+ </div>
14
+ </div>
15
+ <div class="modal-body">
16
+ <slot name="modalbody"></slot>
17
+ </div>
18
+ <div class="modal-footer py-2">
19
+ <slot name="modalfooter"></slot>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </Teleport>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { ref } from "vue";
29
+
30
+ type ModalSize = "sm" | "md" | "lg" | "xl" | string;
31
+
32
+ interface ModalProps {
33
+ id: string;
34
+ title?: string;
35
+ size?: ModalSize;
36
+ }
37
+
38
+ defineOptions({ name: "Modal", inheritAttrs: false });
39
+
40
+ const props = withDefaults(defineProps<ModalProps>(), {
41
+ title: "",
42
+ size: "md"
43
+ });
44
+
45
+ const modal = ref<HTMLElement | null>(null);
46
+ const closeButton = ref<HTMLButtonElement | null>(null);
47
+
48
+ const close = () => {
49
+ closeButton.value?.click();
50
+ };
51
+
52
+ defineExpose({ close });
53
+ </script>
54
+
55
+ <style lang="scss" scoped></style>
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div class="h-100" v-bind="$attrs">
3
+ <div class="h-100 d-flex align-items-center justify-content-center">
4
+ <div class="spinner-grow" :style="spinnerStyle" role="status">
5
+ <span class="visually-hidden">Loading...</span>
6
+ </div>
7
+ <div class="fw-bold ms-2">
8
+ <span v-if="props.text" :class="props.textsize" :style="textStyle">
9
+ {{ props.text }}
10
+ </span>
11
+ <span v-else>Loading...</span>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import { computed } from "vue";
19
+
20
+ defineOptions({ name: "Spinner", inheritAttrs: false });
21
+
22
+ interface SpinnerProps {
23
+ size?: string;
24
+ text?: string;
25
+ textsize?: string;
26
+ }
27
+
28
+ const props = withDefaults(defineProps<SpinnerProps>(), {
29
+ size: "3rem",
30
+ text: "",
31
+ textsize: ""
32
+ });
33
+
34
+ const spinnerStyle = computed(() => ({
35
+ width: props.size,
36
+ height: props.size
37
+ }));
38
+
39
+ const textStyle = computed(() => ({
40
+ fontSize: props.textsize || undefined
41
+ }));
42
+ </script>
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <div :class="wrapperClass">
3
+ <label :class="props.vertical ? 'form-check-label d-block' : 'd-none'">
4
+ <span v-html="statusHtml"></span>
5
+ </label>
6
+ <div class="form-check form-switch d-inline-block">
7
+ <input
8
+ class="form-check-input shadow-none border-primary"
9
+ type="checkbox"
10
+ role="switch"
11
+ :checked="isChecked"
12
+ v-bind="$attrs" />
13
+ <label :class="props.vertical ? 'd-none' : 'form-check-label'">
14
+ <span v-html="statusHtml"></span>
15
+ </label>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script setup lang="ts">
21
+ import { computed, useAttrs } from "vue";
22
+
23
+ defineOptions({ name: "Switch", inheritAttrs: false });
24
+
25
+ interface SwitchProps {
26
+ modelValue?: string | number | boolean;
27
+ value?: unknown[] | Record<string, unknown> | string | number | boolean;
28
+ vertical?: boolean;
29
+ checked?: boolean | number;
30
+ }
31
+
32
+ const $attrs = useAttrs();
33
+ const props = defineProps<SwitchProps>();
34
+
35
+ const textLabel = computed(() => ($attrs.text as string | undefined) || "");
36
+ const blankLabel = computed(() => ($attrs.blank as string | undefined) || "");
37
+ const topclass = computed(() => ($attrs.topclass as string | undefined) || "");
38
+
39
+ const isChecked = computed(() => Boolean(props.checked));
40
+
41
+ const wrapperClass = computed(() => props.vertical ? `text-center ${topclass.value}`.trim() : "");
42
+
43
+ const statusHtml = computed(() => {
44
+ if (isChecked.value) {
45
+ return `<div class='d-flex justify-content-center'><span>${textLabel.value}</span><div class='rounded-circle bg-success indicator'></div></div>`;
46
+ }
47
+
48
+ return `<div class='d-flex justify-content-center'><span>${blankLabel.value}</span><div class='rounded-circle bg-danger indicator'></div></div>`;
49
+ });
50
+ </script>
51
+
52
+ <style lang="scss">
53
+ .indicator {
54
+ width: 4px;
55
+ height: 4px;
56
+ margin-left: 2px;
57
+ margin-top: 5px;
58
+ }
59
+ </style>
60
+ <style lang="scss" scoped>
61
+ label,
62
+ input {
63
+ cursor: pointer;
64
+ }
65
+ </style>
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <div :class="wrapperClass">
3
+ <div class="position-relative">
4
+ <div class="position-relative mb-1">
5
+ <span class="text-capitalize" v-html="inputLabel"></span>
6
+ <span
7
+ class="position-absolute text-danger rounded-circle bg-danger must"
8
+ :class="{ 'd-none': !props.must }"></span>
9
+ </div>
10
+ <div class="form-floating h-100">
11
+ <textarea
12
+ :value="props.modelValue"
13
+ class="form-control mb-0 h-100"
14
+ :maxlength="maxLengthAttr"
15
+ :aria-describedby="`${inputId}Help`"
16
+ v-bind="$attrs"
17
+ rows="3"
18
+ @input="updateModel">
19
+ </textarea>
20
+ <label
21
+ :for="inputId"
22
+ class="d-block placeholder-label border-0"
23
+ :class="{ 'd-none': !placeholderText }">
24
+ {{ placeholderText }}
25
+ </label>
26
+ </div>
27
+ <label
28
+ class="position-absolute end-0 pe-1 text-secondary max"
29
+ :class="{ 'd-none': !max }"
30
+ style="top: 28px">
31
+ {{ maxCounter }}
32
+ </label>
33
+ </div>
34
+ <div :id="`${inputId}Help`" class="form-text text-danger" :class="{ 'd-none': !props.err }">
35
+ {{ props.err }}
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ import { computed, nextTick, onMounted, useAttrs } from "vue";
42
+
43
+ defineOptions({ name: "TextArea", inheritAttrs: false });
44
+
45
+ const $attrs = useAttrs();
46
+ interface TextAreaProps {
47
+ focus?: boolean;
48
+ must?: boolean;
49
+ err?: string | boolean;
50
+ modelValue?: string | number;
51
+ }
52
+
53
+ const props = withDefaults(defineProps<TextAreaProps>(), {
54
+ modelValue: ""
55
+ });
56
+
57
+ const inputId = computed(() => ($attrs.id as string | undefined) || "");
58
+ const inputLabel = computed(() => ($attrs.label as string | undefined) || "");
59
+ const placeholderText = computed(() => ($attrs.placeholder as string | undefined) || "");
60
+ const topclass = computed(() => ($attrs.topclass as string | undefined) || "");
61
+
62
+ const wrapperClass = computed(() =>
63
+ topclass.value ? `${topclass.value} position-relative` : "mb-2"
64
+ );
65
+
66
+ const max = computed<number | null>(() => {
67
+ const raw = $attrs.maxlength as string | number | undefined;
68
+ return raw != null ? Number(raw) : null;
69
+ });
70
+
71
+ const maxLengthAttr = computed<number | undefined>(() => max.value ?? undefined);
72
+ const maxCounter = computed(() =>
73
+ max.value == null ? "" : max.value - String(props.modelValue).length
74
+ );
75
+
76
+ const emit = defineEmits<(event: "update:modelValue", value: string) => void>();
77
+ const updateModel = (e: Event) => {
78
+ const target = e.target as HTMLTextAreaElement;
79
+ emit("update:modelValue", target.value);
80
+ };
81
+
82
+ onMounted(() => {
83
+ if (!props.focus || !inputId.value) {
84
+ return;
85
+ }
86
+
87
+ nextTick(() => {
88
+ const textarea = document.querySelector(`#${inputId.value}`) as HTMLTextAreaElement | null;
89
+ textarea?.focus();
90
+ });
91
+ });
92
+ </script>
93
+
94
+ <style lang="scss" scoped>
95
+ .form-floating {
96
+ label {
97
+ top: -1px;
98
+ left: 1px;
99
+ }
100
+
101
+ textarea:focus+label,
102
+ textarea:not(:placeholder-shown)+label {
103
+ top: -6px;
104
+ }
105
+ }
106
+
107
+ .placeholder-label {
108
+ color: #cccccc !important;
109
+ }
110
+
111
+ .must {
112
+ width: 4px;
113
+ height: 4px;
114
+ margin-left: 2px;
115
+ margin-top: 5px;
116
+ }
117
+
118
+ .max {
119
+ font-size: 0.6rem;
120
+ }
121
+ </style>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <Teleport to="#toast-show">
3
+ <div
4
+ ref="notify"
5
+ class="toast position-fixed"
6
+ role="alert"
7
+ aria-live="assertive"
8
+ aria-atomic="true"
9
+ style="z-index: 1000000; top: 10px; right: 23px"
10
+ data-bs-delay="2000">
11
+ <div :class="`text-bg-${bgcolor} align-items-center rounded-1 shadow-sm`">
12
+ <div class="d-flex">
13
+ <div class="toast-body">
14
+ {{ message }}
15
+ </div>
16
+ <button
17
+ type="button"
18
+ class="btn-close btn-close-white me-2 m-auto"
19
+ data-bs-dismiss="toast"
20
+ aria-label="Close"></button>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </Teleport>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import Toast from "bootstrap/js/dist/toast.js";
29
+ import { ref } from "vue";
30
+
31
+ defineOptions({ name: "Toast", inheritAttrs: false });
32
+
33
+ interface ToastProps {
34
+ icon?: string;
35
+ }
36
+
37
+ defineProps<ToastProps>();
38
+
39
+ const notify = ref<HTMLElement | null>(null);
40
+ const message = ref("");
41
+ const bgcolor = ref("primary");
42
+
43
+ const toastme = (msg: string, bg: string) => {
44
+ message.value = msg;
45
+ bgcolor.value = bg;
46
+ if (!notify.value) {
47
+ return;
48
+ }
49
+ const toast = Toast.getOrCreateInstance(notify.value);
50
+ toast.show();
51
+ };
52
+
53
+ defineExpose({ toastme });
54
+ </script>
55
+
56
+ <style lang="scss" scoped></style>