@mapomodule/utils 1.0.0 → 2.0.0-beta.2
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/README.md +33 -0
- package/dist/debounce.js +19 -0
- package/dist/debounce.js.map +1 -0
- package/dist/deepMerge.js +31 -0
- package/dist/deepMerge.js.map +1 -0
- package/dist/formatDate.js +23 -0
- package/dist/formatDate.js.map +1 -0
- package/dist/formatters.js +43 -0
- package/dist/formatters.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonSchema/conditionals.js +326 -0
- package/dist/jsonSchema/conditionals.js.map +1 -0
- package/dist/jsonSchema/index.js +3 -0
- package/dist/jsonSchema/index.js.map +1 -0
- package/dist/jsonSchema/resolve.js +133 -0
- package/dist/jsonSchema/resolve.js.map +1 -0
- package/dist/jsonSchema/types.js +2 -0
- package/dist/jsonSchema/types.js.map +1 -0
- package/dist/menuHelpers.js +56 -0
- package/dist/menuHelpers.js.map +1 -0
- package/dist/nestedValue.js +53 -0
- package/dist/nestedValue.js.map +1 -0
- package/dist/normalizeEndpoint.js +39 -0
- package/dist/normalizeEndpoint.js.map +1 -0
- package/dist/objectDiff.js +58 -0
- package/dist/objectDiff.js.map +1 -0
- package/dist/objectHelpers.js +93 -0
- package/dist/objectHelpers.js.map +1 -0
- package/dist/slotNamespace.js +15 -0
- package/dist/slotNamespace.js.map +1 -0
- package/dist/types/debounce.d.ts +11 -0
- package/dist/types/debounce.d.ts.map +1 -0
- package/dist/types/deepMerge.d.ts +12 -0
- package/dist/types/deepMerge.d.ts.map +1 -0
- package/dist/types/formatDate.d.ts +11 -0
- package/dist/types/formatDate.d.ts.map +1 -0
- package/dist/types/formatters.d.ts +15 -0
- package/dist/types/formatters.d.ts.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/jsonSchema/conditionals.d.ts +40 -0
- package/dist/types/jsonSchema/conditionals.d.ts.map +1 -0
- package/dist/types/jsonSchema/index.d.ts +15 -0
- package/dist/types/jsonSchema/index.d.ts.map +1 -0
- package/dist/types/jsonSchema/resolve.d.ts +41 -0
- package/dist/types/jsonSchema/resolve.d.ts.map +1 -0
- package/dist/types/jsonSchema/types.d.ts +43 -0
- package/dist/types/jsonSchema/types.d.ts.map +1 -0
- package/dist/types/menuHelpers.d.ts +22 -0
- package/dist/types/menuHelpers.d.ts.map +1 -0
- package/dist/types/nestedValue.d.ts +25 -0
- package/dist/types/nestedValue.d.ts.map +1 -0
- package/dist/types/normalizeEndpoint.d.ts +28 -0
- package/dist/types/normalizeEndpoint.d.ts.map +1 -0
- package/dist/types/objectDiff.d.ts +12 -0
- package/dist/types/objectDiff.d.ts.map +1 -0
- package/dist/types/objectHelpers.d.ts +33 -0
- package/dist/types/objectHelpers.d.ts.map +1 -0
- package/dist/types/slotNamespace.d.ts +12 -0
- package/dist/types/slotNamespace.d.ts.map +1 -0
- package/package.json +41 -7
- package/CHANGELOG.md +0 -182
- package/helpers/cssVariables.js +0 -12
- package/helpers/datetime.js +0 -68
- package/helpers/debounce.js +0 -42
- package/helpers/formatters.js +0 -52
- package/helpers/menu.js +0 -15
- package/helpers/objHelpers.js +0 -118
- package/helpers/slots.js +0 -9
- package/index.js +0 -13
- package/loaders/dummy-loader.js +0 -1
- package/plugins/v-draggable-modals.js +0 -39
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema utilities for the Mapo form engine.
|
|
3
|
+
*
|
|
4
|
+
* - {@link JSONSchema} — shared type definition
|
|
5
|
+
* - {@link matchesSchema} — validate a value against a schema node
|
|
6
|
+
* - {@link applyConditionals} — resolve `if/then/else` and dependent keywords
|
|
7
|
+
* - {@link hasConditionals} — check whether a schema has runtime conditionals
|
|
8
|
+
* - {@link resolveSchema} — dereference `$ref`, `anyOf`, `oneOf`
|
|
9
|
+
* - {@link extractDefs} — extract the `$defs` / `definitions` map
|
|
10
|
+
* - {@link getDefaultForSchema} — derive a zero/empty default value from a schema
|
|
11
|
+
*/
|
|
12
|
+
export type { JSONSchema } from "./types.js";
|
|
13
|
+
export { matchesSchema, applyConditionals, hasConditionals, } from "./conditionals.js";
|
|
14
|
+
export { resolveSchema, extractDefs, getDefaultForSchema } from "./resolve.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jsonSchema/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { JSONSchema } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Recursively resolves a JSON Schema by following `$ref`, `anyOf`, and `oneOf` pointers.
|
|
4
|
+
*
|
|
5
|
+
* - `$ref` is dereferenced against the provided `defs` map.
|
|
6
|
+
* - `anyOf` / `oneOf` with a single non-null branch is unwrapped; nullable schemas
|
|
7
|
+
* are marked with `_nullable: true`.
|
|
8
|
+
* - A `oneOf` paired with a `discriminator` is returned as-is (handled by union editors).
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema node to resolve.
|
|
11
|
+
* @param defs - Flat map of reusable definitions (`$defs` / `definitions`).
|
|
12
|
+
* @param seen - WeakSet used to detect circular references across recursive calls.
|
|
13
|
+
* @param depth - Current recursion depth; capped at {@link MAX_RESOLVE_DEPTH}.
|
|
14
|
+
* @returns The fully resolved schema node.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveSchema(schema: JSONSchema, defs: Record<string, JSONSchema>, seen?: WeakSet<JSONSchema>, depth?: number): JSONSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts the reusable definitions map from a root JSON Schema.
|
|
19
|
+
* Supports both the modern `$defs` keyword and the legacy `definitions` keyword.
|
|
20
|
+
*
|
|
21
|
+
* @param schema - The root schema object.
|
|
22
|
+
* @returns A flat record of named sub-schemas.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractDefs(schema: JSONSchema): Record<string, JSONSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Derives a sensible empty/zero default value for a given JSON Schema node.
|
|
27
|
+
*
|
|
28
|
+
* If the schema declares an explicit `default`, that value is deep-cloned and returned.
|
|
29
|
+
* Otherwise, a type-appropriate zero value is produced:
|
|
30
|
+
* - `object` → object with per-property defaults
|
|
31
|
+
* - `array` → `[]`
|
|
32
|
+
* - `string` → `""`
|
|
33
|
+
* - `integer` / `number` → `0`
|
|
34
|
+
* - `boolean` → `false`
|
|
35
|
+
* - `relation` → `null` (or `[]` when `multiple: true`)
|
|
36
|
+
*
|
|
37
|
+
* @param schema - The resolved schema node.
|
|
38
|
+
* @returns The default value inferred from the schema type.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDefaultForSchema(schema: JSONSchema): unknown;
|
|
41
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/jsonSchema/resolve.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,IAAI,GAAE,OAAO,CAAC,UAAU,CAAiB,EACzC,KAAK,SAAI,GACR,UAAU,CA2DZ;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAE1E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAoB/D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subset of the JSON Schema specification used throughout the Mapo form engine.
|
|
3
|
+
* Covers validation keywords, combination keywords, and custom extensions.
|
|
4
|
+
*
|
|
5
|
+
* This is the single source of truth for the schema shape — `conditionals.ts`,
|
|
6
|
+
* `resolve.ts`, and the public barrel all import `JSONSchema` from here.
|
|
7
|
+
*/
|
|
8
|
+
export interface JSONSchema {
|
|
9
|
+
type?: string | string[];
|
|
10
|
+
properties?: Record<string, JSONSchema>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
items?: JSONSchema;
|
|
13
|
+
const?: unknown;
|
|
14
|
+
enum?: unknown[];
|
|
15
|
+
not?: JSONSchema;
|
|
16
|
+
allOf?: JSONSchema[];
|
|
17
|
+
anyOf?: JSONSchema[];
|
|
18
|
+
oneOf?: JSONSchema[];
|
|
19
|
+
if?: JSONSchema;
|
|
20
|
+
then?: JSONSchema;
|
|
21
|
+
else?: JSONSchema;
|
|
22
|
+
dependentSchemas?: Record<string, JSONSchema>;
|
|
23
|
+
dependentRequired?: Record<string, string[]>;
|
|
24
|
+
minimum?: number;
|
|
25
|
+
maximum?: number;
|
|
26
|
+
exclusiveMinimum?: number;
|
|
27
|
+
exclusiveMaximum?: number;
|
|
28
|
+
multipleOf?: number;
|
|
29
|
+
minLength?: number;
|
|
30
|
+
maxLength?: number;
|
|
31
|
+
pattern?: string;
|
|
32
|
+
$ref?: string;
|
|
33
|
+
$defs?: Record<string, JSONSchema>;
|
|
34
|
+
definitions?: Record<string, JSONSchema>;
|
|
35
|
+
discriminator?: {
|
|
36
|
+
propertyName: string;
|
|
37
|
+
};
|
|
38
|
+
title?: string;
|
|
39
|
+
default?: unknown;
|
|
40
|
+
_nullable?: boolean;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/jsonSchema/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACzC,aAAa,CAAC,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RouteRecordNormalized, RouteMeta } from "vue-router";
|
|
2
|
+
export interface MenuNode {
|
|
3
|
+
link: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
children: MenuNode[];
|
|
7
|
+
meta: RouteMeta;
|
|
8
|
+
sidebarFooter: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Return the maximum nesting depth of a MenuNode tree (root = depth 1). */
|
|
11
|
+
export declare function calcMaxMenuNestDepth(nodes: MenuNode[], depth?: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Builds a hierarchical menu tree from flat route records.
|
|
14
|
+
*
|
|
15
|
+
* Routes are included only when they define a `meta.label` and are not marked
|
|
16
|
+
* as hidden. Parent-child relationships are resolved through `meta.parent`.
|
|
17
|
+
*
|
|
18
|
+
* @param routes Flat list of normalized router records.
|
|
19
|
+
* @returns Root menu nodes with nested children.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildRouteTree(routes: RouteRecordNormalized[]): MenuNode[];
|
|
22
|
+
//# sourceMappingURL=menuHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuHelpers.d.ts","sourceRoot":"","sources":["../../src/menuHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,SAAI,GAAG,MAAM,CAUzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,QAAQ,EAAE,CAgC1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a value from an object using a dot-notation path.
|
|
3
|
+
*
|
|
4
|
+
* @param obj Source object to traverse.
|
|
5
|
+
* @param path Dot-notation path (for example, `"user.profile.name"`).
|
|
6
|
+
* @returns The nested value, or `undefined` when the path cannot be fully resolved.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getNestedValue(obj: unknown, path: string): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* In-place version for Vue reactive proxies. Mutates obj directly so Vue's
|
|
11
|
+
* reactivity system tracks the change. Creates missing intermediate objects.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setNestedValueMutating(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a new object with `value` assigned at the given dot-notation path.
|
|
16
|
+
*
|
|
17
|
+
* Existing nested objects along the path are shallow-cloned to preserve immutability.
|
|
18
|
+
*
|
|
19
|
+
* @param obj Source object.
|
|
20
|
+
* @param path Dot-notation path where the value should be set.
|
|
21
|
+
* @param value Value to assign at the target path.
|
|
22
|
+
* @returns A new object with the updated nested value.
|
|
23
|
+
*/
|
|
24
|
+
export declare function setNestedValue<T extends Record<string, unknown>>(obj: T, path: string, value: unknown): T;
|
|
25
|
+
//# sourceMappingURL=nestedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestedValue.d.ts","sourceRoot":"","sources":["../../src/nestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,CAAC,CAWH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures an API endpoint path has exactly one leading and one trailing slash.
|
|
3
|
+
* Query strings are preserved unchanged — the slash is inserted before the `?`.
|
|
4
|
+
* Used by `useCrud` to normalize user-provided endpoint paths before making requests.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* normalizeEndpoint('api/articles') // '/api/articles/'
|
|
8
|
+
* normalizeEndpoint('/api/articles') // '/api/articles/'
|
|
9
|
+
* normalizeEndpoint('/api/articles/') // '/api/articles/'
|
|
10
|
+
* normalizeEndpoint('/api/articles/?q=1') // '/api/articles/?q=1'
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeEndpoint(endpoint: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Splits an endpoint string into its clean path and parsed query params.
|
|
15
|
+
* Useful when an endpoint carries baked-in params (e.g. `?fields=id,title`) that
|
|
16
|
+
* must be merged into request params while CRUD mutations target the bare path.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* splitEndpointParams('/api/articles/?fields=id,title')
|
|
20
|
+
* { path: '/api/articles/', params: { fields: 'id,title' } }
|
|
21
|
+
* splitEndpointParams('/api/articles/')
|
|
22
|
+
* { path: '/api/articles/', params: {} }
|
|
23
|
+
*/
|
|
24
|
+
export declare function splitEndpointParams(endpoint: string): {
|
|
25
|
+
path: string;
|
|
26
|
+
params: Record<string, string>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=normalizeEndpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeEndpoint.d.ts","sourceRoot":"","sources":["../../src/normalizeEndpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAOA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes a deep diff between two objects and returns only changed fields.
|
|
3
|
+
*
|
|
4
|
+
* Nested objects are diffed recursively. Arrays are compared deeply and, when changed,
|
|
5
|
+
* are returned as the full current array value.
|
|
6
|
+
*
|
|
7
|
+
* @param base Base object used as the comparison reference.
|
|
8
|
+
* @param current Current object to compare against `base`.
|
|
9
|
+
* @returns A partial object containing only keys whose values differ from `base`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function objectDiff<T extends object>(base: T, current: T): Partial<T>;
|
|
12
|
+
//# sourceMappingURL=objectDiff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectDiff.d.ts","sourceRoot":"","sources":["../../src/objectDiff.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA2B5E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-clones a value and returns a detached copy.
|
|
3
|
+
*
|
|
4
|
+
* The function first unwraps Vue reactive proxies (when present), then:
|
|
5
|
+
* - uses `structuredClone` when available
|
|
6
|
+
* - falls back to recursive cloning for plain objects/arrays
|
|
7
|
+
*
|
|
8
|
+
* The recursive fallback does not support circular references.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deepClone<T>(value: T): T;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard that returns true when `value` is a browser `File`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isFile(value: unknown): value is File;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard that returns true when `value` is a browser `Blob`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isBlob(value: unknown): value is Blob;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard that returns true when `value` is either a `File` or a `Blob`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isFileOrBlob(value: unknown): value is File | Blob;
|
|
23
|
+
/**
|
|
24
|
+
* Return all dot-notation paths in `obj` where the predicate is truthy.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findPropPaths(obj: unknown, predicate: (val: unknown) => boolean, _prefix?: string): string[];
|
|
27
|
+
/** Return all paths in `obj` that hold a File or Blob. */
|
|
28
|
+
export declare function filesInObject(obj: unknown): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Return a shallow copy of `obj` containing only the listed top-level keys.
|
|
31
|
+
*/
|
|
32
|
+
export declare function filterObj<T extends Record<string, unknown>>(obj: T, keys: (keyof T)[]): Partial<T>;
|
|
33
|
+
//# sourceMappingURL=objectHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectHelpers.d.ts","sourceRoot":"","sources":["../../src/objectHelpers.ts"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAkBxC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,CAEjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,EACpC,OAAO,SAAK,GACX,MAAM,EAAE,CAaV;AAED,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAEpD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAChB,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Slots } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a namespaced view of slots, including only those that start with the given prefix.
|
|
4
|
+
*
|
|
5
|
+
* Filtered slot names are normalized by removing the prefix from the slot key.
|
|
6
|
+
*
|
|
7
|
+
* @param slots Source Vue slots object.
|
|
8
|
+
* @param prefix Prefix used to select which slots to include.
|
|
9
|
+
* @returns A new `Slots` object containing only prefixed slots, renamed without the prefix.
|
|
10
|
+
*/
|
|
11
|
+
export declare function slotNamespace(slots: Slots, prefix: string): Slots;
|
|
12
|
+
//# sourceMappingURL=slotNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotNamespace.d.ts","sourceRoot":"","sources":["../../src/slotNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAEjC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAMjE"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
|
+
"description": "Mapo typed utilities",
|
|
5
|
+
"type": "module",
|
|
4
6
|
"license": "MIT",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"repository":
|
|
8
|
-
|
|
7
|
+
"author": "Lotrek Agency (https://lotrek.it)",
|
|
8
|
+
"homepage": "https://lotrekagency.github.io/mapo-new/",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/lotrekagency/mapo-new.git",
|
|
12
|
+
"directory": "packages/@mapomodule/utils"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/lotrekagency/mapo-new/issues"
|
|
16
|
+
},
|
|
9
17
|
"publishConfig": {
|
|
10
|
-
"access": "public"
|
|
18
|
+
"access": "public",
|
|
19
|
+
"tag": "next"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./jsonSchema": {
|
|
27
|
+
"types": "./dist/types/jsonSchema/index.d.ts",
|
|
28
|
+
"import": "./dist/jsonSchema/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint src",
|
|
41
|
+
"test": "vitest run"
|
|
11
42
|
},
|
|
12
|
-
"
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"vue": "^3.5.32",
|
|
45
|
+
"vue-router": "^5.0.4"
|
|
46
|
+
}
|
|
13
47
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [1.0.0](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.60...v1.0.0) (2026-07-02)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @mapomodule/utils
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [1.0.0-alpha.49](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.48...v1.0.0-alpha.49) (2023-07-27)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Features
|
|
18
|
-
|
|
19
|
-
* added max-depth prop to menu manager to give the possibility of set a limit in depth for nesting ([e4ab7a1](https://github.com/lotrekagency/mapo/commit/e4ab7a137cbb392e709e8865404105d7707a7634))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# [1.0.0-alpha.45](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.44...v1.0.0-alpha.45) (2023-06-10)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Bug Fixes
|
|
29
|
-
|
|
30
|
-
* fix setPointed ([f43685d](https://github.com/lotrekagency/mapo/commit/f43685dce23fb9383d7b0501767b1c40ff442686))
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# [1.0.0-alpha.44](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.43...v1.0.0-alpha.44) (2023-06-10)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Bug Fixes
|
|
40
|
-
|
|
41
|
-
* added better reactivity to setPointed function ([78a4a88](https://github.com/lotrekagency/mapo/commit/78a4a88fbc98e5ce0d2662c074541eb4f8fd3ea1))
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Performance Improvements
|
|
45
|
-
|
|
46
|
-
* EXPERIMENTAL: use Vue.set in setpointed and directly manipulate js object in FormField ([1c384e9](https://github.com/lotrekagency/mapo/commit/1c384e9d7c922b0e876512de874a3f9832ac30f1))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
# [1.0.0-alpha.43](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.42...v1.0.0-alpha.43) (2023-02-02)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Bug Fixes
|
|
56
|
-
|
|
57
|
-
* put version on @mapomodule/utils ([9182283](https://github.com/lotrekagency/mapo/commit/9182283aeef7075a664ce12a45c94b934d5c491a))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# [1.0.0-alpha.40](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.39...v1.0.0-alpha.40) (2022-12-20)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### Bug Fixes
|
|
67
|
-
|
|
68
|
-
* rewritten and more precise diffObjs function ([3e79775](https://github.com/lotrekagency/mapo/commit/3e797756d0dc48142febcdb806390552ea522b30))
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Features
|
|
72
|
-
|
|
73
|
-
* style scrollbars ([48e4c7b](https://github.com/lotrekagency/mapo/commit/48e4c7b047a1062464d823ddeebdc60b96ea11a8))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
# [1.0.0-alpha.34](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2022-11-11)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
### Bug Fixes
|
|
83
|
-
|
|
84
|
-
* fix draggable dialogues ([aeaa009](https://github.com/lotrekagency/mapo/commit/aeaa009cb30e4d13df1288d3996742d529713ffc))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# [1.0.0-alpha.30](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2022-09-13)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### Bug Fixes
|
|
94
|
-
|
|
95
|
-
* **auth:** removed js set cookie helpers since mapo login is http-only cookie based now ([6328c13](https://github.com/lotrekagency/mapo/commit/6328c13bec39d8e312f9dd4c33c53182fd64e6ed))
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
### Features
|
|
99
|
-
|
|
100
|
-
* added memoized debounce ([3c9a025](https://github.com/lotrekagency/mapo/commit/3c9a02509ffd8277d362c30eb2cfafabdde995b7))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# [1.0.0-alpha.23](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2022-05-04)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### Bug Fixes
|
|
110
|
-
|
|
111
|
-
* **utils:** better File recognition for deepClone util ([72a1002](https://github.com/lotrekagency/mapo/commit/72a1002144ff0be1c016a39f46f8ea712a950825))
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
# [1.0.0-alpha.22](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-05-01)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
### Features
|
|
121
|
-
|
|
122
|
-
* big code refactor and improovements to fields management ([a818d8b](https://github.com/lotrekagency/mapo/commit/a818d8b891dbb4892f50267d6355c41297e2c6c6))
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
# [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Features
|
|
132
|
-
|
|
133
|
-
* enhance findPropPaths to deal also with arrays indexes ([158a9aa](https://github.com/lotrekagency/mapo/commit/158a9aa9329defbecbb39e1f19df2855dd3ece01))
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
# [1.0.0-alpha.13](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-01)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
### Features
|
|
143
|
-
|
|
144
|
-
* make all modals draggable 🛸 ([57da10d](https://github.com/lotrekagency/mapo/commit/57da10d17aa31d58e55fda5385d45d43beed8c4f))
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
# [1.0.0-alpha.10](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2022-02-11)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### Bug Fixes
|
|
154
|
-
|
|
155
|
-
* fix objectHelper getPointed returning a keyerror when some point in path are missing ([6f1c2aa](https://github.com/lotrekagency/mapo/commit/6f1c2aa72176c9965e499135042de0646d9a04f8))
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### Features
|
|
159
|
-
|
|
160
|
-
* **core:** Completely rewritten multipart capabilities, now the crud helper autodiscovers whet to use a multipart request. ([0a6546c](https://github.com/lotrekagency/mapo/commit/0a6546c9adeaf1fcf57a88105101e476b8b786dc))
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# [1.0.0-alpha.9](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2022-02-08)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
### Bug Fixes
|
|
170
|
-
|
|
171
|
-
* **core:** fix object setPointed to create missing nesting ([7a26510](https://github.com/lotrekagency/mapo/commit/7a26510d6c1648156bd5a8f18d3851e4fe195d29))
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
# [1.0.0-alpha.8](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-01-23)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
### Features
|
|
181
|
-
|
|
182
|
-
* **quickedit:** merge detail component logics in to quickedit ([691f610](https://github.com/lotrekagency/mapo/commit/691f610b156f58a5d30598d89bf06425d90451d8))
|
package/helpers/cssVariables.js
DELETED
package/helpers/datetime.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const pad = (val, len = 2) => String(val).padStart(len, "0");
|
|
2
|
-
const convertToDate = (date) =>
|
|
3
|
-
typeof date == "string" ? new Date(date) : date;
|
|
4
|
-
|
|
5
|
-
function getUTC(date) {
|
|
6
|
-
return new Date(date.toISOString().slice(0, -1));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function cleanDateStr(dateStr) {
|
|
10
|
-
return dateStr &&
|
|
11
|
-
!dateStr.endsWith("Z") &&
|
|
12
|
-
dateStr.slice(-6).indexOf("+") === -1 &&
|
|
13
|
-
dateStr.slice(-6).indexOf("-") === -1
|
|
14
|
-
? dateStr + "Z"
|
|
15
|
-
: dateStr;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function formatLocalTime(date) {
|
|
19
|
-
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
|
|
20
|
-
date.getSeconds()
|
|
21
|
-
)}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function formatLocalDate(date) {
|
|
25
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
|
|
26
|
-
date.getDate()
|
|
27
|
-
)}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function formatLocalDateTime(date) {
|
|
31
|
-
return `${formatLocalDate(date)}T${formatLocalTime(date)}`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function formatUTCTime(date) {
|
|
35
|
-
return formatLocalTime(getUTC(date));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function formatUTCDate(date) {
|
|
39
|
-
return formatLocalDate(getUTC(date));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const formatOps = Object.fromEntries(
|
|
43
|
-
Object.entries({
|
|
44
|
-
getUTC,
|
|
45
|
-
formatLocalTime,
|
|
46
|
-
formatLocalDate,
|
|
47
|
-
formatLocalDateTime,
|
|
48
|
-
formatUTCTime,
|
|
49
|
-
formatUTCDate
|
|
50
|
-
}).map(([k, func]) => [k, (date) => func(convertToDate(date))])
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
function mergeDate(dateTime, date) {
|
|
54
|
-
let newDateTime = new Date(dateTime);
|
|
55
|
-
date = convertToDate(date);
|
|
56
|
-
newDateTime.setFullYear(date.getFullYear());
|
|
57
|
-
newDateTime.setMonth(date.getMonth());
|
|
58
|
-
newDateTime.setDate(date.getDate());
|
|
59
|
-
return newDateTime;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function mergeTime(dateTime, time) {
|
|
63
|
-
let newDateTime = new Date(dateTime);
|
|
64
|
-
let timeDateTime = new Date(`2000-01-01T${time}`);
|
|
65
|
-
return mergeDate(timeDateTime, newDateTime);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = { ...formatOps, cleanDateStr, mergeDate, mergeTime };
|
package/helpers/debounce.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
function debounce(func, wait, immediate) {
|
|
2
|
-
var timeout;
|
|
3
|
-
return function () {
|
|
4
|
-
var context = this,
|
|
5
|
-
args = arguments;
|
|
6
|
-
var later = function () {
|
|
7
|
-
timeout = null;
|
|
8
|
-
if (!immediate) func.apply(context, args);
|
|
9
|
-
};
|
|
10
|
-
var callNow = immediate && !timeout;
|
|
11
|
-
clearTimeout(timeout);
|
|
12
|
-
timeout = setTimeout(later, wait);
|
|
13
|
-
if (callNow) func.apply(context, args);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function memoizedDebounce(
|
|
18
|
-
func,
|
|
19
|
-
wait,
|
|
20
|
-
immediate,
|
|
21
|
-
argsSerializer = (args) => JSON.stringify(args)
|
|
22
|
-
) {
|
|
23
|
-
var timeout = {};
|
|
24
|
-
return function () {
|
|
25
|
-
var context = this,
|
|
26
|
-
args = arguments,
|
|
27
|
-
serializedArgs = argsSerializer(arguments);
|
|
28
|
-
var later = function () {
|
|
29
|
-
timeout[serializedArgs] = null;
|
|
30
|
-
if (!immediate) func.apply(context, args);
|
|
31
|
-
};
|
|
32
|
-
var callNow = immediate && !timeout[serializedArgs];
|
|
33
|
-
clearTimeout(timeout[serializedArgs]);
|
|
34
|
-
timeout[serializedArgs] = setTimeout(later, wait);
|
|
35
|
-
if (callNow) func.apply(context, args);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
debounce,
|
|
41
|
-
memoizedDebounce,
|
|
42
|
-
};
|