@webx-ui/core 0.0.2 → 0.1.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 (69) hide show
  1. package/dist/components/Card/Card.d.ts +3 -1
  2. package/dist/components/Card/types.d.ts +2 -2
  3. package/dist/components/Checkbox/Checkbox.d.ts +41 -0
  4. package/dist/components/Checkbox/index.d.ts +2 -0
  5. package/dist/components/Checkbox/types.d.ts +18 -0
  6. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +37 -0
  7. package/dist/components/CheckboxGroup/index.d.ts +2 -0
  8. package/dist/components/CheckboxGroup/types.d.ts +23 -0
  9. package/dist/components/ColorPicker/ColorPicker.d.ts +25 -0
  10. package/dist/components/ColorPicker/index.d.ts +2 -0
  11. package/dist/components/ColorPicker/types.d.ts +21 -0
  12. package/dist/components/DatePicker/DatePicker.d.ts +54 -0
  13. package/dist/components/DatePicker/index.d.ts +2 -0
  14. package/dist/components/DatePicker/types.d.ts +47 -0
  15. package/dist/components/DateRangePicker/DateRangePicker.d.ts +51 -0
  16. package/dist/components/DateRangePicker/index.d.ts +2 -0
  17. package/dist/components/DateRangePicker/types.d.ts +37 -0
  18. package/dist/components/DateTimePicker/DateTimePicker.d.ts +52 -0
  19. package/dist/components/DateTimePicker/index.d.ts +1 -0
  20. package/dist/components/Form/Form.d.ts +32 -0
  21. package/dist/components/Form/index.d.ts +2 -0
  22. package/dist/components/Form/types.d.ts +22 -0
  23. package/dist/components/FormItem/FormItem.d.ts +33 -0
  24. package/dist/components/FormItem/index.d.ts +2 -0
  25. package/dist/components/FormItem/types.d.ts +24 -0
  26. package/dist/components/Input/Input.d.ts +11 -10
  27. package/dist/components/Input/types.d.ts +2 -0
  28. package/dist/components/InputNumber/InputNumber.d.ts +41 -0
  29. package/dist/components/InputNumber/index.d.ts +2 -0
  30. package/dist/components/InputNumber/types.d.ts +34 -0
  31. package/dist/components/Radio/Radio.d.ts +36 -0
  32. package/dist/components/Radio/index.d.ts +2 -0
  33. package/dist/components/Radio/types.d.ts +16 -0
  34. package/dist/components/RadioGroup/RadioGroup.d.ts +35 -0
  35. package/dist/components/RadioGroup/index.d.ts +2 -0
  36. package/dist/components/RadioGroup/types.d.ts +19 -0
  37. package/dist/components/Rate/Rate.d.ts +24 -0
  38. package/dist/components/Rate/index.d.ts +2 -0
  39. package/dist/components/Rate/types.d.ts +22 -0
  40. package/dist/components/RichText/RichText.d.ts +38 -0
  41. package/dist/components/RichText/ToolbarButton.d.ts +20 -0
  42. package/dist/components/RichText/icons.d.ts +6 -0
  43. package/dist/components/RichText/index.d.ts +2 -0
  44. package/dist/components/RichText/tools.d.ts +48 -0
  45. package/dist/components/RichText/types.d.ts +42 -0
  46. package/dist/components/Select/Select.d.ts +50 -0
  47. package/dist/components/Select/index.d.ts +2 -0
  48. package/dist/components/Select/types.d.ts +41 -0
  49. package/dist/components/Slider/Slider.d.ts +26 -0
  50. package/dist/components/Slider/index.d.ts +2 -0
  51. package/dist/components/Slider/types.d.ts +24 -0
  52. package/dist/components/Switch/Switch.d.ts +38 -0
  53. package/dist/components/Switch/index.d.ts +2 -0
  54. package/dist/components/Switch/types.d.ts +18 -0
  55. package/dist/components/TagsInput/TagsInput.d.ts +32 -0
  56. package/dist/components/TagsInput/index.d.ts +2 -0
  57. package/dist/components/TagsInput/types.d.ts +26 -0
  58. package/dist/components/Textarea/Textarea.d.ts +39 -0
  59. package/dist/components/Textarea/index.d.ts +2 -0
  60. package/dist/components/Textarea/types.d.ts +31 -0
  61. package/dist/components/TimePicker/TimePicker.d.ts +52 -0
  62. package/dist/components/TimePicker/index.d.ts +1 -0
  63. package/dist/components/index.d.ts +20 -1
  64. package/dist/composables/useFormField.d.ts +64 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +2418 -164
  67. package/dist/index.js.map +1 -1
  68. package/dist/style.css +1 -1
  69. package/package.json +12 -2
