@webx-ui/core 0.40.2 → 0.42.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.
@@ -1,44 +1,27 @@
1
- import { Extension } from '@codemirror/state';
2
1
  import { EditorView } from '@codemirror/view';
3
- import { CodeEditorDiagnostic, CodeEditorProps } from './types';
4
- type __VLS_Props = CodeEditorProps;
5
- declare function format(): boolean;
6
- type __VLS_PublicProps = {
7
- modelValue?: string;
8
- } & __VLS_Props;
9
- declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
10
- view: import('vue').ShallowRef<EditorView | null, EditorView | null>;
11
- focus: () => void | undefined;
12
- format: typeof format;
13
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
- change: (value: string) => any;
15
- "update:modelValue": (value: string) => any;
16
- blur: () => any;
17
- focus: () => any;
18
- lint: (diagnostics: CodeEditorDiagnostic[]) => any;
19
- }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
- onChange?: ((value: string) => any) | undefined;
21
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
22
- onBlur?: (() => any) | undefined;
23
- onFocus?: (() => any) | undefined;
24
- onLint?: ((diagnostics: CodeEditorDiagnostic[]) => any) | undefined;
25
- }>, {
26
- size: import('../..').ControlSize;
27
- disabled: boolean;
28
- placeholder: string;
29
- ariaLabel: string;
30
- status: import('../..').ControlStatus;
31
- id: string;
32
- language: import('./types').CodeEditorLanguage;
33
- readonly: boolean;
34
- minHeight: string;
35
- maxHeight: string;
36
- lineNumbers: boolean;
37
- lineWrapping: boolean;
38
- tabSize: number;
39
- lint: boolean;
40
- extensions: Extension[];
41
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
42
- host: HTMLDivElement;
43
- }, any>;
2
+ import { CodeEditorDiagnostic, CodeEditorModelValue, CodeEditorProps } from './types';
3
+ declare const _default: <T extends CodeEditorModelValue = string>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
5
+ readonly onChange?: ((value: string) => any) | undefined;
6
+ readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
7
+ readonly onBlur?: (() => any) | undefined;
8
+ readonly onFocus?: (() => any) | undefined;
9
+ readonly onLint?: ((diagnostics: CodeEditorDiagnostic[]) => any) | undefined;
10
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onChange" | "onUpdate:modelValue" | "onFocus" | "onBlur" | "onLint"> & ({
11
+ modelValue?: T;
12
+ } & CodeEditorProps) & Partial<{}>> & import('vue').PublicProps;
13
+ expose(exposed: import('vue').ShallowUnwrapRef<{
14
+ view: import('vue').ShallowRef<EditorView | null, EditorView | null>;
15
+ focus: () => void | undefined;
16
+ format: () => boolean;
17
+ }>): void;
18
+ attrs: any;
19
+ slots: {};
20
+ emit: (((evt: "change", value: string) => void) & ((evt: "blur") => void) & ((evt: "focus") => void) & ((evt: "lint", diagnostics: CodeEditorDiagnostic[]) => void)) & ((evt: "update:modelValue", value: T) => void);
21
+ }>) => import('vue').VNode & {
22
+ __ctx?: Awaited<typeof __VLS_setup>;
23
+ };
44
24
  export default _default;
25
+ type __VLS_PrettifyLocal<T> = {
26
+ [K in keyof T]: T[K];
27
+ } & {};
@@ -1,2 +1,4 @@
1
1
  export { default as WxCodeEditor } from './CodeEditor';
2
2
  export type * from './types';
