@m3ui-vue/m3ui-vue 1.6.1 → 1.7.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.
- package/dist/API.md +649 -28
- package/dist/{MButton-OQ4wIERQ.js → MButton-CN3wYwIG.js} +2 -2
- package/dist/{MButton-OQ4wIERQ.js.map → MButton-CN3wYwIG.js.map} +1 -1
- package/dist/MColorPickerModal-BKM1CHxr.js +577 -0
- package/dist/MColorPickerModal-BKM1CHxr.js.map +1 -0
- package/dist/{MDialog-DYMnaBlt.js → MDialog-1LAk9WAO.js} +2 -2
- package/dist/{MDialog-DYMnaBlt.js.map → MDialog-1LAk9WAO.js.map} +1 -1
- package/dist/{MListItem-D2cNUyzP.js → MListItem-BU5KDRCB.js} +376 -270
- package/dist/MListItem-BU5KDRCB.js.map +1 -0
- package/dist/{MLoadingIndicator-DWUj0BAB.js → MLoadingIndicator-RykOo5tf.js} +2 -2
- package/dist/{MLoadingIndicator-DWUj0BAB.js.map → MLoadingIndicator-RykOo5tf.js.map} +1 -1
- package/dist/{MSeekBar-C4cn9RIF.js → MSeekBar-B_Y3MpVz.js} +2 -2
- package/dist/{MSeekBar-C4cn9RIF.js.map → MSeekBar-B_Y3MpVz.js.map} +1 -1
- package/dist/MSegmentedButton-CiOOY1-N.js +105 -0
- package/dist/MSegmentedButton-CiOOY1-N.js.map +1 -0
- package/dist/MSlider-BCeVIxcq.js +739 -0
- package/dist/MSlider-BCeVIxcq.js.map +1 -0
- package/dist/{MSpinner-DZkXZJpc.js → MSpinner-Cs03qoqE.js} +2 -2
- package/dist/{MSpinner-DZkXZJpc.js.map → MSpinner-Cs03qoqE.js.map} +1 -1
- package/dist/{MTextField-CNH-byir.js → MTextField-NaFbMkjv.js} +162 -115
- package/dist/MTextField-NaFbMkjv.js.map +1 -0
- package/dist/MTooltip-CK39Zon4.js +183 -0
- package/dist/MTooltip-CK39Zon4.js.map +1 -0
- package/dist/_useFieldValidation-Bz34IAQY.js +191 -0
- package/dist/_useFieldValidation-Bz34IAQY.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +184 -103
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAddressField.vue.d.ts +18 -3
- package/dist/components/MAppBarWithSearch.vue.d.ts +1 -1
- package/dist/components/MAudioRecorder.vue.d.ts +2 -2
- package/dist/components/MAutocomplete.vue.d.ts +22 -3
- package/dist/components/MCheckbox.vue.d.ts +23 -1
- package/dist/components/MCodeEditor.vue.d.ts +23 -1
- package/dist/components/MColorPicker.vue.d.ts +24 -3
- package/dist/components/MConfirmDialog.vue.d.ts +2 -2
- package/dist/components/MCountrySelect.vue.d.ts +13 -2
- package/dist/components/MCreditCardInput.vue.d.ts +33 -0
- package/dist/components/MCronField.vue.d.ts +23 -1
- package/dist/components/MDataTable.vue.d.ts +1 -1
- package/dist/components/MDatePicker.vue.d.ts +24 -3
- package/dist/components/MDateRangePicker.vue.d.ts +24 -3
- package/dist/components/MFileUpload.vue.d.ts +23 -2
- package/dist/components/MForm.vue.d.ts +61 -0
- package/dist/components/MJsonEditor.vue.d.ts +23 -1
- package/dist/components/MMapRoute.vue.d.ts +168 -0
- package/dist/components/MMaskField.vue.d.ts +20 -2
- package/dist/components/MMentionField.vue.d.ts +13 -2
- package/dist/components/MMultiAutocomplete.vue.d.ts +22 -3
- package/dist/components/MMultiSelect.vue.d.ts +22 -3
- package/dist/components/MNavigationRail.vue.d.ts +1 -1
- package/dist/components/MNotificationCenter.vue.d.ts +2 -2
- package/dist/components/MNumberField.vue.d.ts +20 -2
- package/dist/components/MPhoneInput.vue.d.ts +19 -4
- package/dist/components/MPinInput.vue.d.ts +24 -3
- package/dist/components/MPosKeypad.vue.d.ts +2 -2
- package/dist/components/MRadioGroup.vue.d.ts +23 -1
- package/dist/components/MRating.vue.d.ts +23 -1
- package/dist/components/MRichTextEditor.vue.d.ts +23 -1
- package/dist/components/MSearchBar.vue.d.ts +1 -1
- package/dist/components/MSegmentedButton.vue.d.ts +23 -2
- package/dist/components/MSelect.vue.d.ts +22 -3
- package/dist/components/MSignaturePad.vue.d.ts +19 -0
- package/dist/components/MSlider.vue.d.ts +23 -1
- package/dist/components/MSwitch.vue.d.ts +23 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTagInput.vue.d.ts +20 -2
- package/dist/components/MText.vue.d.ts +1 -1
- package/dist/components/MTextField.vue.d.ts +26 -3
- package/dist/components/MTimePicker.vue.d.ts +24 -3
- package/dist/components/MTimezoneSelect.vue.d.ts +13 -2
- package/dist/components/MTour.vue.d.ts +2 -2
- package/dist/components/MTrackingTimeline.vue.d.ts +75 -0
- package/dist/components/MWindow.vue.d.ts +2 -2
- package/dist/composables/_routeGeometry.d.ts +26 -0
- package/dist/composables/_useFieldValidation.d.ts +91 -0
- package/dist/composables/mapRouting.d.ts +35 -0
- package/dist/composables/useLocale.d.ts +23 -0
- package/dist/composables/validation.d.ts +82 -0
- package/dist/draw.js +27 -26
- package/dist/draw.js.map +1 -1
- package/dist/flow.js +1 -1
- package/dist/gantt.js +2 -2
- package/dist/index.d.ts +5 -0
- package/dist/locales/index.js +154 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +7350 -6183
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +4 -0
- package/dist/map.js +1319 -867
- package/dist/map.js.map +1 -1
- package/dist/media.js +4 -4
- package/dist/pdf.js +4 -4
- package/dist/rich-text-editor.js +189 -146
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-DaVSTdm0.js → useLocale-Dh1xZZ8i.js} +22 -1
- package/dist/useLocale-Dh1xZZ8i.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MForm.test.ts +325 -0
- package/src/__tests__/MMapRoute.test.ts +384 -0
- package/src/__tests__/MPhoneInput.test.ts +5 -2
- package/src/__tests__/MRichTextEditor.test.ts +2 -1
- package/src/__tests__/MTrackingTimeline.test.ts +66 -0
- package/src/__tests__/_fakeMaplibre.ts +4 -1
- package/src/__tests__/_osrmRoutes.ts +10 -0
- package/src/__tests__/attrsFallthrough.test.ts +11 -0
- package/src/__tests__/fieldsValidation.test.ts +229 -0
- package/src/__tests__/ssr.test.ts +1 -0
- package/src/__tests__/validation.test.ts +77 -0
- package/src/components/MAddressField.vue +45 -8
- package/src/components/MAudioRecorder.vue +9 -9
- package/src/components/MAutocomplete.vue +69 -23
- package/src/components/MCheckbox.vue +80 -17
- package/src/components/MCodeEditor.vue +59 -2
- package/src/components/MColorPicker.vue +65 -16
- package/src/components/MCountrySelect.vue +17 -3
- package/src/components/MCreditCardInput.vue +76 -7
- package/src/components/MCronField.vue +60 -10
- package/src/components/MDatePicker.vue +65 -16
- package/src/components/MDateRangePicker.vue +66 -16
- package/src/components/MFileUpload.vue +71 -8
- package/src/components/MForm.vue +208 -0
- package/src/components/MJsonEditor.vue +57 -3
- package/src/components/MMapBaseLayers.vue +29 -28
- package/src/components/MMapMeasure.vue +1 -1
- package/src/components/MMapRoute.vue +470 -0
- package/src/components/MMaskField.vue +55 -13
- package/src/components/MMentionField.vue +17 -2
- package/src/components/MMultiAutocomplete.vue +70 -23
- package/src/components/MMultiSelect.vue +70 -23
- package/src/components/MNumberField.vue +58 -16
- package/src/components/MPhoneInput.vue +60 -18
- package/src/components/MPinInput.vue +58 -10
- package/src/components/MRadioGroup.vue +65 -4
- package/src/components/MRating.vue +62 -6
- package/src/components/MRichTextEditor.vue +64 -4
- package/src/components/MSegmentedButton.vue +59 -2
- package/src/components/MSelect.vue +72 -26
- package/src/components/MSignaturePad.vue +71 -6
- package/src/components/MSlider.vue +61 -10
- package/src/components/MSwitch.vue +63 -8
- package/src/components/MTagInput.vue +67 -25
- package/src/components/MTextField.vue +68 -14
- package/src/components/MTimePicker.vue +65 -16
- package/src/components/MTimezoneSelect.vue +17 -3
- package/src/components/MTrackingTimeline.vue +257 -0
- package/src/composables/_routeGeometry.ts +140 -0
- package/src/composables/_useFieldValidation.ts +287 -0
- package/src/composables/mapRouting.ts +55 -0
- package/src/composables/useLocale.ts +46 -0
- package/src/composables/validation.ts +178 -0
- package/src/index.ts +5 -0
- package/src/locales/de.ts +21 -0
- package/src/locales/es.ts +28 -7
- package/src/locales/fr.ts +21 -0
- package/src/locales/ja.ts +21 -0
- package/src/locales/ko.ts +21 -0
- package/src/locales/pt.ts +21 -0
- package/src/locales/zh.ts +21 -0
- package/src/map.ts +4 -0
- package/dist/MListItem-D2cNUyzP.js.map +0 -1
- package/dist/MSegmentedButton-BEB4gXLA.js +0 -64
- package/dist/MSegmentedButton-BEB4gXLA.js.map +0 -1
- package/dist/MSlider-BIkA6DiE.js +0 -690
- package/dist/MSlider-BIkA6DiE.js.map +0 -1
- package/dist/MTextField-CNH-byir.js.map +0 -1
- package/dist/MTooltip-Dd5g2zhh.js +0 -754
- package/dist/MTooltip-Dd5g2zhh.js.map +0 -1
- package/dist/useLocale-DaVSTdm0.js.map +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type InjectionKey } from 'vue';
|
|
2
|
+
import { type ValidateOn, type ValidationRule } from './validation';
|
|
3
|
+
/** @internal What a field registers with its `MForm` */
|
|
4
|
+
export interface FormField {
|
|
5
|
+
name: () => string | undefined;
|
|
6
|
+
value: () => unknown;
|
|
7
|
+
/** Checks the rules, shows the result, resolves to whether its own rules pass */
|
|
8
|
+
validate: () => Promise<boolean>;
|
|
9
|
+
resetValidation: () => void;
|
|
10
|
+
reset: () => Promise<void>;
|
|
11
|
+
focus: () => void;
|
|
12
|
+
el: () => Element | null | undefined;
|
|
13
|
+
/** The message on display, if any */
|
|
14
|
+
error: () => string | null;
|
|
15
|
+
/** Whether its rules pass right now (checked silently, whether or not it's shown yet) */
|
|
16
|
+
valid: () => boolean;
|
|
17
|
+
pending: () => boolean;
|
|
18
|
+
}
|
|
19
|
+
/** @internal Provided by `MForm` */
|
|
20
|
+
export interface FormContext {
|
|
21
|
+
register: (field: FormField) => () => void;
|
|
22
|
+
/** Every named field's value, by name */
|
|
23
|
+
values: () => Record<string, unknown>;
|
|
24
|
+
/** An error given from outside (`MForm`'s `errors` prop) */
|
|
25
|
+
externalError: (name: string) => string | null;
|
|
26
|
+
hasSchema: () => boolean;
|
|
27
|
+
/** The form schema's first issue for this field */
|
|
28
|
+
schemaError: (name: string) => Promise<string | null>;
|
|
29
|
+
validateOn: () => ValidateOn | undefined;
|
|
30
|
+
/** Default debounce (ms) for re-checks while the value changes */
|
|
31
|
+
validateDebounce: () => number | undefined;
|
|
32
|
+
/** The `errors` object itself: a new one (a new server response) shows its errors again */
|
|
33
|
+
externalErrorsKey: () => unknown;
|
|
34
|
+
/** Keep an outside error after its field changes, instead of hiding it */
|
|
35
|
+
keepErrors: () => boolean;
|
|
36
|
+
disabled: () => boolean;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
export declare const FORM_KEY: InjectionKey<FormContext>;
|
|
40
|
+
/**
|
|
41
|
+
* @internal "Blur" for a field made of several focusable parts (stepper buttons, chips, a popup panel): calls
|
|
42
|
+
* `onLeave` once focus has left `root` for good, not while it moves between its parts or while `open` (its
|
|
43
|
+
* teleported panel, which sits outside `root` in the DOM) is showing. Closing the panel with focus outside
|
|
44
|
+
* counts as leaving. Bind the returned handler to the root's `@focusout`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useFocusLeave(root: () => Element | null | undefined, onLeave: () => void, open?: () => boolean): () => void;
|
|
47
|
+
export interface FieldValidationOptions {
|
|
48
|
+
value: () => unknown;
|
|
49
|
+
rules: () => ValidationRule | ValidationRule[] | undefined;
|
|
50
|
+
required: () => boolean | undefined;
|
|
51
|
+
error: () => boolean | string | undefined;
|
|
52
|
+
errorLabel: () => string | undefined;
|
|
53
|
+
name: () => string | undefined;
|
|
54
|
+
validateOn: () => ValidateOn | undefined;
|
|
55
|
+
/** Wait this long (ms) after the value stops changing before re-checking (async rules: one request, not one per key) */
|
|
56
|
+
validateDebounce?: () => number | undefined;
|
|
57
|
+
disabled: () => boolean | undefined;
|
|
58
|
+
focus: () => void;
|
|
59
|
+
el: () => Element | null | undefined;
|
|
60
|
+
/** Writes a value back through v-model (used by `MForm`'s `reset()`) */
|
|
61
|
+
setValue?: (value: unknown) => void;
|
|
62
|
+
/** What "not filled in" means for `required`, when `isEmpty` isn't it (a date range needs both ends) */
|
|
63
|
+
isEmpty?: (value: unknown) => boolean;
|
|
64
|
+
/** Called when the field is validated on demand (`validate()`, an `MForm` submit), to reveal sub-parts' own errors */
|
|
65
|
+
onValidate?: () => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @internal The validation every form field shares: its own `rules` (plus `required` inside an `MForm` or
|
|
69
|
+
* next to other rules), errors from outside (the `error` prop, `MForm`'s `errors`, its `schema`), when to show
|
|
70
|
+
* them (`validateOn`), and registration with the surrounding `MForm`.
|
|
71
|
+
*
|
|
72
|
+
* Priority of what's shown: a string `error` → `error: true` with `errorLabel` → `MForm`'s `errors[name]`
|
|
73
|
+
* → the field's own rules.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useFieldValidation(opts: FieldValidationOptions): {
|
|
76
|
+
/** Error state (red border/label) */
|
|
77
|
+
hasError: import("vue").ComputedRef<boolean>;
|
|
78
|
+
/** Message under the field, or null */
|
|
79
|
+
message: import("vue").ComputedRef<string | null>;
|
|
80
|
+
/** id for the message element, to point `aria-describedby` at */
|
|
81
|
+
messageId: string;
|
|
82
|
+
/** Whether async rules are still running */
|
|
83
|
+
pending: import("vue").Ref<boolean, boolean>;
|
|
84
|
+
/** The field's own disabled state merged with its `MForm`'s */
|
|
85
|
+
disabled: import("vue").ComputedRef<boolean>;
|
|
86
|
+
/** Call from the field's blur */
|
|
87
|
+
onBlur: () => void;
|
|
88
|
+
validate: () => Promise<boolean>;
|
|
89
|
+
resetValidation: () => void;
|
|
90
|
+
reset: () => Promise<void>;
|
|
91
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LngLat } from './_mapGeometry';
|
|
2
|
+
/** A route between waypoints, as a routing service returns it. */
|
|
3
|
+
export interface MapRouteResult {
|
|
4
|
+
/** The road to follow, `[lng, lat][]`: the streets' real shape (curves, roundabouts), one-way streets respected */
|
|
5
|
+
path: LngLat[];
|
|
6
|
+
/** Length in meters */
|
|
7
|
+
distance: number;
|
|
8
|
+
/** Expected travel time in seconds */
|
|
9
|
+
duration: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where `MMapRoute` gets its road from when you give it `stops` but no `path`: any function from waypoints to a route.
|
|
13
|
+
* `osrmRouteProvider()` ships; GraphHopper, Valhalla, OpenRouteService, Mapbox Directions or your own backend fit
|
|
14
|
+
* the same shape. Gets an `AbortSignal`: a newer request cancels the older one.
|
|
15
|
+
*/
|
|
16
|
+
export type MapRouteProvider = (waypoints: LngLat[], options: {
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}) => Promise<MapRouteResult>;
|
|
19
|
+
export interface OsrmRouteOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The OSRM server. Defaults to the project's public demo server, which is meant for light use only (see its usage
|
|
22
|
+
* policy): run your own (`osrm-backend` in Docker) or use a hosted one in production
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
/** The routing profile in the URL: `driving` (the demo server has only this one), `cycling`, `walking`, or your server's own */
|
|
26
|
+
profile?: string;
|
|
27
|
+
/** More query parameters for OSRM (`exclude=toll`, `alternatives`…) */
|
|
28
|
+
params?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Routes through an OSRM server (Open Source Routing Machine, on OpenStreetMap data): the path follows the streets
|
|
32
|
+
* as they are, and the car profile respects one-way streets and turn restrictions. Available from the `/map` entry
|
|
33
|
+
* point.
|
|
34
|
+
*/
|
|
35
|
+
export declare function osrmRouteProvider(options?: OsrmRouteOptions): MapRouteProvider;
|
|
@@ -221,6 +221,17 @@ export interface M3Locale {
|
|
|
221
221
|
mapPressEnterToSearch: string;
|
|
222
222
|
mapSearching: string;
|
|
223
223
|
mapNoPlaces: string;
|
|
224
|
+
/** MMapRoute: a stop's name when it has no label (followed by its number) */
|
|
225
|
+
mapRouteStop: string;
|
|
226
|
+
/** MMapRoute: the vehicle marker's accessible name */
|
|
227
|
+
mapRouteVehicle: string;
|
|
228
|
+
trackingArrives: string;
|
|
229
|
+
trackingArrivingNow: string;
|
|
230
|
+
trackingDelivered: string;
|
|
231
|
+
trackingDelayed: string;
|
|
232
|
+
trackingCanceled: string;
|
|
233
|
+
trackingShowDetails: string;
|
|
234
|
+
trackingHideDetails: string;
|
|
224
235
|
filterMatchAll: string;
|
|
225
236
|
filterMatchAny: string;
|
|
226
237
|
filterAddCondition: string;
|
|
@@ -548,6 +559,18 @@ export interface M3Locale {
|
|
|
548
559
|
cardInvalidNumber: string;
|
|
549
560
|
cardInvalidExpiry: string;
|
|
550
561
|
cardInvalidCvc: string;
|
|
562
|
+
validationRequired: string;
|
|
563
|
+
validationInvalid: string;
|
|
564
|
+
validationEmail: string;
|
|
565
|
+
validationUrl: string;
|
|
566
|
+
validationMinLength: string;
|
|
567
|
+
validationMaxLength: string;
|
|
568
|
+
validationMinItems: string;
|
|
569
|
+
validationMaxItems: string;
|
|
570
|
+
validationMin: string;
|
|
571
|
+
validationMax: string;
|
|
572
|
+
validationPattern: string;
|
|
573
|
+
validationSameAs: string;
|
|
551
574
|
keypadDelete: string;
|
|
552
575
|
keypadClear: string;
|
|
553
576
|
keypadChange: string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { M3Locale } from './useLocale';
|
|
2
|
+
/**
|
|
3
|
+
* The Standard Schema interface (https://standardschema.dev), implemented by zod (3.24+), valibot (1.0+),
|
|
4
|
+
* arktype, yup (1.7+) and others. A copy of the spec's types, so the lib doesn't depend on any of them:
|
|
5
|
+
* pass a schema straight to a field's `rules` or to `MForm`'s `schema`.
|
|
6
|
+
*/
|
|
7
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
8
|
+
readonly '~standard': {
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly vendor: string;
|
|
11
|
+
readonly validate: (value: unknown) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
|
|
12
|
+
readonly types?: {
|
|
13
|
+
readonly input: Input;
|
|
14
|
+
readonly output: Output;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface StandardSchemaIssue {
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly path?: ReadonlyArray<PropertyKey | {
|
|
21
|
+
readonly key: PropertyKey;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export type StandardSchemaResult<Output> = {
|
|
25
|
+
readonly value: Output;
|
|
26
|
+
readonly issues?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
readonly issues: ReadonlyArray<StandardSchemaIssue>;
|
|
29
|
+
};
|
|
30
|
+
/** What a rule receives besides the value */
|
|
31
|
+
export interface ValidationContext {
|
|
32
|
+
/** The active locale, for messages */
|
|
33
|
+
locale: M3Locale;
|
|
34
|
+
/** The values of every named field of the surrounding `MForm` (empty outside one) */
|
|
35
|
+
values: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `true`, `undefined` or `null` = valid; a string = invalid with that message; `false` = invalid with the
|
|
39
|
+
* locale's generic `validationInvalid` message
|
|
40
|
+
*/
|
|
41
|
+
export type ValidationResult = boolean | string | null | undefined;
|
|
42
|
+
/** A function `(value, ctx) => true | 'message'` (may be async), or a Standard Schema (zod, valibot…) */
|
|
43
|
+
export type ValidationRule<T = any> = ((value: T, ctx: ValidationContext) => ValidationResult | Promise<ValidationResult>) | StandardSchemaV1;
|
|
44
|
+
/** When a field checks its rules and shows the result */
|
|
45
|
+
export type ValidateOn = 'blur' | 'input' | 'submit';
|
|
46
|
+
export declare function isStandardSchema(rule: unknown): rule is StandardSchemaV1;
|
|
47
|
+
/** The key of a Standard Schema issue path segment */
|
|
48
|
+
export declare function issueKey(segment: PropertyKey | {
|
|
49
|
+
readonly key: PropertyKey;
|
|
50
|
+
}): PropertyKey;
|
|
51
|
+
/** Runs one rule: the error message, or null when it passes */
|
|
52
|
+
export declare function runRule(rule: ValidationRule, value: unknown, ctx: ValidationContext): Promise<string | null>;
|
|
53
|
+
/** Runs rules in order and stops at the first that fails */
|
|
54
|
+
export declare function runRules(rules: ValidationRule[], value: unknown, ctx: ValidationContext): Promise<string | null>;
|
|
55
|
+
/** Whether a value counts as "not filled in": null/undefined, blank string, empty array, `false` (an unticked checkbox) */
|
|
56
|
+
export declare function isEmpty(value: unknown): boolean;
|
|
57
|
+
/** Marks the rules `required()` makes, so a field's `required` prop doesn't add a second one in front */
|
|
58
|
+
export declare const REQUIRED_RULE: unique symbol;
|
|
59
|
+
/**
|
|
60
|
+
* The value must be filled in (see `isEmpty`; a field may define its own "empty", e.g. a date range needs both
|
|
61
|
+
* ends). Given in `rules`, it replaces the check the field's `required` prop adds, so its message is the one shown
|
|
62
|
+
*/
|
|
63
|
+
export declare function required(message?: string): ValidationRule;
|
|
64
|
+
/** An email address (the browser's own rule, plus a dot in the domain) */
|
|
65
|
+
export declare function email(message?: string): ValidationRule;
|
|
66
|
+
/** An absolute http(s) URL */
|
|
67
|
+
export declare function url(message?: string): ValidationRule;
|
|
68
|
+
/** At least `min` characters (strings) or items (arrays) */
|
|
69
|
+
export declare function minLength(min: number, message?: string): ValidationRule;
|
|
70
|
+
/** At most `max` characters (strings) or items (arrays) */
|
|
71
|
+
export declare function maxLength(max: number, message?: string): ValidationRule;
|
|
72
|
+
/** A number (or numeric string) of at least `min` */
|
|
73
|
+
export declare function min(min: number, message?: string): ValidationRule;
|
|
74
|
+
/** A number (or numeric string) of at most `max` */
|
|
75
|
+
export declare function max(max: number, message?: string): ValidationRule;
|
|
76
|
+
/** Matches a regular expression */
|
|
77
|
+
export declare function pattern(re: RegExp, message?: string): ValidationRule;
|
|
78
|
+
/**
|
|
79
|
+
* Equals another value: the name of a field in the same `MForm` (e.g. 'password' for a confirmation field),
|
|
80
|
+
* or a getter
|
|
81
|
+
*/
|
|
82
|
+
export declare function sameAs(other: string | (() => unknown), message?: string): ValidationRule;
|
package/dist/draw.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { i as e } from "./useLocale-
|
|
1
|
+
import { i as e } from "./useLocale-Dh1xZZ8i.js";
|
|
2
2
|
import { t } from "./MIconButton-BBggVwBV.js";
|
|
3
3
|
import { n, t as r } from "./MMenuItem-BuxYoASE.js";
|
|
4
|
-
import {
|
|
4
|
+
import { t as i } from "./MTooltip-CK39Zon4.js";
|
|
5
|
+
import { t as a } from "./MColorPickerModal-BKM1CHxr.js";
|
|
5
6
|
import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, inject as h, mergeModels as g, mergeProps as _, nextTick as v, normalizeClass as y, normalizeStyle as b, onBeforeUnmount as x, onMounted as S, openBlock as C, provide as ee, ref as w, renderList as T, renderSlot as E, shallowRef as D, toDisplayString as te, unref as O, useId as ne, useModel as k, vModelText as re, watch as ie, withCtx as A, withDirectives as j, withKeys as ae, withModifiers as M } from "vue";
|
|
6
7
|
// src/composables/drawGeometry.ts
|
|
7
8
|
var N = 0, oe = () => `d${Date.now().toString(36)}${(N++).toString(36)}`, se = {
|
|
@@ -1365,7 +1366,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1365
1366
|
"aria-label": O(x).drawTools
|
|
1366
1367
|
}, [
|
|
1367
1368
|
E(e.$slots, "default"),
|
|
1368
|
-
(C(!0), u(o, null, T(D.value, (e,
|
|
1369
|
+
(C(!0), u(o, null, T(D.value, (e, a) => (C(), u(o, { key: a }, [e.length === 1 ? (C(), c(i, {
|
|
1369
1370
|
key: 0,
|
|
1370
1371
|
text: j(e[0]),
|
|
1371
1372
|
placement: "top"
|
|
@@ -1384,16 +1385,16 @@ var De = ["aria-label"], Oe = [
|
|
|
1384
1385
|
"onClick"
|
|
1385
1386
|
])]),
|
|
1386
1387
|
_: 2
|
|
1387
|
-
}, 1032, ["text"])) : (C(), u("div", st, [p(
|
|
1388
|
-
text: j(k(e,
|
|
1388
|
+
}, 1032, ["text"])) : (C(), u("div", st, [p(i, {
|
|
1389
|
+
text: j(k(e, a)),
|
|
1389
1390
|
placement: "top"
|
|
1390
1391
|
}, {
|
|
1391
1392
|
default: A(() => [p(t, {
|
|
1392
|
-
icon: S[k(e,
|
|
1393
|
-
label: j(k(e,
|
|
1393
|
+
icon: S[k(e, a)].icon,
|
|
1394
|
+
label: j(k(e, a)),
|
|
1394
1395
|
variant: e.includes(O(v).tool.value) ? "filled" : "standard",
|
|
1395
1396
|
"aria-pressed": e.includes(O(v).tool.value),
|
|
1396
|
-
onClick: (t) => O(v).tool.value = k(e,
|
|
1397
|
+
onClick: (t) => O(v).tool.value = k(e, a)
|
|
1397
1398
|
}, null, 8, [
|
|
1398
1399
|
"icon",
|
|
1399
1400
|
"label",
|
|
@@ -1426,7 +1427,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1426
1427
|
]))), 128))]),
|
|
1427
1428
|
_: 2
|
|
1428
1429
|
}, 1024)]))], 64))), 128)),
|
|
1429
|
-
re.value ? (C(), c(
|
|
1430
|
+
re.value ? (C(), c(i, {
|
|
1430
1431
|
key: 0,
|
|
1431
1432
|
text: O(x).drawFill,
|
|
1432
1433
|
placement: "top"
|
|
@@ -1454,7 +1455,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1454
1455
|
"aria-pressed": O(v).color.value.toLowerCase() === e.toLowerCase(),
|
|
1455
1456
|
onClick: (t) => O(v).color.value = e
|
|
1456
1457
|
}, null, 14, B))), 128)),
|
|
1457
|
-
m.customColor ? (C(), c(
|
|
1458
|
+
m.customColor ? (C(), c(i, {
|
|
1458
1459
|
key: 1,
|
|
1459
1460
|
text: O(x).drawCustomColor,
|
|
1460
1461
|
placement: "top"
|
|
@@ -1469,7 +1470,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1469
1470
|
}, [M.value ? l("", !0) : (C(), u("span", V, "add"))], 14, lt)]),
|
|
1470
1471
|
_: 1
|
|
1471
1472
|
}, 8, ["text"])) : l("", !0),
|
|
1472
|
-
m.customColor ? (C(), c(
|
|
1473
|
+
m.customColor ? (C(), c(a, {
|
|
1473
1474
|
key: 2,
|
|
1474
1475
|
modelValue: O(v).color.value,
|
|
1475
1476
|
"onUpdate:modelValue": s[2] ||= (e) => O(v).color.value = e,
|
|
@@ -1493,7 +1494,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1493
1494
|
}, null, 4)], 10, H))), 128)),
|
|
1494
1495
|
m.history ? (C(), u(o, { key: 3 }, [
|
|
1495
1496
|
s[8] ||= d("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
|
|
1496
|
-
p(
|
|
1497
|
+
p(i, {
|
|
1497
1498
|
text: O(x).drawUndo,
|
|
1498
1499
|
placement: "top"
|
|
1499
1500
|
}, {
|
|
@@ -1505,7 +1506,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1505
1506
|
}, null, 8, ["label", "disabled"])]),
|
|
1506
1507
|
_: 1
|
|
1507
1508
|
}, 8, ["text"]),
|
|
1508
|
-
p(
|
|
1509
|
+
p(i, {
|
|
1509
1510
|
text: O(x).drawRedo,
|
|
1510
1511
|
placement: "top"
|
|
1511
1512
|
}, {
|
|
@@ -1518,7 +1519,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1518
1519
|
_: 1
|
|
1519
1520
|
}, 8, ["text"])
|
|
1520
1521
|
], 64)) : l("", !0),
|
|
1521
|
-
O(v).selection.value.length ? (C(), c(
|
|
1522
|
+
O(v).selection.value.length ? (C(), c(i, {
|
|
1522
1523
|
key: 4,
|
|
1523
1524
|
text: O(x).drawDelete,
|
|
1524
1525
|
placement: "top"
|
|
@@ -1547,10 +1548,10 @@ var De = ["aria-label"], Oe = [
|
|
|
1547
1548
|
setup(n) {
|
|
1548
1549
|
let r = h(Te, null);
|
|
1549
1550
|
if (!r) throw Error("MDrawLayers must be inside <MDrawCanvas>");
|
|
1550
|
-
let
|
|
1551
|
+
let a = r, f = e(), m = s(() => a.layers.value.length ? a.layers.value : [{
|
|
1551
1552
|
id: "layer-1",
|
|
1552
1553
|
name: f.drawLayer.replace("{n}", "1")
|
|
1553
|
-
}]), g = s(() => m.value.slice().reverse()), _ = (e) =>
|
|
1554
|
+
}]), g = s(() => m.value.slice().reverse()), _ = (e) => a.setLayers(e), b = (e, t) => _(m.value.map((n) => n.id === e ? {
|
|
1554
1555
|
...n,
|
|
1555
1556
|
...t
|
|
1556
1557
|
} : n));
|
|
@@ -1559,14 +1560,14 @@ var De = ["aria-label"], Oe = [
|
|
|
1559
1560
|
id: oe(),
|
|
1560
1561
|
name: f.drawLayer.replace("{n}", String(m.value.length + 1))
|
|
1561
1562
|
};
|
|
1562
|
-
_([...m.value, e]),
|
|
1563
|
+
_([...m.value, e]), a.layer.value = e.id;
|
|
1563
1564
|
}
|
|
1564
1565
|
function S(e) {
|
|
1565
1566
|
if (m.value.length < 2) return;
|
|
1566
|
-
let t = m.value[0].id, n =
|
|
1567
|
-
n.length && (
|
|
1567
|
+
let t = m.value[0].id, n = a.items.value.filter((n) => (n.layer ?? t) === e).map((e) => e.id);
|
|
1568
|
+
n.length && (a.selection.value = n, a.deleteSelection());
|
|
1568
1569
|
let r = m.value.filter((t) => t.id !== e);
|
|
1569
|
-
_(r),
|
|
1570
|
+
_(r), a.layer.value === e && (a.layer.value = r[r.length - 1].id);
|
|
1570
1571
|
}
|
|
1571
1572
|
function ee(e, t) {
|
|
1572
1573
|
let n = m.value.findIndex((t) => t.id === e), r = n + t;
|
|
@@ -1585,7 +1586,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1585
1586
|
class: "m3-draw-layers flex w-64 flex-col rounded-xl bg-surface-container p-2 text-on-surface shadow-elevation-2",
|
|
1586
1587
|
role: "group",
|
|
1587
1588
|
"aria-label": O(f).drawLayers
|
|
1588
|
-
}, [d("div", dt, [d("span", ft, te(O(f).drawLayers), 1), p(
|
|
1589
|
+
}, [d("div", dt, [d("span", ft, te(O(f).drawLayers), 1), p(i, {
|
|
1589
1590
|
text: O(f).drawAddLayer,
|
|
1590
1591
|
placement: "left"
|
|
1591
1592
|
}, {
|
|
@@ -1598,7 +1599,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1598
1599
|
_: 1
|
|
1599
1600
|
}, 8, ["text"])]), (C(!0), u(o, null, T(g.value, (e) => (C(), u("div", {
|
|
1600
1601
|
key: e.id,
|
|
1601
|
-
class: y(["group flex h-10 items-center gap-1 rounded-full pr-1 pl-3 text-body-medium", O(
|
|
1602
|
+
class: y(["group flex h-10 items-center gap-1 rounded-full pr-1 pl-3 text-body-medium", O(a).layer.value === e.id ? "bg-secondary-container text-on-secondary-container" : "hover:bg-on-surface/8"])
|
|
1602
1603
|
}, [
|
|
1603
1604
|
E.value === e.id ? (C(), u("input", {
|
|
1604
1605
|
key: 0,
|
|
@@ -1614,11 +1615,11 @@ var De = ["aria-label"], Oe = [
|
|
|
1614
1615
|
key: 1,
|
|
1615
1616
|
type: "button",
|
|
1616
1617
|
class: y(["min-w-0 flex-1 truncate text-left outline-none", e.visible === !1 && "opacity-50"]),
|
|
1617
|
-
"aria-pressed": O(
|
|
1618
|
-
onClick: (t) => O(
|
|
1618
|
+
"aria-pressed": O(a).layer.value === e.id,
|
|
1619
|
+
onClick: (t) => O(a).layer.value = e.id,
|
|
1619
1620
|
onDblclick: (t) => ne(e.id)
|
|
1620
1621
|
}, te(e.name), 43, W)),
|
|
1621
|
-
p(
|
|
1622
|
+
p(i, {
|
|
1622
1623
|
text: e.visible === !1 ? O(f).drawShowLayer : O(f).drawHideLayer,
|
|
1623
1624
|
placement: "left"
|
|
1624
1625
|
}, {
|
|
@@ -1634,7 +1635,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1634
1635
|
])]),
|
|
1635
1636
|
_: 2
|
|
1636
1637
|
}, 1032, ["text"]),
|
|
1637
|
-
p(
|
|
1638
|
+
p(i, {
|
|
1638
1639
|
text: e.locked ? O(f).drawUnlockLayer : O(f).drawLockLayer,
|
|
1639
1640
|
placement: "left"
|
|
1640
1641
|
}, {
|