@@ -0,0 +1,32 @@
1
+ import { TagsInputProps } from './types';
2
+ type __VLS_Props = TagsInputProps;
3
+ type __VLS_PublicProps = {
4
+ modelValue?: string[];
5
+ } & __VLS_Props;
6
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
7
+ focus: () => void | undefined;
8
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ search: (term: string) => any;
10
+ change: (value: string[]) => any;
11
+ "update:modelValue": (value: string[]) => any;
12
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
+ onSearch?: ((term: string) => any) | undefined;
14
+ onChange?: ((value: string[]) => any) | undefined;
15
+ "onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
16
+ }>, {
17
+ name: string;
18
+ size: import('../..').ControlSize;
19
+ disabled: boolean;
20
+ id: string;
21
+ ariaLabel: string;
22
+ max: number;
23
+ placeholder: string;
24
+ status: import('../..').ControlStatus;
25
+ emptyText: string;
26
+ suggestions: string[];
27
+ duplicates: boolean;
28
+ allowCreate: boolean;
29
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
30
+ inputRef: HTMLInputElement;
31
+ }, any>;
32
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as WxTagsInput } from './TagsInput';
2
+ export type * from './types';
@@ -0,0 +1,26 @@
1
+ import { ControlSize, ControlStatus } from '../../composables/useFormField';
2
+ export interface TagsInputProps {
3
+ /** Options offered while typing. Refresh them from the `search` event for a backend. */
4
+ suggestions?: string[];
5
+ placeholder?: string;
6
+ /** Shown when nothing matches and new tags are not allowed. */
7
+ emptyText?: string;
8
+ /** Largest number of tags the user may end up with. */
9
+ max?: number;
10
+ /** Allow the same tag twice. */
11
+ duplicates?: boolean;
12
+ /** Let Enter add a tag that is not in the suggestions. */
13
+ allowCreate?: boolean;
14
+ disabled?: boolean;
15
+ size?: ControlSize;
16
+ status?: ControlStatus;
17
+ id?: string;
18
+ name?: string;
19
+ /** Accessible label used when there is no visible `<label>`. */
20
+ ariaLabel?: string;
21
+ }
22
+ export interface TagsInputEmits {
23
+ change: [value: string[]];
24
+ /** What the user typed, on every keystroke — use it to fetch suggestions. */
25
+ search: [term: string];
26
+ }
@@ -0,0 +1,39 @@
1
+ import { TextareaModelValue, TextareaProps } from './types';
2
+ type __VLS_Props = TextareaProps;
3
+ type __VLS_PublicProps = {
4
+ modelValue?: TextareaModelValue;
5
+ } & __VLS_Props;
6
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
7
+ focus: () => void | undefined;
8
+ blur: () => void | undefined;
9
+ select: () => void | undefined;
10
+ textarea: import('vue').Ref<HTMLTextAreaElement | null, HTMLTextAreaElement | null>;
11
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
12
+ input: (value: string) => any;
13
+ change: (value: string) => any;
14
+ "update:modelValue": (value: TextareaModelValue) => any;
15
+ blur: (event: FocusEvent) => any;
16
+ focus: (event: FocusEvent) => any;
17
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ onInput?: ((value: string) => any) | undefined;
19
+ onChange?: ((value: string) => any) | undefined;
20
+ "onUpdate:modelValue"?: ((value: TextareaModelValue) => any) | undefined;
21
+ onBlur?: ((event: FocusEvent) => any) | undefined;
22
+ onFocus?: ((event: FocusEvent) => any) | undefined;
23
+ }>, {
24
+ size: import('../..').ControlSize;
25
+ disabled: boolean;
26
+ id: string;
27
+ ariaLabel: string;
28
+ placeholder: string;
29
+ readonly: boolean;
30
+ status: import('../..').ControlStatus;
31
+ maxlength: number;
32
+ showCount: boolean;
33
+ resize: "none" | "vertical" | "both";
34
+ rows: number;
35
+ autosize: boolean | import('./types').AutosizeOptions;
36
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
37
+ textareaRef: HTMLTextAreaElement;
38
+ }, any>;
39
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as WxTextarea } from './Textarea';
2
+ export type * from './types';
@@ -0,0 +1,31 @@
1
+ import { ControlSize, ControlStatus } from '../../composables/useFormField';
2
+ export interface AutosizeOptions {
3
+ minRows?: number;
4
+ maxRows?: number;
5
+ }
6
+ export interface TextareaProps {
7
+ size?: ControlSize;
8
+ status?: ControlStatus;
9
+ id?: string;
10
+ placeholder?: string;
11
+ disabled?: boolean;
12
+ readonly?: boolean;
13
+ /** Visible rows when autosize is off. */
14
+ rows?: number;
15
+ /** Grows with the content. Pass an object to bound the growth. */
16
+ autosize?: boolean | AutosizeOptions;
17
+ maxlength?: number;
18
+ /** Renders a `current / max` counter (requires `maxlength`). */
19
+ showCount?: boolean;
20
+ /** Which way the user may resize the field by hand. */
21
+ resize?: 'none' | 'vertical' | 'both';
22
+ /** Accessible label used when the field has no visible `<label>`. */
23
+ ariaLabel?: string;
24
+ }
25
+ export type TextareaModelValue = string | undefined;
26
+ export interface TextareaEmits {
27
+ input: [value: string];
28
+ change: [value: string];
29
+ focus: [event: FocusEvent];
30
+ blur: [event: FocusEvent];
31
+ }
@@ -0,0 +1,52 @@
1
+ import { DatePickerModelValue, DatePickerProps } from '../DatePicker/types';
2
+ /**
3
+ * Every prop defaults to `undefined` on purpose. Vue casts an absent boolean prop
4
+ * to `false`, and this preset forwards its whole prop object — without these the
5
+ * preset would hand `WxDatePicker` an explicit `false` for `is24`, `clearable`,
6
+ * `autoApply` and `teleport`, overriding that component's own defaults. Passing
7
+ * `undefined` lets each default apply as if the prop had never been written.
8
+ */
9
+ type __VLS_Props = Omit<DatePickerProps, 'type'>;
10
+ type __VLS_PublicProps = {
11
+ modelValue?: DatePickerModelValue;
12
+ } & __VLS_Props;
13
+ declare function __VLS_template(): {
14
+ attrs: Partial<{}>;
15
+ slots: any;
16
+ refs: {};
17
+ rootEl: any;
18
+ };
19
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
20
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
21
+ "update:modelValue": (value: DatePickerModelValue) => any;
22
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
23
+ "onUpdate:modelValue"?: ((value: DatePickerModelValue) => any) | undefined;
24
+ }>, {
25
+ name: string;
26
+ size: import('../..').ControlSize;
27
+ disabled: boolean;
28
+ id: string;
29
+ ariaLabel: string;
30
+ clearable: boolean;
31
+ placeholder: string;
32
+ teleport: boolean | string;
33
+ readonly: boolean;
34
+ status: import('../..').ControlStatus;
35
+ valueFormat: string;
36
+ format: string;
37
+ minDate: string | Date;
38
+ maxDate: string | Date;
39
+ seconds: boolean;
40
+ minutesIncrement: number;
41
+ is24: boolean;
42
+ weekStart: number;
43
+ autoApply: boolean;
44
+ textInput: boolean;
45
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
46
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
47
+ export default _default;
48
+ type __VLS_WithTemplateSlots<T, S> = T & {
49
+ new (): {
50
+ $slots: S;
51
+ };
52
+ };
@@ -0,0 +1 @@
1
+ export { default as WxTimePicker } from './TimePicker';
@@ -1,3 +1,22 @@
1
1
  export * from './Button';
2
- export * from './Input';
3
2
  export * from './Card';
3
+ export * from './Checkbox';
4
+ export * from './CheckboxGroup';
5
+ export * from './ColorPicker';
6
+ export * from './DatePicker';
7
+ export * from './DateRangePicker';
8
+ export * from './DateTimePicker';
9
+ export * from './Form';
10
+ export * from './FormItem';
11
+ export * from './Input';
12
+ export * from './InputNumber';
13
+ export * from './Radio';
14
+ export * from './RadioGroup';
15
+ export * from './Rate';
16
+ export * from './RichText';
17
+ export * from './Select';
18
+ export * from './Slider';
19
+ export * from './Switch';
20
+ export * from './TagsInput';
21
+ export * from './Textarea';
22
+ export * from './TimePicker';
@@ -0,0 +1,64 @@
1
+ import { ComputedRef, InjectionKey, Ref } from 'vue';
2
+ export type ControlSize = 'sm' | 'md' | 'lg';
3
+ export type ControlStatus = 'default' | 'success' | 'warning' | 'error';
4
+ /** Field name -> messages, the shape Laravel returns on a 422. */
5
+ export type ValidationErrors = Record<string, string[]>;
6
+ export interface FormContext {
7
+ /** Server-side errors, keyed by field name. */
8
+ errors: Ref<ValidationErrors>;
9
+ disabled: Ref<boolean>;
10
+ size: Ref<ControlSize>;
11
+ labelPosition: Ref<'top' | 'left'>;
12
+ labelWidth: Ref<string | undefined>;
13
+ }
14
+ export interface FormItemContext {
15
+ /** Id given to the control, so the label's `for` matches. */
16
+ id: ComputedRef<string>;
17
+ /** Ids of the help and error nodes, for `aria-describedby`. */
18
+ describedBy: ComputedRef<string | undefined>;
19
+ status: ComputedRef<ControlStatus>;
20
+ disabled: ComputedRef<boolean>;
21
+ size: ComputedRef<ControlSize | undefined>;
22
+ /** Set by grouped controls so the label points at the group, not one input. */
23
+ registerLabelTarget: (id: string | undefined) => void;
24
+ }
25
+ export declare const formContextKey: InjectionKey<FormContext>;
26
+ export declare const formItemContextKey: InjectionKey<FormItemContext>;
27
+ export declare function useId(prefix?: string): string;
28
+ export interface FormFieldProps {
29
+ disabled?: boolean;
30
+ size?: ControlSize;
31
+ status?: ControlStatus;
32
+ id?: string;
33
+ }
34
+ /**
35
+ * Resolves what a control should render as, given its own props, the enclosing
36
+ * `WxFormItem` and the enclosing `WxForm`. The control's own prop always wins;
37
+ * `WxFormItem` beats `WxForm`.
38
+ */
39
+ export declare function useFormField(props: FormFieldProps): {
40
+ id: ComputedRef<string>;
41
+ disabled: ComputedRef<boolean>;
42
+ size: ComputedRef<ControlSize>;
43
+ status: ComputedRef<ControlStatus>;
44
+ describedBy: ComputedRef<string | undefined>;
45
+ form: FormContext | null;
46
+ item: FormItemContext | null;
47
+ };
48
+ /**
49
+ * What a checkbox, radio or switch may carry. Deliberately narrower than `unknown`:
50
+ * a `v-model` that hands back `unknown` is useless to the caller, and object values
51
+ * would need identity comparison rather than `===`.
52
+ */
53
+ export type ChoiceValue = string | number | boolean | null;
54
+ /** Used by `WxCheckboxGroup` / `WxRadioGroup` to share state with their children. */
55
+ export interface ChoiceGroupContext<T> {
56
+ name: ComputedRef<string | undefined>;
57
+ modelValue: Ref<T>;
58
+ disabled: ComputedRef<boolean>;
59
+ size: ComputedRef<ControlSize>;
60
+ toggle: (value: ChoiceValue, checked: boolean) => void;
61
+ }
62
+ export declare const checkboxGroupKey: InjectionKey<ChoiceGroupContext<ChoiceValue[]>>;
63
+ export declare const radioGroupKey: InjectionKey<ChoiceGroupContext<ChoiceValue | undefined>>;
64
+ export declare function provideFormItem(context: FormItemContext): void;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './components';
2
2
  export { WebxUI, type WebxUiOptions } from './plugin';
3
+ export type { ControlSize, ControlStatus, ValidationErrors } from './composables/useFormField';