3
+ export { mustacheCompletions, mustacheHighlighting, mustacheProblems, scanMustache, } from './mustache';
4
+ export type { MustacheProblems, MustacheTag, MustacheTagKind } from './mustache';
@@ -0,0 +1,66 @@
1
+ import { Extension } from '@codemirror/state';
2
+ import { CodeEditorCompleter, MustacheVariable, MustacheWords } from './types';
3
+ /**
4
+ * Mustache over text or HTML: `{{name}}`, sections `{{#list}}…{{/list}}`, `{{^name}}`, comments.
5
+ *
6
+ * Neither CodeMirror nor a maintained package carries Mustache for CodeMirror 6 (the legacy modes
7
+ * have Jinja and Velocity, not Mustache), and a template of a notification is a dozen lines — so
8
+ * the tags are found by one scan of the document and painted as marks over whatever language is
9
+ * underneath. The same scan answers the completion source and the checks a form runs on a
10
+ * template, so the three never disagree about where a tag begins.
11
+ */
12
+ /** What a tag is, by its first character. */
13
+ export type MustacheTagKind = 'variable' | 'section' | 'inverted' | 'close' | 'comment'
14
+ /** `{{{name}}}` and `{{&name}}`: printed raw by Mustache itself. */
15
+ | 'raw'
16
+ /** `{{>partial}}`, `{{=<% %>=}}`, `{{%pragma}}`, `{{$block}}`, `{{<parent}}`. */
17
+ | 'other'
18
+ /** `{{` with no `}}` after it. */
19
+ | 'unclosed';
20
+ export interface MustacheTag {
21
+ kind: MustacheTagKind;
22
+ /** The name inside, trimmed; empty for a comment and for a tag still being typed. */
23
+ name: string;
24
+ /** Offset of the first `{`. */
25
+ from: number;
26
+ /** Offset just past the last `}` — the end of the document for an unclosed tag. */
27
+ to: number;
28
+ }
29
+ /** Every tag of a template, in order. */
30
+ export declare function scanMustache(text: string): MustacheTag[];
31
+ /** The sections open at an offset, the innermost last. */
32
+ export declare function openSections(tags: MustacheTag[], before: number): string[];
33
+ export interface MustacheProblems {
34
+ /** Sections opened and never closed. */
35
+ unclosed: string[];
36
+ /** `{{/name}}` with nothing of that name open. */
37
+ stray: string[];
38
+ /** Names no variable and no field of an open list has — only when variables were given. */
39
+ unknown: string[];
40
+ /** Tags Mustache would read and a template here may not use: partials, delimiters, pragmas. */
41
+ refused: string[];
42
+ /** `{{` that never ends. */
43
+ broken: boolean;
44
+ }
45
+ /**
46
+ * What is wrong with a template as it stands, by the same rules the completion knows: the open
47
+ * list's fields inside its section, the variables everywhere. With no variables the names are not
48
+ * judged — a template for any event may say anything.
49
+ */
50
+ export declare function mustacheProblems(text: string, variables?: MustacheVariable[]): MustacheProblems;
51
+ /** The tags painted as marks over the language underneath. */
52
+ export declare function mustacheHighlighting(): Extension;
53
+ /**
54
+ * Mustache's own suggestions after `{{`: the variables and the fields of the list being looped
55
+ * over, a list as a whole section, `{{#…}}` / `{{^…}}` for "has a value" / "is empty", and after
56
+ * `{{/` the section open nearest. With no variables only the syntax is offered — a template for
57
+ * any event knows no names.
58
+ *
59
+ * Every suggestion ends the tag: the `}}` that closing brackets typed is taken over rather than
60
+ * doubled, and a section is written whole with the caret inside.
61
+ *
62
+ * ```ts
63
+ * <wx-code-editor language="mustache" :completions="mustacheCompletions(variables)" />
64
+ * ```
65
+ */
66
+ export declare function mustacheCompletions(variables?: MustacheVariable[], words?: Partial<MustacheWords>): CodeEditorCompleter;
@@ -1,8 +1,79 @@
1
1
  import { Extension } from '@codemirror/state';
2
2
  import { EditorView } from '@codemirror/view';
3
3
  import { ControlSize, ControlStatus } from '../../composables/useFormField';
