@webx-ui/core 0.15.0 → 0.17.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.
@@ -0,0 +1,44 @@
1
+ import { Extension } from '@codemirror/state';
2
+ 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>;
44
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { HighlightStyle } from '@codemirror/language';
2
+ /**
3
+ * Syntax colours come from the semantic tokens, so both themes are covered by the
4
+ * same style and a project that re-tints its primary colour re-tints its code too.
5
+ * The palette is deliberately small: five roles, not a rainbow.
6
+ */
7
+ export declare const highlightStyle: HighlightStyle;
@@ -0,0 +1,2 @@
1
+ export { default as WxCodeEditor } from './CodeEditor';
2
+ export type * from './types';
@@ -0,0 +1,14 @@
1
+ import { Extension } from '@codemirror/state';
2
+ import { LintSource } from '@codemirror/lint';
3
+ import { CodeEditorLanguage } from './types';
4
+ interface LanguageSupport {
5
+ extension: () => Extension;
6
+ /** Only JSON has a parser cheap enough to run on every keystroke. */
7
+ linter?: () => LintSource;
8
+ }
9
+ /**
10
+ * Each entry is a factory rather than an instance: language support carries
11
+ * state fields, and CodeMirror expects a fresh one per editor.
12
+ */
13
+ export declare const LANGUAGES: Record<CodeEditorLanguage, LanguageSupport>;
14
+ export {};
@@ -0,0 +1,56 @@
1
+ import { Extension } from '@codemirror/state';
2
+ import { EditorView } from '@codemirror/view';
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';
6
+ export interface CodeEditorDiagnostic {
7
+ /** Offset of the first character the problem covers. */
8
+ from: number;
9
+ /** Offset just past the last character it covers. */
10
+ to: number;
11
+ severity: 'error' | 'warning' | 'info' | 'hint';
12
+ message: string;
13
+ }
14
+ export interface CodeEditorProps {
15
+ language?: CodeEditorLanguage;
16
+ placeholder?: string;
17
+ disabled?: boolean;
18
+ readonly?: boolean;
19
+ size?: ControlSize;
20
+ status?: ControlStatus;
21
+ id?: string;
22
+ /** Accessible label used when there is no visible `<label>`. */
23
+ ariaLabel?: string;
24
+ /** Height of the editing area before it starts growing. */
25
+ minHeight?: string;
26
+ /** Height at which the editor stops growing and scrolls instead. */
27
+ maxHeight?: string;
28
+ lineNumbers?: boolean;
29
+ /** Wrap long lines instead of scrolling horizontally. */
30
+ lineWrapping?: boolean;
31
+ /** Width of one indentation step, in spaces; Tab inserts this many. */
32
+ tabSize?: number;
33
+ /**
34
+ * Check the document with the language's own linter and underline what it finds.
35
+ * Only JSON ships with one; the flag is ignored elsewhere.
36
+ */
37
+ lint?: boolean;
38
+ /** Extra CodeMirror extensions, for anything this component does not wrap. */
39
+ extensions?: Extension[];
40
+ }
41
+ export interface CodeEditorEmits {
42
+ change: [value: string];
43
+ focus: [];
44
+ blur: [];
45
+ /** The linter ran; an empty list means the document is valid. */
46
+ lint: [diagnostics: CodeEditorDiagnostic[]];
47
+ }
48
+ export interface CodeEditorExposed {
49
+ view: EditorView | null;
50
+ focus: () => void;
51
+ /**
52
+ * Re-indents a JSON document with `tabSize` spaces. Returns `false` and leaves the
53
+ * text alone when it does not parse or the language is not JSON.
54
+ */
55
+ format: () => boolean;
56
+ }
@@ -19,7 +19,7 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
19
19
  clearable: boolean;
20
20
  status: import('../..').ControlStatus;
21
21
  id: string;
22
- presets: string[];
23
22
  readonly: boolean;
23
+ presets: string[];
24
24
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
25
  export default _default;
