@maizzle/framework 6.0.0-rc.24 → 6.0.0-rc.26
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/dist/build.d.ts +19 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +139 -102
- package/dist/build.js.map +1 -1
- package/dist/components/Body.vue +12 -0
- package/dist/components/Button.vue +16 -29
- package/dist/components/CodeBlock.vue +5 -4
- package/dist/components/CodeInline.vue +9 -8
- package/dist/components/Column.vue +17 -4
- package/dist/components/Container.vue +7 -11
- package/dist/components/Hr.vue +1 -1
- package/dist/components/Img.vue +39 -22
- package/dist/components/Layout.vue +1 -1
- package/dist/components/Markdown.vue +9 -14
- package/dist/components/QrCode.vue +2 -2
- package/dist/components/Section.vue +9 -6
- package/dist/components/Text.vue +2 -2
- package/dist/components/utils.d.ts +25 -1
- package/dist/components/utils.d.ts.map +1 -1
- package/dist/components/utils.js +29 -1
- package/dist/components/utils.js.map +1 -1
- package/dist/components/utils.ts +46 -0
- package/dist/composables/useConfig.d.ts.map +1 -1
- package/dist/composables/useCurrentTemplate.d.ts.map +1 -1
- package/dist/composables/useEvent.d.ts.map +1 -1
- package/dist/composables/useFont.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/plaintext.js.map +1 -1
- package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -1
- package/dist/plugins/postcss/pruneVars.js.map +1 -1
- package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -1
- package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -1
- package/dist/plugins/postcss/removeDeclarations.js.map +1 -1
- package/dist/plugins/postcss/resolveProps.d.ts.map +1 -1
- package/dist/plugins/postcss/resolveProps.js +0 -3
- package/dist/plugins/postcss/resolveProps.js.map +1 -1
- package/dist/plugins/postcss/tailwindCleanup.js.map +1 -1
- package/dist/prepare.js +1 -1
- package/dist/prepare.js.map +1 -1
- package/dist/render/active.d.ts.map +1 -1
- package/dist/render/buildTemplate.d.ts +49 -0
- package/dist/render/buildTemplate.d.ts.map +1 -0
- package/dist/render/buildTemplate.js +139 -0
- package/dist/render/buildTemplate.js.map +1 -0
- package/dist/render/createRenderer.d.ts +3 -1
- package/dist/render/createRenderer.d.ts.map +1 -1
- package/dist/render/createRenderer.js +43 -10
- package/dist/render/createRenderer.js.map +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/injectFonts.js.map +1 -1
- package/dist/render/parallel/buildWorker.d.ts +31 -0
- package/dist/render/parallel/buildWorker.d.ts.map +1 -0
- package/dist/render/parallel/buildWorker.js +66 -0
- package/dist/render/parallel/buildWorker.js.map +1 -0
- package/dist/render/parallel/worker.mjs +28 -0
- package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -1
- package/dist/render/plugins/codeBlockExtract.js.map +1 -1
- package/dist/render/plugins/markdownExtract.d.ts.map +1 -1
- package/dist/render/plugins/markdownExtract.js.map +1 -1
- package/dist/render/plugins/rawExtract.d.ts.map +1 -1
- package/dist/render/plugins/rawExtract.js.map +1 -1
- package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -1
- package/dist/render/plugins/rowSourceLocation.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +73 -53
- package/dist/serve.js.map +1 -1
- package/dist/server/compatibility.d.ts.map +1 -1
- package/dist/server/compatibility.js.map +1 -1
- package/dist/server/linter.js.map +1 -1
- package/dist/server/sfc-utils.js +1 -1
- package/dist/server/sfc-utils.js.map +1 -1
- package/dist/server/ui/pages/Preview.vue +34 -11
- package/dist/server/ui/vite-env.d.ts +1 -0
- package/dist/tests/render/_helpers.d.ts.map +1 -1
- package/dist/tests/render/_helpers.js.map +1 -1
- package/dist/transformers/addAttributes.js +2 -3
- package/dist/transformers/addAttributes.js.map +1 -1
- package/dist/transformers/base.d.ts +1 -1
- package/dist/transformers/base.d.ts.map +1 -1
- package/dist/transformers/base.js +5 -10
- package/dist/transformers/base.js.map +1 -1
- package/dist/transformers/columnWidth.d.ts.map +1 -1
- package/dist/transformers/columnWidth.js +2 -7
- package/dist/transformers/columnWidth.js.map +1 -1
- package/dist/transformers/entities.js.map +1 -1
- package/dist/transformers/filters/defaults.js.map +1 -1
- package/dist/transformers/filters/index.js.map +1 -1
- package/dist/transformers/format.js.map +1 -1
- package/dist/transformers/imgWidth.d.ts +20 -0
- package/dist/transformers/imgWidth.d.ts.map +1 -0
- package/dist/transformers/imgWidth.js +76 -0
- package/dist/transformers/imgWidth.js.map +1 -0
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/index.js +2 -0
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/inlineCss.d.ts +3 -2
- package/dist/transformers/inlineCss.d.ts.map +1 -1
- package/dist/transformers/inlineCss.js.map +1 -1
- package/dist/transformers/inlineLink.js +1 -1
- package/dist/transformers/inlineLink.js.map +1 -1
- package/dist/transformers/minify.js.map +1 -1
- package/dist/transformers/minifyCodeInline.js.map +1 -1
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
- package/dist/transformers/msoPlaceholders.js +2 -7
- package/dist/transformers/msoPlaceholders.js.map +1 -1
- package/dist/transformers/purgeCss.js.map +1 -1
- package/dist/transformers/replaceStrings.js.map +1 -1
- package/dist/transformers/safeSelectors.js.map +1 -1
- package/dist/transformers/shorthandCss.js.map +1 -1
- package/dist/transformers/tailwindComponent.js.map +1 -1
- package/dist/transformers/tailwindcss.js +1 -1
- package/dist/transformers/tailwindcss.js.map +1 -1
- package/dist/transformers/urlQuery.js.map +1 -1
- package/dist/types/config.d.ts +26 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/ast/serializer.js.map +1 -1
- package/dist/utils/compileTailwindCss.js.map +1 -1
- package/dist/utils/componentSources.js.map +1 -1
- package/dist/utils/cssBox.d.ts.map +1 -1
- package/dist/utils/cssBox.js +2 -7
- package/dist/utils/cssBox.js.map +1 -1
- package/dist/utils/decodeStyleEntities.js.map +1 -1
- package/dist/utils/url.js.map +1 -1
- package/dist/utils/watchPaths.js.map +1 -1
- package/node_modules/@clack/core/CHANGELOG.md +30 -0
- package/node_modules/@clack/core/dist/index.d.mts +109 -3
- package/node_modules/@clack/core/dist/index.mjs +972 -17
- package/node_modules/@clack/core/package.json +2 -1
- package/node_modules/@clack/prompts/CHANGELOG.md +42 -0
- package/node_modules/@clack/prompts/README.md +30 -9
- package/node_modules/@clack/prompts/dist/index.d.mts +458 -27
- package/node_modules/@clack/prompts/dist/index.mjs +1378 -141
- package/node_modules/@clack/prompts/package.json +2 -2
- package/node_modules/tinyexec/package.json +4 -4
- package/package.json +13 -11
- package/dist/components/Overlap.vue +0 -156
- package/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { State, AutocompletePrompt, DateFormat } from '@clack/core';
|
|
1
|
+
import { State, AutocompletePrompt, Validate, DateFormat } from '@clack/core';
|
|
2
2
|
export { ClackSettings, DateFormat, isCancel, settings, updateSettings } from '@clack/core';
|
|
3
3
|
import { Readable, Writable } from 'node:stream';
|
|
4
4
|
|
|
@@ -98,138 +98,478 @@ interface SelectOptions<Value> extends CommonOptions {
|
|
|
98
98
|
}
|
|
99
99
|
declare const select: <Value>(opts: SelectOptions<Value>) => Promise<Value | symbol>;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Options for the {@link autocomplete} prompt.
|
|
103
|
+
*/
|
|
101
104
|
interface AutocompleteSharedOptions<Value> extends CommonOptions {
|
|
102
105
|
/**
|
|
103
|
-
* The message
|
|
106
|
+
* The message or question shown to the user above the input.
|
|
104
107
|
*/
|
|
105
108
|
message: string;
|
|
106
109
|
/**
|
|
107
|
-
*
|
|
110
|
+
* The options to present, or a function that returns the options to present
|
|
111
|
+
* allowing for custom search/filtering.
|
|
112
|
+
*
|
|
113
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#dynamic-options-getter
|
|
108
114
|
*/
|
|
109
115
|
options: Option<Value>[] | ((this: AutocompletePrompt<Option<Value>>) => Option<Value>[]);
|
|
110
116
|
/**
|
|
111
|
-
*
|
|
117
|
+
* The maximum number of items/options to display in the autocomplete list at once.
|
|
112
118
|
*/
|
|
113
119
|
maxItems?: number;
|
|
114
120
|
/**
|
|
115
|
-
* Placeholder text
|
|
121
|
+
* Placeholder text displayed when the search field is empty. When set, pressing
|
|
122
|
+
* tab copies the placeholder into the input.
|
|
116
123
|
*/
|
|
117
124
|
placeholder?: string;
|
|
118
125
|
/**
|
|
119
|
-
*
|
|
126
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
127
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
128
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
120
129
|
*/
|
|
121
|
-
validate?:
|
|
130
|
+
validate?: Validate<Value | Value[]>;
|
|
122
131
|
/**
|
|
123
|
-
* Custom filter function to match options against search input.
|
|
124
|
-
* If not provided, a default filter that matches label, hint, and value is used.
|
|
132
|
+
* Custom filter function to match options against the search input.
|
|
125
133
|
*/
|
|
126
134
|
filter?: (search: string, option: Option<Value>) => boolean;
|
|
127
135
|
}
|
|
128
136
|
interface AutocompleteOptions<Value> extends AutocompleteSharedOptions<Value> {
|
|
129
137
|
/**
|
|
130
|
-
* The
|
|
138
|
+
* The initially selected option from the list.
|
|
131
139
|
*/
|
|
132
140
|
initialValue?: Value;
|
|
133
141
|
/**
|
|
134
|
-
* The
|
|
142
|
+
* The starting value shown in the users input box.
|
|
135
143
|
*/
|
|
136
144
|
initialUserInput?: string;
|
|
137
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* The `autocomplete` prompt combines a text input with a searchable list of options.
|
|
148
|
+
* It's perfect for when you have a large list of options and want to help users
|
|
149
|
+
* find what they're looking for quickly.
|
|
150
|
+
*
|
|
151
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#autocomplete
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { autocomplete } from '@clack/prompts';
|
|
156
|
+
*
|
|
157
|
+
* const framework = await autocomplete({
|
|
158
|
+
* message: 'Search for a framework',
|
|
159
|
+
* options: [
|
|
160
|
+
* { value: 'next', label: 'Next.js', hint: 'React framework' },
|
|
161
|
+
* { value: 'astro', label: 'Astro', hint: 'Content-focused' },
|
|
162
|
+
* { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },
|
|
163
|
+
* { value: 'remix', label: 'Remix', hint: 'Full stack framework' },
|
|
164
|
+
* { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },
|
|
165
|
+
* ],
|
|
166
|
+
* placeholder: 'Type to search...',
|
|
167
|
+
* maxItems: 5,
|
|
168
|
+
* });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
138
171
|
declare const autocomplete: <Value>(opts: AutocompleteOptions<Value>) => Promise<Value | symbol>;
|
|
172
|
+
/**
|
|
173
|
+
* Options for the {@link autocompleteMultiselect} prompt
|
|
174
|
+
*/
|
|
139
175
|
interface AutocompleteMultiSelectOptions<Value> extends AutocompleteSharedOptions<Value> {
|
|
140
176
|
/**
|
|
141
|
-
* The
|
|
177
|
+
* The initially selected option(s) from the list.
|
|
142
178
|
*/
|
|
143
179
|
initialValues?: Value[];
|
|
144
180
|
/**
|
|
145
|
-
*
|
|
181
|
+
* When `true` at least one option must be selected.
|
|
182
|
+
* @default false
|
|
146
183
|
*/
|
|
147
184
|
required?: boolean;
|
|
148
185
|
}
|
|
149
186
|
/**
|
|
150
|
-
*
|
|
187
|
+
* The `autocompleteMultiselect` prompt combines the search functionality of autocomplete
|
|
188
|
+
* with the ability to select multiple options.
|
|
189
|
+
*
|
|
190
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#autocomplete-multiselect
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* import { autocompleteMultiselect } from '@clack/prompts';
|
|
195
|
+
*
|
|
196
|
+
* const frameworks = await autocompleteMultiselect({
|
|
197
|
+
* message: 'Select frameworks',
|
|
198
|
+
* options: [
|
|
199
|
+
* { value: 'next', label: 'Next.js', hint: 'React framework' },
|
|
200
|
+
* { value: 'astro', label: 'Astro', hint: 'Content-focused' },
|
|
201
|
+
* { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },
|
|
202
|
+
* { value: 'remix', label: 'Remix', hint: 'Full stack framework' },
|
|
203
|
+
* { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },
|
|
204
|
+
* ],
|
|
205
|
+
* placeholder: 'Type to search...',
|
|
206
|
+
* maxItems: 5,
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
151
209
|
*/
|
|
152
210
|
declare const autocompleteMultiselect: <Value>(opts: AutocompleteMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
|
|
153
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Alignment for content or titles within the box.
|
|
214
|
+
*/
|
|
154
215
|
type BoxAlignment = 'left' | 'center' | 'right';
|
|
216
|
+
/**
|
|
217
|
+
* Options for the {@link box} prompt.
|
|
218
|
+
*/
|
|
155
219
|
interface BoxOptions extends CommonOptions {
|
|
220
|
+
/**
|
|
221
|
+
* Alignment of the content (`'left'`, `'center'`, or `'right'`).
|
|
222
|
+
* @default 'left'
|
|
223
|
+
*/
|
|
156
224
|
contentAlign?: BoxAlignment;
|
|
225
|
+
/**
|
|
226
|
+
* Alignment of the title (`'left'`, `'center'`, or `'right'`).
|
|
227
|
+
* @default 'left'
|
|
228
|
+
*/
|
|
157
229
|
titleAlign?: BoxAlignment;
|
|
230
|
+
/**
|
|
231
|
+
* The width of the box, either `'auto'` to fit the content or a number for a fixed width.
|
|
232
|
+
* @default 'auto'
|
|
233
|
+
*/
|
|
158
234
|
width?: number | 'auto';
|
|
235
|
+
/**
|
|
236
|
+
* Padding around the title.
|
|
237
|
+
* @default 1
|
|
238
|
+
*/
|
|
159
239
|
titlePadding?: number;
|
|
240
|
+
/**
|
|
241
|
+
* Padding around the content.
|
|
242
|
+
* @default 2
|
|
243
|
+
*/
|
|
160
244
|
contentPadding?: number;
|
|
245
|
+
/**
|
|
246
|
+
* Use rounded corners when `true`, square corners when `false`.
|
|
247
|
+
* @default true
|
|
248
|
+
*/
|
|
161
249
|
rounded?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Custom function to style the border characters.
|
|
252
|
+
*/
|
|
162
253
|
formatBorder?: (text: string) => string;
|
|
163
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Renders a customizable box around text content. It's similar to {@link note} but offers
|
|
257
|
+
* more styling options.
|
|
258
|
+
*
|
|
259
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#box
|
|
260
|
+
*
|
|
261
|
+
* @param message - The content to display inside the box.
|
|
262
|
+
* @param title - The title to display in the top border of the box.
|
|
263
|
+
* @param opts - Optional configuration for the box styling and behavior.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* import { box } from '@clack/prompts';
|
|
268
|
+
*
|
|
269
|
+
* box('This is the content of the box', 'Box Title', {
|
|
270
|
+
* contentAlign: 'center',
|
|
271
|
+
* titleAlign: 'center',
|
|
272
|
+
* width: 'auto',
|
|
273
|
+
* rounded: true,
|
|
274
|
+
* });
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
164
277
|
declare const box: (message?: string, title?: string, opts?: BoxOptions) => void;
|
|
165
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Options for the {@link confirm} prompt.
|
|
281
|
+
*/
|
|
166
282
|
interface ConfirmOptions extends CommonOptions {
|
|
283
|
+
/**
|
|
284
|
+
* The message or question shown to the user above the input.
|
|
285
|
+
*/
|
|
167
286
|
message: string;
|
|
287
|
+
/**
|
|
288
|
+
* The label to use for the active (true) option.
|
|
289
|
+
* @default 'Yes'
|
|
290
|
+
*/
|
|
168
291
|
active?: string;
|
|
292
|
+
/**
|
|
293
|
+
* The label to use for the inactive (false) option.
|
|
294
|
+
* @default 'No'
|
|
295
|
+
*/
|
|
169
296
|
inactive?: string;
|
|
297
|
+
/**
|
|
298
|
+
* The initial selected value (true or false).
|
|
299
|
+
* @default true
|
|
300
|
+
*/
|
|
170
301
|
initialValue?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Whether to render the options vertically instead of horizontally.
|
|
304
|
+
* @default false
|
|
305
|
+
*/
|
|
171
306
|
vertical?: boolean;
|
|
172
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* The `confirm` prompt accepts a yes or no choice, returning a boolean value
|
|
310
|
+
* corresponding to the user's selection.
|
|
311
|
+
*
|
|
312
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#confirmation
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* import { confirm } from '@clack/prompts';
|
|
317
|
+
*
|
|
318
|
+
* const shouldProceed = await confirm({
|
|
319
|
+
* message: 'Do you want to continue?',
|
|
320
|
+
* });
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
173
323
|
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
|
174
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Options for the {@link date} prompt.
|
|
327
|
+
*/
|
|
175
328
|
interface DateOptions extends CommonOptions {
|
|
329
|
+
/**
|
|
330
|
+
* The message or question shown to the user above the input.
|
|
331
|
+
*/
|
|
176
332
|
message: string;
|
|
333
|
+
/**
|
|
334
|
+
* The date format for the input segments.
|
|
335
|
+
* @deafult based on locale
|
|
336
|
+
*/
|
|
177
337
|
format?: DateFormat;
|
|
338
|
+
/**
|
|
339
|
+
* The BCP 47 language tag to use for formatting
|
|
340
|
+
* @see https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag
|
|
341
|
+
* @example "en-GB"
|
|
342
|
+
*/
|
|
178
343
|
locale?: string;
|
|
344
|
+
/**
|
|
345
|
+
* The default value returned when the user doesn't select a date.
|
|
346
|
+
*/
|
|
179
347
|
defaultValue?: Date;
|
|
348
|
+
/**
|
|
349
|
+
* The starting date shown when the prompt first renders.
|
|
350
|
+
* Users can edit this value before submitting.
|
|
351
|
+
*/
|
|
180
352
|
initialValue?: Date;
|
|
353
|
+
/**
|
|
354
|
+
* The minimum allowed date for validation.
|
|
355
|
+
*/
|
|
181
356
|
minDate?: Date;
|
|
357
|
+
/**
|
|
358
|
+
* The maximum allowed date for validation.
|
|
359
|
+
*/
|
|
182
360
|
maxDate?: Date;
|
|
183
|
-
|
|
361
|
+
/**
|
|
362
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
363
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
364
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
365
|
+
*/
|
|
366
|
+
validate?: Validate<Date>;
|
|
184
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* The `date` prompt provides an interactive date picker, allowing users
|
|
370
|
+
* to navigate between year, month, and day segments and
|
|
371
|
+
* increment/decrement values using keyboard controls.
|
|
372
|
+
*
|
|
373
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#date-input
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* import { date } from '@clack/prompts';
|
|
378
|
+
*
|
|
379
|
+
* const birthday = await date({
|
|
380
|
+
* message: 'Pick your birthday',
|
|
381
|
+
* minDate: new Date('1900-01-01'),
|
|
382
|
+
* initialValue: new Date(),
|
|
383
|
+
* maxDate: new Date(),
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
185
387
|
declare const date: (opts: DateOptions) => Promise<Date | symbol>;
|
|
186
388
|
|
|
187
389
|
type Prettify<T> = {
|
|
188
390
|
[P in keyof T]: T[P];
|
|
189
391
|
} & {};
|
|
392
|
+
/**
|
|
393
|
+
* The return type of a {@link PromptGroup}.
|
|
394
|
+
* Resolves all prompt results, excluding the cancel symbol.
|
|
395
|
+
*/
|
|
190
396
|
type PromptGroupAwaitedReturn<T> = {
|
|
191
397
|
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
|
192
398
|
};
|
|
399
|
+
/**
|
|
400
|
+
* Options for the {@link group} utility.
|
|
401
|
+
*/
|
|
193
402
|
interface PromptGroupOptions<T> {
|
|
194
403
|
/**
|
|
195
|
-
*
|
|
196
|
-
* if one of the prompts is canceled.
|
|
404
|
+
* Called when any one of the prompts is canceled.
|
|
197
405
|
*/
|
|
198
406
|
onCancel?: (opts: {
|
|
199
407
|
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
|
200
408
|
}) => void;
|
|
201
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* A group of prompts to be displayed sequentially, with each prompt receiving
|
|
412
|
+
* the results of all previous prompts in the group.
|
|
413
|
+
*/
|
|
202
414
|
type PromptGroup<T> = {
|
|
203
415
|
[P in keyof T]: (opts: {
|
|
204
416
|
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
|
205
417
|
}) => undefined | Promise<T[P] | undefined>;
|
|
206
418
|
};
|
|
207
419
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
420
|
+
* The `group` utility provides a consistent way to combine a series of prompts,
|
|
421
|
+
* combining each answer into one object. Each prompt receives the results of
|
|
422
|
+
* all previously completed prompts, and are displayed sequentially.
|
|
423
|
+
*
|
|
424
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#group
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { group, text, password } from '@clack/prompts';
|
|
429
|
+
*
|
|
430
|
+
* const account = await group({
|
|
431
|
+
* email: () => text({
|
|
432
|
+
* message: 'What is your email address?',
|
|
433
|
+
* }),
|
|
434
|
+
* username: ({ results }) => text({
|
|
435
|
+
* message: 'What is your username?',
|
|
436
|
+
* placeholder: results.email?.replace(/@.+$/, '').toLowerCase() ?? '',
|
|
437
|
+
* }),
|
|
438
|
+
* password: () => password({
|
|
439
|
+
* message: 'Define your password',
|
|
440
|
+
* }),
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
210
443
|
*/
|
|
211
444
|
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T>) => Promise<Prettify<PromptGroupAwaitedReturn<T>>>;
|
|
212
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Options for the {@link groupMultiselect} prompt.
|
|
448
|
+
*/
|
|
213
449
|
interface GroupMultiSelectOptions<Value> extends CommonOptions {
|
|
450
|
+
/**
|
|
451
|
+
* The message or question shown to the user above the input.
|
|
452
|
+
*/
|
|
214
453
|
message: string;
|
|
454
|
+
/**
|
|
455
|
+
* Grouped options to display. Each key is a group label, and each value is an array of options.
|
|
456
|
+
*/
|
|
215
457
|
options: Record<string, Option<Value>[]>;
|
|
458
|
+
/**
|
|
459
|
+
* The initially selected option(s).
|
|
460
|
+
*/
|
|
216
461
|
initialValues?: Value[];
|
|
462
|
+
/**
|
|
463
|
+
* The maximum number of items/options to display at once.
|
|
464
|
+
*/
|
|
217
465
|
maxItems?: number;
|
|
466
|
+
/**
|
|
467
|
+
* When `true` at least one option must be selected.
|
|
468
|
+
* @default true
|
|
469
|
+
*/
|
|
218
470
|
required?: boolean;
|
|
471
|
+
/**
|
|
472
|
+
* The value the cursor should be positioned at initially.
|
|
473
|
+
*/
|
|
219
474
|
cursorAt?: Value;
|
|
475
|
+
/**
|
|
476
|
+
* Whether entire groups can be selected at once.
|
|
477
|
+
* @default true
|
|
478
|
+
*/
|
|
220
479
|
selectableGroups?: boolean;
|
|
480
|
+
/**
|
|
481
|
+
* Number of blank lines between groups.
|
|
482
|
+
* @default 0
|
|
483
|
+
*/
|
|
221
484
|
groupSpacing?: number;
|
|
222
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* The `groupMultiselect` prompt extends the {@link multiselect} prompt to allow
|
|
488
|
+
* arranging distinct Multi-Selects, whilst keeping all of them interactive.
|
|
489
|
+
*
|
|
490
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#group-multiselect
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```ts
|
|
494
|
+
* import { groupMultiselect } from '@clack/prompts';
|
|
495
|
+
*
|
|
496
|
+
* const result = await groupMultiselect({
|
|
497
|
+
* message: 'Define your project',
|
|
498
|
+
* options: {
|
|
499
|
+
* 'Testing': [
|
|
500
|
+
* { value: 'Jest', hint: 'JavaScript testing framework' },
|
|
501
|
+
* { value: 'Playwright', hint: 'End-to-end testing' },
|
|
502
|
+
* ],
|
|
503
|
+
* 'Language': [
|
|
504
|
+
* { value: 'js', label: 'JavaScript', hint: 'Dynamic typing' },
|
|
505
|
+
* { value: 'ts', label: 'TypeScript', hint: 'Static typing' },
|
|
506
|
+
* ],
|
|
507
|
+
* },
|
|
508
|
+
* });
|
|
509
|
+
* ```
|
|
510
|
+
*
|
|
511
|
+
* @param opts The options for the group multiselect prompt
|
|
512
|
+
*/
|
|
223
513
|
declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
|
|
224
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Options for the {@link limitOptions} function.
|
|
517
|
+
*/
|
|
225
518
|
interface LimitOptionsParams<TOption> extends CommonOptions {
|
|
519
|
+
/**
|
|
520
|
+
* The list of options to display.
|
|
521
|
+
*/
|
|
226
522
|
options: TOption[];
|
|
523
|
+
/**
|
|
524
|
+
* The index of the currently active/selected option.
|
|
525
|
+
*/
|
|
227
526
|
cursor: number;
|
|
527
|
+
/**
|
|
528
|
+
* A function that styles the given option string.
|
|
529
|
+
*
|
|
530
|
+
* @param option - The option string to style.
|
|
531
|
+
* @param active - Whether the option is currently selected.
|
|
532
|
+
*/
|
|
228
533
|
style: (option: TOption, active: boolean) => string;
|
|
534
|
+
/**
|
|
535
|
+
* Maximum number of options to display at once.
|
|
536
|
+
* @default Infinity
|
|
537
|
+
*/
|
|
229
538
|
maxItems?: number;
|
|
539
|
+
/**
|
|
540
|
+
* Number of columns to reserve for padding.
|
|
541
|
+
* @default 0
|
|
542
|
+
*/
|
|
230
543
|
columnPadding?: number;
|
|
544
|
+
/**
|
|
545
|
+
* Number of rows to reserve for padding.
|
|
546
|
+
* @default 4
|
|
547
|
+
*/
|
|
231
548
|
rowPadding?: number;
|
|
232
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Trims an option list to what fits the terminal, while keeping the active
|
|
552
|
+
* option (cursor) visible using a Clack style sliding window.
|
|
553
|
+
*
|
|
554
|
+
* @returns The lines to render.
|
|
555
|
+
*
|
|
556
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#limitoptions
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```ts
|
|
560
|
+
* import { limitOptions } from '@clack/prompts';
|
|
561
|
+
* import { styleText } from 'node:util';
|
|
562
|
+
*
|
|
563
|
+
* const options = ['apple', 'banana', 'cherry', 'date'];
|
|
564
|
+
* const lines = limitOptions({
|
|
565
|
+
* options,
|
|
566
|
+
* cursor: 2,
|
|
567
|
+
* maxItems: 8,
|
|
568
|
+
* style: (opt, active) =>
|
|
569
|
+
* active ? styleText('cyan', opt) : styleText('dim', opt),
|
|
570
|
+
* });
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
233
573
|
declare const limitOptions: <TOption>({ cursor, options, style, output, maxItems, columnPadding, rowPadding, }: LimitOptionsParams<TOption>) => string[];
|
|
234
574
|
|
|
235
575
|
interface LogMessageOptions extends CommonOptions {
|
|
@@ -248,8 +588,56 @@ declare const log: {
|
|
|
248
588
|
error: (message: string, opts?: LogMessageOptions) => void;
|
|
249
589
|
};
|
|
250
590
|
|
|
591
|
+
/**
|
|
592
|
+
* The `cancel` function defines an interruption of an interaction
|
|
593
|
+
* and therefore its end.
|
|
594
|
+
*
|
|
595
|
+
* @param title Optional closing message to be displayed.
|
|
596
|
+
* @param opts Additional configuration options.
|
|
597
|
+
*
|
|
598
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#cancel
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* import { cancel } from '@clack/prompts';
|
|
603
|
+
* import process from 'node:process';
|
|
604
|
+
*
|
|
605
|
+
* cancel('Installation canceled');
|
|
606
|
+
* process.exit(1);
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
251
609
|
declare const cancel: (message?: string, opts?: CommonOptions) => void;
|
|
610
|
+
/**
|
|
611
|
+
* The `intro` function defines the beginning of an interaction.
|
|
612
|
+
*
|
|
613
|
+
* @param title Optional title to be displayed.
|
|
614
|
+
* @param opts Additional configuration options.
|
|
615
|
+
*
|
|
616
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#intro
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```ts
|
|
620
|
+
* import { intro } from '@clack/prompts';
|
|
621
|
+
*
|
|
622
|
+
* intro('Welcome to clack');
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
252
625
|
declare const intro: (title?: string, opts?: CommonOptions) => void;
|
|
626
|
+
/**
|
|
627
|
+
* The `outro` function defines the end of an interaction.
|
|
628
|
+
*
|
|
629
|
+
* @param title Optional closing message to be displayed.
|
|
630
|
+
* @param opts Additional configuration options.
|
|
631
|
+
*
|
|
632
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#outro
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* ```ts
|
|
636
|
+
* import { outro } from '@clack/prompts';
|
|
637
|
+
*
|
|
638
|
+
* outro('All operations are finished');
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
253
641
|
declare const outro: (message?: string, opts?: CommonOptions) => void;
|
|
254
642
|
|
|
255
643
|
/**
|
|
@@ -274,10 +662,11 @@ interface TextOptions extends CommonOptions {
|
|
|
274
662
|
*/
|
|
275
663
|
initialValue?: string;
|
|
276
664
|
/**
|
|
277
|
-
* A function
|
|
278
|
-
*
|
|
665
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
666
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
667
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
279
668
|
*/
|
|
280
|
-
validate?:
|
|
669
|
+
validate?: Validate<string>;
|
|
281
670
|
}
|
|
282
671
|
/**
|
|
283
672
|
* The text prompt accepts a single line of text.
|
|
@@ -361,10 +750,11 @@ interface PasswordOptions extends CommonOptions {
|
|
|
361
750
|
*/
|
|
362
751
|
mask?: string;
|
|
363
752
|
/**
|
|
364
|
-
* A function
|
|
365
|
-
*
|
|
753
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
754
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
755
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
366
756
|
*/
|
|
367
|
-
validate?:
|
|
757
|
+
validate?: Validate<string>;
|
|
368
758
|
/**
|
|
369
759
|
* When enabled it causes the input to be cleared if/when validation fails.
|
|
370
760
|
* @default false
|
|
@@ -387,13 +777,54 @@ interface PasswordOptions extends CommonOptions {
|
|
|
387
777
|
*/
|
|
388
778
|
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
|
389
779
|
|
|
780
|
+
/**
|
|
781
|
+
* Options for the {@link path} prompt.
|
|
782
|
+
*/
|
|
390
783
|
interface PathOptions extends CommonOptions {
|
|
784
|
+
/**
|
|
785
|
+
* The message or question shown to the user above the input.
|
|
786
|
+
*/
|
|
787
|
+
message: string;
|
|
788
|
+
/**
|
|
789
|
+
* The starting directory for path suggestions (defaults to current working directory).
|
|
790
|
+
*/
|
|
391
791
|
root?: string;
|
|
792
|
+
/**
|
|
793
|
+
* When `true` only **directories** appear in suggestions while you navigate.
|
|
794
|
+
*/
|
|
392
795
|
directory?: boolean;
|
|
796
|
+
/**
|
|
797
|
+
* The starting path shown when the prompt first renders, which users can edit
|
|
798
|
+
* before submitting. If not provided it will fall back to the given `root`,
|
|
799
|
+
* or the current working directory.
|
|
800
|
+
*
|
|
801
|
+
* In `directory` mode, if the initial value points to a directory that exists,
|
|
802
|
+
* pressing enter will submit the input instead of jumping to the first child.
|
|
803
|
+
*/
|
|
393
804
|
initialValue?: string;
|
|
394
|
-
|
|
395
|
-
|
|
805
|
+
/**
|
|
806
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
807
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
808
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
809
|
+
*/
|
|
810
|
+
validate?: Validate<string>;
|
|
396
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* The `path` prompt extends `autocomplete` to provide file and directory suggestions.
|
|
814
|
+
*
|
|
815
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#path-selection
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```ts
|
|
819
|
+
* import { path } from '@clack/prompts';
|
|
820
|
+
*
|
|
821
|
+
* const result = await path({
|
|
822
|
+
* message: 'Select a file:',
|
|
823
|
+
* root: process.cwd(),
|
|
824
|
+
* directory: false,
|
|
825
|
+
* });
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
397
828
|
declare const path: (opts: PathOptions) => Promise<string | symbol>;
|
|
398
829
|
|
|
399
830
|
interface SpinnerOptions extends CommonOptions {
|