4
- /** The languages the editor highlights out of the box. `plain` highlights nothing. */
5
- export type CodeEditorLanguage = 'json' | 'javascript' | 'typescript' | 'html' | 'css' | 'markdown' | 'yaml' | 'php' | 'plain';
4
+ import { LocalizedValue } from '../../composables/useLocalized';
5
+ /** The document, or under `localized` one per language. */
6
+ export type CodeEditorModelValue = string | LocalizedValue | null | undefined;
7
+ /**
8
+ * The languages the editor highlights out of the box. `plain` highlights nothing; `mustache` is
9
+ * Mustache tags over text, `mustache-html` over HTML.
10
+ */
11
+ export type CodeEditorLanguage = 'json' | 'javascript' | 'typescript' | 'html' | 'css' | 'markdown' | 'yaml' | 'php' | 'mustache' | 'mustache-html' | 'plain';
12
+ /** One suggestion of the completion list. */
13
+ export interface CodeEditorCompletion {
14
+ /** What the list shows, and what typing is matched against. */
15
+ label: string;
16
+ /**
17
+ * What goes into the document instead of the label. `${}` marks where the caret lands and
18
+ * `${name}` a field to type over, as in CodeMirror's snippets.
19
+ */
20
+ apply?: string;
21
+ /** A short word beside the label: a type, an example value. */
22
+ detail?: string;
23
+ /** A longer description, shown beside the list for the suggestion in focus. */
24
+ info?: string;
25
+ /** CodeMirror's kind of suggestion — `variable`, `keyword`, `property` and the like. */
26
+ type?: string;
27
+ /** Higher comes first among equally good matches; -99 … 99. */
28
+ boost?: number;
29
+ }
30
+ export interface CodeEditorCompletionContext {
31
+ /** The whole document. */
32
+ text: string;
33
+ /** Where the caret is. */
34
+ pos: number;
35
+ /** Asked for with Ctrl+Space rather than by typing. */
36
+ explicit: boolean;
37
+ }
38
+ export interface CodeEditorCompletionResult {
39
+ /** Where the text the suggestions replace starts. */
40
+ from: number;
41
+ /** Where it ends; the caret when left out. */
42
+ to?: number;
43
+ options: CodeEditorCompletion[];
44
+ }
45
+ /** Suggestions for a place in the document, or `null` for none there. */
46
+ export type CodeEditorCompleter = (context: CodeEditorCompletionContext) => CodeEditorCompletionResult | null;
47
+ /**
48
+ * A fixed vocabulary — completed from the word before the caret — or a function that decides
49
+ * by the document itself, like `mustacheCompletions()`.
50
+ */
51
+ export type CodeEditorCompletions = CodeEditorCompletion[] | CodeEditorCompleter;
52
+ /** A value a Mustache template may use, for `mustacheCompletions()` and `mustacheProblems()`. */
53
+ export interface MustacheVariable {
54
+ /** `name`, `field.phone`; `field.*` for a family of names. */
55
+ name: string;
56
+ /** What it is, in words. */
57
+ label?: string;
58
+ /** A value it may take. */
59
+ example?: unknown;
60
+ /** A list: the fields of each of its elements. */
61
+ fields?: {
62
+ name: string;
63
+ label?: string;
64
+ }[];
65
+ }
66
+ /** The words of the Mustache suggestions — English by default, `:name` filled in. */
67
+ export interface MustacheWords {
68
+ variable: string;
69
+ list: string;
70
+ field: string;
71
+ section: string;
72
+ inverted: string;
73
+ close: string;
74
+ comment: string;
75
+ example: string;
76
+ }
6
77
  export interface CodeEditorDiagnostic {
7
78
  /** Offset of the first character the problem covers. */
8
79
  from: number;
@@ -35,6 +106,16 @@ export interface CodeEditorProps {
35
106
  * Only JSON ships with one; the flag is ignored elsewhere.
36
107
  */
37
108
  lint?: boolean;
109
+ /**
110
+ * Suggestions while typing, and on Ctrl+Space: a list of words, or a function of the document
111
+ * and the caret — `mustacheCompletions(variables)` for a Mustache template.
112
+ */
113
+ completions?: CodeEditorCompletions;
114
+ /**
115
+ * Edits the document in every language the site publishes in, with a selector on the field;
116
+ * the model is then `{ en: '…', uk: '…' }`.
117
+ */
118
+ localized?: boolean;
38
119
  /** Extra CodeMirror extensions, for anything this component does not wrap. */
39
120
  extensions?: Extension[];
40
121
  }
@@ -33,9 +33,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
33
33
  clearable: boolean;
34
34
  status: import('../..').ControlStatus;
35
35
  id: string;
36
- readonly: boolean;
37
- format: string;
38
36
  locale: string | import('../..').DateFnsLocale;
37
+ format: string;
38
+ readonly: boolean;
39
39
  valueFormat: string;
40
40
  minDate: string | Date;
41
41
  maxDate: string | Date;
@@ -32,9 +32,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
32
32
  clearable: boolean;
33
33
  status: import('../..').ControlStatus;
34
34
  id: string;
35
- readonly: boolean;
36
- format: string;
37
35
  locale: string | import('../..').DateFnsLocale;
36
+ format: string;
37
+ readonly: boolean;
38
38
  valueFormat: string;
39
39
  minDate: string | Date;
40
40
  maxDate: string | Date;
@@ -31,9 +31,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
31
31
  clearable: boolean;
32
32
  status: import('../..').ControlStatus;
33
33
  id: string;
34
- readonly: boolean;
35
- format: string;
36
34
  locale: string | import('../..').DateFnsLocale;
35
+ format: string;
36
+ readonly: boolean;
37
37
  valueFormat: string;
38
38
  minDate: string | Date;
39
39
  maxDate: string | Date;
@@ -97,10 +97,10 @@ declare function __VLS_template(): {
97
97
  status: import('..').InputStatus;
98
98
  id: string;
99
99
  readonly: boolean;
100
+ localized: boolean;
100
101
  autocomplete: string;
101
102
  maxlength: number;
102
103
  showCount: boolean;
103
- localized: boolean;
104
104
  tokens: import('../..').TokenOption[];
105
105
  tokensTitle: string;
106
106
  tokensLabel: string;
@@ -134,10 +134,10 @@ declare function __VLS_template(): {
134
134
  status: import('..').InputStatus;
135
135
  id: string;
136
136
  readonly: boolean;
137
+ localized: boolean;
137
138
  autocomplete: string;
138
139
  maxlength: number;
139
140
  showCount: boolean;
140
- localized: boolean;
141
141
  tokens: import('../..').TokenOption[];
142
142
  tokensTitle: string;
143
143
  tokensLabel: string;
@@ -150,7 +150,7 @@ declare function __VLS_template(): {
150
150
  onClear?: (() => any) | undefined;
151
151
  onBlur?: ((event: FocusEvent) => any) | undefined;
152
152
  onFocus?: ((event: FocusEvent) => any) | undefined;
153
- }>, "input" | "select" | "blur" | "focus" | ("size" | "disabled" | "type" | "placeholder" | "ariaLabel" | "clearable" | "status" | "id" | "readonly" | "autocomplete" | "maxlength" | "showCount" | "localized" | "tokens" | "tokensTitle" | "tokensLabel")> & {
153
+ }>, "input" | "select" | "blur" | "focus" | ("size" | "disabled" | "type" | "placeholder" | "ariaLabel" | "clearable" | "status" | "id" | "readonly" | "localized" | "autocomplete" | "maxlength" | "showCount" | "tokens" | "tokensTitle" | "tokensLabel")> & {
154
154
  focus: () => void | undefined;
155
155
  blur: () => void | undefined;
156
156
  select: () => void | undefined;
@@ -286,10 +286,10 @@ declare const __VLS_component: import('vue').DefineComponent<FileCardProps, {},
286
286
  status: import('..').InputStatus;
287
287
  id: string;
288
288
  readonly: boolean;
289
+ localized: boolean;
289
290
  autocomplete: string;
290
291
  maxlength: number;
291
292
  showCount: boolean;
292
- localized: boolean;
293
293
  tokens: import('../..').TokenOption[];
294
294
  tokensTitle: string;
295
295
  tokensLabel: string;
@@ -323,10 +323,10 @@ declare const __VLS_component: import('vue').DefineComponent<FileCardProps, {},
323
323
  status: import('..').InputStatus;
324
324
  id: string;
325
325
  readonly: boolean;
326
+ localized: boolean;
326
327
  autocomplete: string;
327
328
  maxlength: number;
328
329
  showCount: boolean;
329
- localized: boolean;
330
330
  tokens: import('../..').TokenOption[];
331
331
  tokensTitle: string;
332
332
  tokensLabel: string;
@@ -339,7 +339,7 @@ declare const __VLS_component: import('vue').DefineComponent<FileCardProps, {},
339
339
  onClear?: (() => any) | undefined;
340
340
  onBlur?: ((event: FocusEvent) => any) | undefined;
341
341
  onFocus?: ((event: FocusEvent) => any) | undefined;
342
- }>, "input" | "select" | "blur" | "focus" | ("size" | "disabled" | "type" | "placeholder" | "ariaLabel" | "clearable" | "status" | "id" | "readonly" | "autocomplete" | "maxlength" | "showCount" | "localized" | "tokens" | "tokensTitle" | "tokensLabel")> & {
342
+ }>, "input" | "select" | "blur" | "focus" | ("size" | "disabled" | "type" | "placeholder" | "ariaLabel" | "clearable" | "status" | "id" | "readonly" | "localized" | "autocomplete" | "maxlength" | "showCount" | "tokens" | "tokensTitle" | "tokensLabel")> & {
343
343
  focus: () => void | undefined;
344
344
  blur: () => void | undefined;
345
345
  select: () => void | undefined;
@@ -65,6 +65,7 @@ export declare const builtinIcons: {
65
65
  readonly calendar: "<rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"15\" rx=\"2.5\"/><path d=\"M3.5 10h17M8 3.5V7M16 3.5V7\"/>";
66
66
  readonly clock: "<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M12 7.5V12l3 2\"/>";
67
67
  readonly mail: "<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2.5\"/><path d=\"m4 7.5 6.9 5a2 2 0 0 0 2.2 0l6.9-5\"/>";
68
+ readonly send: "<path d=\"M20.5 3.5 3.8 10.4a.6.6 0 0 0 0 1.1l6.3 2.4 2.4 6.3a.6.6 0 0 0 1.1 0Z\"/><path d=\"m10.1 13.9 4.6-4.6\"/>";
68
69
  readonly phone: "<path d=\"M7 3.5 9.5 4l1.2 3.4-1.9 1.6a11 11 0 0 0 5.2 5.2l1.6-1.9 3.4 1.2.5 2.5a2 2 0 0 1-2 2.3A15.5 15.5 0 0 1 4.7 5.5a2 2 0 0 1 2.3-2Z\"/>";
69
70
  readonly bell: "<path d=\"M7 10a5 5 0 0 1 10 0c0 4 1.5 5.5 1.5 5.5h-13S7 14 7 10Z\"/><path d=\"M10.2 18.5a2 2 0 0 0 3.6 0\"/>";
70
71
  readonly 'map-pin': "<path d=\"M12 21s6.5-6 6.5-10.5a6.5 6.5 0 0 0-13 0C5.5 15 12 21 12 21Z\"/><circle cx=\"12\" cy=\"10.3\" r=\"2.4\"/>";
@@ -32,8 +32,8 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {
32
32
  disabled: boolean;
33
33
  footer: boolean;
34
34
  maxWidth: number;
35
- maxHeight: number;
36
35
  format: "auto" | "image/jpeg" | "image/png" | "image/webp";
36
+ maxHeight: number;
37
37
  background: string;
38
38
  filters: boolean;
39
39
  resizable: boolean;
@@ -47,10 +47,10 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
47
47
  status: import('./types').InputStatus;
48
48
  id: string;
49
49
  readonly: boolean;
50
+ localized: boolean;
50
51
  autocomplete: string;
51
52
  maxlength: number;
52
53
  showCount: boolean;
53
- localized: boolean;
54
54
  tokens: TokenOption[];
55
55
  tokensTitle: string;
56
56
  tokensLabel: string;
@@ -31,6 +31,12 @@ export interface SortableListProps<T = unknown> {
31
31
  size?: SortableListSize;
32
32
  /** Drops the frame, for a list that already sits in a card. */
33
33
  plain?: boolean;
34
+ /**
35
+ * Tints the row under the pointer, and the row that holds the current item (`.is-current` or
36
+ * `aria-current` inside it), with the rules either side of a tinted row taken away — a tint
37
+ * cut by a line above and below reads as two rows.
38
+ */
39
+ hoverable?: boolean;
34
40
  /** Shown when there is nothing in the list. */
35
41
  emptyText?: string;
36
42
  /** What the grip is called, before the name of the row it holds. */
@@ -18,8 +18,8 @@ declare const __VLS_component: import('vue').DefineComponent<StatisticProps, {},
18
18
  value: number | string;
19
19
  align: import('..').TextAlign;
20
20
  tone: import('..').TextTone;
21
- precision: number;
22
21
  locale: string;
22
+ precision: number;
23
23
  grouping: boolean;
24
24
  prefix: string;
25
25
  suffix: string;
@@ -30,9 +30,9 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
30
30
  id: string;
31
31
  resize: "none" | "vertical" | "both";
32
32
  readonly: boolean;
33
+ localized: boolean;
33
34
  maxlength: number;
34
35
  showCount: boolean;
35
- localized: boolean;
36
36
  tokens: TokenOption[];
37
37
  tokensTitle: string;
38
38
  tokensLabel: string;
@@ -31,9 +31,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
31
31
  clearable: boolean;
32
32
  status: import('../..').ControlStatus;
33
33
  id: string;
34
- readonly: boolean;
35
- format: string;
36
34
  locale: string | import('../..').DateFnsLocale;
35
+ format: string;
36
+ readonly: boolean;
37
37
  valueFormat: string;
38
38
  minDate: string | Date;
39
39
  maxDate: string | Date;