@@ -28,9 +28,9 @@ declare const __VLS_component: import('vue').DefineComponent<CountdownProps, {
28
28
  title: string;
29
29
  tone: import('..').TextTone;
30
30
  align: import('..').TextAlign;
31
+ format: string;
31
32
  prefix: string;
32
33
  suffix: string;
33
- format: string;
34
34
  interval: number;
35
35
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
36
36
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -82,10 +82,10 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
82
82
  closeLabel: string;
83
83
  width: number | string;
84
84
  scroll: import('./types').DialogScroll;
85
+ minHeight: number;
85
86
  height: number | string;
86
87
  stickyFooter: boolean;
87
88
  minWidth: number;
88
- minHeight: number;
89
89
  sidebarWidth: number | string;
90
90
  closeOnOverlay: boolean;
91
91
  closeOnEscape: boolean;
@@ -31,8 +31,9 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {
31
31
  }>, {
32
32
  disabled: boolean;
33
33
  footer: boolean;
34
- background: string;
34
+ maxHeight: number;
35
35
  format: "auto" | "image/jpeg" | "image/png" | "image/webp";
36
+ background: string;
36
37
  filters: boolean;
37
38
  resizable: boolean;
38
39
  minSize: number;
@@ -45,7 +46,6 @@ declare const _default: import('vue').DefineComponent<ImageEditorProps, {
45
46
  ratios: (ImageEditorRatio | ImageEditorRatioOption)[];
46
47
  rotatable: boolean;
47
48
  flippable: boolean;
48
- maxHeight: number;
49
49
  quality: number;
50
50
  crossOrigin: "anonymous" | "use-credentials" | "";
51
51
  resetLabel: string;
@@ -29,8 +29,8 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
29
29
  id: string;
30
30
  max: number;
31
31
  wheel: boolean;
32
- min: number;
33
32
  readonly: boolean;
33
+ min: number;
34
34
  step: number;
35
35
  precision: number;
36
36
  controls: boolean;
@@ -23,8 +23,8 @@ declare const __VLS_component: import('vue').DefineComponent<ScrollbarProps, {
23
23
  }>, {
24
24
  size: import('./types').ScrollbarSize;
25
25
  always: boolean;
26
- height: number | string;
27
26
  maxHeight: number | string;
27
+ height: number | string;
28
28
  axis: import('./types').ScrollbarAxis;
29
29
  chainScroll: boolean;
30
30
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
@@ -47,6 +47,11 @@ declare const _default: <T extends TableRow = TableRow>(__VLS_props: NonNullable
47
47
  row: T;
48
48
  index: number;
49
49
  }) => unknown;
50
+ /** Buttons along the top of a card, where a row has no room for a column of them. */
51
+ 'card-actions'?: (props: {
52
+ row: T;
53
+ index: number;
54
+ }) => unknown;
50
55
  }> & {
51
56
  [key: `header-${string}`]: ((props: {
52
57
  column: TableColumn<T>;
@@ -70,6 +75,11 @@ declare const _default: <T extends TableRow = TableRow>(__VLS_props: NonNullable
70
75
  row: T;
71
76
  index: number;
72
77
  }) => unknown;
78
+ /** Buttons along the top of a card, where a row has no room for a column of them. */
79
+ 'card-actions'?: (props: {
80
+ row: T;
81
+ index: number;
82
+ }) => unknown;
73
83
  };
74
84
  emit: (((evt: "search", term: string) => void) & ((evt: "row-click", row: T, index: number, event: MouseEvent) => void) & ((evt: "sort-change", sort: TableSort | null) => void) & ((evt: "selection-change", keys: RowKey[], rows: T[]) => void) & ((evt: "expand-change", keys: RowKey[], rows: T[]) => void) & ((evt: "node-drop", event: import('./types').TableNodeDropEvent<T>) => void) & ((evt: "state-change", state: TableState) => void)) & (((evt: "update:page", value: number) => void) & ((evt: "update:perPage", value: number) => void) & ((evt: "update:selected", value: RowKey[]) => void) & ((evt: "update:expanded", value: RowKey[]) => void) & ((evt: "update:sort", value: TableSort | null) => void) & ((evt: "update:search", value: string) => void));
75
85
  }>) => import('vue').VNode & {
@@ -50,6 +50,21 @@ export interface TableColumn<T = TableRow> {
50
50
  cellClass?: string;
51
51
  /** Leaves the column out without changing the array. */
52
52
  hidden?: boolean;
53
+ /**
54
+ * Drops the column while the table is narrower than this.
55
+ *
56
+ * The alternative is a horizontal scrollbar, and a column somebody has to drag sideways to
57
+ * read is a column they will not read. Say it about the ones that can go — a date, a count —
58
+ * and the ones that identify the row stay whatever the width.
59
+ */
60
+ hideBelow?: number;
61
+ /**
62
+ * Leaves the column out of a card, where space is the scarce thing.
63
+ *
64
+ * A date somebody scans down a column is worth a line of its own on a wide screen and is the
65
+ * first thing to go on a narrow one.
66
+ */
67
+ hideOnCards?: boolean;
53
68
  }
54
69
  /**
55
70
  * One line of the summary under the table. `label` occupies every column ahead of the
@@ -158,6 +173,21 @@ export interface TableProps<T = TableRow> {
158
173
  expandableIf?: (row: T) => boolean;
159
174
  /** Lines under the table: totals, discounts, whatever the figures are. */
160
175
  summary?: TableSummaryRow[];
176
+ /**
177
+ * Below this width — of the table, not the window — each row is drawn as a card instead.
178
+ *
179
+ * A table narrower than about forty characters is a row of columns nobody can read, and on a
180
+ * phone that is every table. `0` turns it off and keeps the columns at any width.
181
+ */
182
+ cardsBelow?: number;
183
+ /**
184
+ * Drops the table's own margins around the header and the cards.
185
+ *
186
+ * On its own the table is a surface, and its search field and cards keep clear of its rounded
187
+ * edge. Inside a card the card keeps the margins already, and a second set puts the search
188
+ * field a step in from whatever the card has above it.
189
+ */
190
+ flush?: boolean;
161
191
  /**
162
192
  * Puts the pagination in the footer. On by default as soon as `data` is a paginator,
163
193
  * since a paginated response is a promise that there are more pages to reach.
@@ -13,10 +13,10 @@ declare const __VLS_component: import('vue').DefineComponent<TextProps, {}, {},
13
13
  as: string;
14
14
  tone: import('./types').TextTone;
15
15
  align: import('./types').TextAlign;
16
+ italic: boolean;
16
17
  truncate: boolean | number;
17
18
  mono: boolean;
18
19
  weight: import('./types').TextWeight;
19
- italic: boolean;
20
20
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
21
21
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
22
22
  export default _default;
@@ -31,8 +31,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
31
31
  align: import('./types').TooltipAlign;
32
32
  offset: number;
33
33
  teleport: boolean;
34
- arrow: boolean;
35
34
  delay: number;
35
+ arrow: boolean;
36
36
  maxWidth: number | string;
37
37
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -54,12 +54,12 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps,
54
54
  multiple: boolean;
55
55
  disabled: boolean;
56
56
  max: number;
57
+ hint: string;
57
58
  removable: boolean;
58
59
  accept: string;
59
60
  maxSize: number;
60
61
  buttonOnly: boolean;
61
62
  buttonText: string;
62
- hint: string;
63
63
  gallery: boolean;
64
64
  beforeAdd: (file: File) => boolean | Promise<boolean>;
65
65
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
@@ -17,6 +17,7 @@ export * from './ButtonGroup';
17
17
  export * from './Card';
18
18
  export * from './Cascader';
19
19
  export * from './Checkbox';
20
+ export * from './CodeEditor';
20
21
  export * from './CheckboxGroup';
21
22
  export * from './Col';
22
23
  export * from './ColorPicker';