@ramathibodi/nuxt-commons 4.0.10 → 4.0.12
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 +8 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +8 -3
- package/dist/runtime/components/document/TemplateBuilder.vue +22 -42
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +8 -3
- package/dist/runtime/components/form/ActionPad.vue +1 -0
- package/dist/runtime/components/form/Birthdate.d.vue.ts +3 -3
- package/dist/runtime/components/form/Birthdate.vue.d.ts +3 -3
- package/dist/runtime/components/form/Date.vue +11 -6
- package/dist/runtime/components/form/Dialog.d.vue.ts +1 -5
- package/dist/runtime/components/form/Dialog.vue +1 -0
- package/dist/runtime/components/form/Dialog.vue.d.ts +1 -5
- package/dist/runtime/components/form/EditPad.vue +1 -0
- package/dist/runtime/components/form/Pad.d.vue.ts +24 -0
- package/dist/runtime/components/form/Pad.vue +12 -7
- package/dist/runtime/components/form/Pad.vue.d.ts +24 -0
- package/dist/runtime/components/form/Time.vue +10 -5
- package/dist/runtime/components/form/images/Edit.d.vue.ts +1 -3
- package/dist/runtime/components/form/images/Edit.vue.d.ts +1 -3
- package/dist/runtime/components/model/AutoRefreshChip.d.vue.ts +16 -0
- package/dist/runtime/components/model/AutoRefreshChip.vue +34 -0
- package/dist/runtime/components/model/AutoRefreshChip.vue.d.ts +16 -0
- package/dist/runtime/components/model/Table.d.vue.ts +91 -61
- package/dist/runtime/components/model/Table.vue +24 -5
- package/dist/runtime/components/model/Table.vue.d.ts +91 -61
- package/dist/runtime/components/model/iterator.d.vue.ts +103 -71
- package/dist/runtime/components/model/iterator.vue +24 -5
- package/dist/runtime/components/model/iterator.vue.d.ts +103 -71
- package/dist/runtime/composables/apiModel.d.ts +2 -2
- package/dist/runtime/composables/apiModel.js +3 -3
- package/dist/runtime/composables/autoRefresh.d.ts +42 -0
- package/dist/runtime/composables/autoRefresh.js +57 -0
- package/dist/runtime/composables/document/template.js +10 -1
- package/dist/runtime/composables/document/templateInputTypes.d.ts +228 -0
- package/dist/runtime/composables/document/templateInputTypes.js +128 -0
- package/dist/runtime/composables/graphqlModel.d.ts +2 -2
- package/dist/runtime/composables/graphqlModel.js +3 -3
- package/dist/runtime/composables/modelAutoRefresh.d.ts +29 -0
- package/dist/runtime/composables/modelAutoRefresh.js +16 -0
- package/dist/runtime/composables/utils/validation.d.ts +4 -0
- package/dist/runtime/composables/utils/validation.js +2 -0
- package/package.json +4 -2
- package/scripts/generate-ai-summary.mjs +88 -0
- package/scripts/scaffold-playground-pages.mjs +207 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Scaffold per-component playground pages.
|
|
4
|
+
*
|
|
5
|
+
* Reads docs/ai-summary.json and, for every component under
|
|
6
|
+
* src/runtime/components/, emits:
|
|
7
|
+
* - playground/pages/components/<slug>.vue (stub demo + API panel)
|
|
8
|
+
* - playground/playgrounds.generated.ts (component registry array)
|
|
9
|
+
*
|
|
10
|
+
* Idempotency: pages start with a "SCAFFOLD_MARKER" comment. The script
|
|
11
|
+
* overwrites only files that still carry the marker — hand-edited pages
|
|
12
|
+
* (marker removed) are left alone.
|
|
13
|
+
*
|
|
14
|
+
* Run with: pnpm exec node scripts/scaffold-playground-pages.mjs
|
|
15
|
+
*/
|
|
16
|
+
import fs from 'node:fs'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
|
|
19
|
+
const rootDir = process.cwd()
|
|
20
|
+
const aiSummary = JSON.parse(fs.readFileSync(path.join(rootDir, 'docs/ai-summary.json'), 'utf8'))
|
|
21
|
+
const pagesDir = path.join(rootDir, 'playground/pages/components')
|
|
22
|
+
const registryFile = path.join(rootDir, 'playground/playgrounds.generated.ts')
|
|
23
|
+
|
|
24
|
+
const SCAFFOLD_MARKER = '<!-- SCAFFOLD: auto-generated by scripts/scaffold-playground-pages.mjs. Delete this line to opt out of overwrites. -->'
|
|
25
|
+
|
|
26
|
+
function pascal(segment) {
|
|
27
|
+
return segment.charAt(0).toUpperCase() + segment.slice(1)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function deriveNames(componentPath) {
|
|
31
|
+
// componentPath like "src/runtime/components/form/images/Pad.vue"
|
|
32
|
+
const rel = componentPath.replace(/^src\/runtime\/components\//, '').replace(/\.vue$/, '')
|
|
33
|
+
const segments = rel.split('/')
|
|
34
|
+
const componentName = segments.map(pascal).join('')
|
|
35
|
+
const slug = segments.map(s => s.toLowerCase()).join('-')
|
|
36
|
+
const title = componentName
|
|
37
|
+
// First path segment is the group; root-level components fall into "general".
|
|
38
|
+
const group = segments.length > 1 ? segments[0].toLowerCase() : 'general'
|
|
39
|
+
return { componentName, slug, title, group }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function renderPage({ componentName, title, summary, sourcePath }) {
|
|
43
|
+
const props = inferStubProps(componentName)
|
|
44
|
+
const propsAttr = props ? ' ' + props : ''
|
|
45
|
+
const setup = setupForComponent[componentName] ?? ''
|
|
46
|
+
return `<script setup lang="ts">
|
|
47
|
+
// ${SCAFFOLD_MARKER.replace(/^<!--\s*|\s*-->$/g, '')}
|
|
48
|
+
//
|
|
49
|
+
// To enrich this page (richer demo, multiple variants, controls, etc.),
|
|
50
|
+
// remove the SCAFFOLD comment in the <template> below — the scaffold
|
|
51
|
+
// script will then leave this file alone on future runs.
|
|
52
|
+
${setup}</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
${SCAFFOLD_MARKER}
|
|
56
|
+
<PlaygroundPage
|
|
57
|
+
title="${title}"
|
|
58
|
+
summary="${escapeAttr(summary)}"
|
|
59
|
+
source-path="${sourcePath}"
|
|
60
|
+
>
|
|
61
|
+
<div class="text-caption text-medium-emphasis mb-3">
|
|
62
|
+
Auto-scaffolded demo — mounts the component with minimal props.
|
|
63
|
+
Replace this block (and delete the SCAFFOLD comment) when you wire
|
|
64
|
+
up a realistic interactive demo.
|
|
65
|
+
</div>
|
|
66
|
+
<${componentName}${propsAttr} />
|
|
67
|
+
</PlaygroundPage>
|
|
68
|
+
</template>
|
|
69
|
+
`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function escapeAttr(s) {
|
|
73
|
+
return (s || '').replace(/"/g, '"').replace(/\n/g, ' ')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Hand-tuned minimal props for components that throw without them.
|
|
78
|
+
* Keep tiny — anything richer belongs in a hand-enriched page.
|
|
79
|
+
*/
|
|
80
|
+
const stubProps = {
|
|
81
|
+
FormTable: 'title="Demo table"',
|
|
82
|
+
FormTableData: 'title="Demo table"',
|
|
83
|
+
FormActionPad: 'title="Demo"',
|
|
84
|
+
FormEditPad: 'title="Demo"',
|
|
85
|
+
FormSystem: 'name="demoForm"',
|
|
86
|
+
FormDialog: ':model-value="false" title="Demo"',
|
|
87
|
+
FormImagesCapture: 'title="Demo"',
|
|
88
|
+
FormImagesEdit: 'title="Demo"',
|
|
89
|
+
FormImagesField: 'title="Demo"',
|
|
90
|
+
FormImagesPad: 'title="Demo"',
|
|
91
|
+
DialogConfirm: ':model-value="false"',
|
|
92
|
+
DialogLoading: ':model-value="false"',
|
|
93
|
+
DialogIndex: ':model-value="false" title="Demo"',
|
|
94
|
+
DialogHost: '',
|
|
95
|
+
DialogDefaultConfirm: ':model-value="false"',
|
|
96
|
+
DialogDefaultLoading: ':model-value="false"',
|
|
97
|
+
DialogDefaultNotify: ':model-value="false"',
|
|
98
|
+
DialogDefaultPrinting: ':model-value="false"',
|
|
99
|
+
DialogDefaultVerifyUser: ':model-value="false"',
|
|
100
|
+
DocumentForm: 'documentName="demo"',
|
|
101
|
+
DocumentTemplateBuilder: 'title="Template Builder"',
|
|
102
|
+
ModelTable: 'modelName="MasterItem" :fields="[\'*\']"',
|
|
103
|
+
ModelPad: 'modelName="MasterItem"',
|
|
104
|
+
ModelIterator: 'modelName="MasterItem" :fields="[\'*\']"',
|
|
105
|
+
ModelLabel: 'modelName="MasterItem"',
|
|
106
|
+
ModelSelect: 'modelName="MasterItem"',
|
|
107
|
+
ModelAutocomplete: 'modelName="MasterItem"',
|
|
108
|
+
ModelCombobox: 'modelName="MasterItem"',
|
|
109
|
+
MasterLabel: 'groupKey="DEMO"',
|
|
110
|
+
MasterSelect: 'groupKey="DEMO"',
|
|
111
|
+
MasterAutocomplete: 'groupKey="DEMO"',
|
|
112
|
+
MasterCombobox: 'groupKey="DEMO"',
|
|
113
|
+
MasterRadioGroup: 'groupKey="DEMO"',
|
|
114
|
+
LabelDate: 'model-value="2026-05-18"',
|
|
115
|
+
LabelDateAgo: ':model-value="DateTime.now()"',
|
|
116
|
+
LabelDateCount: ':model-value="DateTime.now()"',
|
|
117
|
+
LabelField: 'label="Demo" model-value="value"',
|
|
118
|
+
LabelFormatMoney: ':model-value="1234.5"',
|
|
119
|
+
LabelMask: 'mask="###-###-####" model-value="1234567890"',
|
|
120
|
+
LabelObject: ':model-value="{ key: \'value\' }"',
|
|
121
|
+
PdfView: '',
|
|
122
|
+
PdfPrint: '',
|
|
123
|
+
SplitterPanel: '',
|
|
124
|
+
TabsGroup: ':items="[{ label: \'Tab 1\' }, { label: \'Tab 2\' }]"',
|
|
125
|
+
ImportCSV: '',
|
|
126
|
+
ExportCSV: ':model-value="[]" file-name="demo"',
|
|
127
|
+
FileBtn: 'label="Upload"',
|
|
128
|
+
BarcodeReader: '',
|
|
129
|
+
MrzReader: '',
|
|
130
|
+
TextBarcode: ':model-value="\'ABC123\'"',
|
|
131
|
+
Alert: '',
|
|
132
|
+
DeviceIdCardButton: '',
|
|
133
|
+
DeviceIdCardWebSocket: '',
|
|
134
|
+
DeviceScanner: '',
|
|
135
|
+
FormLogin: '',
|
|
136
|
+
FormPad: '',
|
|
137
|
+
FormBirthdate: '',
|
|
138
|
+
FormCheckboxGroup: ':items="[{ title: \'One\', value: 1 }, { title: \'Two\', value: 2 }]"',
|
|
139
|
+
FormCodeEditor: 'language="javascript"',
|
|
140
|
+
FormDate: '',
|
|
141
|
+
FormDateTime: '',
|
|
142
|
+
FormTime: '',
|
|
143
|
+
FormFile: '',
|
|
144
|
+
FormHidden: '',
|
|
145
|
+
FormIterator: '',
|
|
146
|
+
FormSignPad: '',
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function inferStubProps(componentName) {
|
|
150
|
+
return stubProps[componentName] ?? ''
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Per-component <script setup> snippets injected after the SCAFFOLD comment. */
|
|
154
|
+
const setupForComponent = {
|
|
155
|
+
LabelDateAgo: `import { DateTime } from 'luxon'\n`,
|
|
156
|
+
LabelDateCount: `import { DateTime } from 'luxon'\n`,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function shouldOverwrite(filePath) {
|
|
160
|
+
if (!fs.existsSync(filePath)) return true
|
|
161
|
+
const content = fs.readFileSync(filePath, 'utf8')
|
|
162
|
+
return content.includes(SCAFFOLD_MARKER)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const entries = []
|
|
166
|
+
let written = 0
|
|
167
|
+
let skipped = 0
|
|
168
|
+
|
|
169
|
+
for (const component of aiSummary.components) {
|
|
170
|
+
const { componentName, slug, title, group } = deriveNames(component.path)
|
|
171
|
+
const summary = (component.summary || '').replace(/"/g, '\'')
|
|
172
|
+
const sourcePath = component.path
|
|
173
|
+
|
|
174
|
+
const subdir = slug.includes('-') ? '' : '' // flat layout under components/
|
|
175
|
+
const fileName = `${slug}.vue`
|
|
176
|
+
const filePath = path.join(pagesDir, subdir, fileName)
|
|
177
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true })
|
|
178
|
+
|
|
179
|
+
if (shouldOverwrite(filePath)) {
|
|
180
|
+
fs.writeFileSync(filePath, renderPage({ componentName, title, summary, sourcePath }))
|
|
181
|
+
written++
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
skipped++
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
entries.push({
|
|
188
|
+
slug,
|
|
189
|
+
title,
|
|
190
|
+
summary,
|
|
191
|
+
to: `/components/${slug}`,
|
|
192
|
+
group,
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
entries.sort((a, b) => a.slug.localeCompare(b.slug))
|
|
197
|
+
|
|
198
|
+
const registrySource = `// Auto-generated by scripts/scaffold-playground-pages.mjs.
|
|
199
|
+
// Do not edit by hand — re-run the script after adding components.
|
|
200
|
+
import type { PlaygroundEntry } from './playgrounds'
|
|
201
|
+
|
|
202
|
+
export const componentEntries: PlaygroundEntry[] = ${JSON.stringify(entries, null, 2)}
|
|
203
|
+
`
|
|
204
|
+
fs.writeFileSync(registryFile, registrySource)
|
|
205
|
+
|
|
206
|
+
console.log(`Pages scaffolded: ${written} written, ${skipped} preserved (hand-edited).`)
|
|
207
|
+
console.log(`Registry: ${path.relative(rootDir, registryFile)} (${entries.length} entries)`)
|