@chelone/vue 0.2.0 → 0.4.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/array/use-array-input.d.ts +4 -3
- package/dist/choices/use-choices.d.ts +19 -12
- package/dist/choices/use-choices.js +8 -11
- package/dist/components/admin/auth/auth-error.vue.d.ts +1 -1
- package/dist/components/admin/buttons/dual-approval-button.vue.d.ts +19 -15
- package/dist/components/admin/buttons/dual-approval-button.vue.js +3 -1
- package/dist/components/admin/buttons/save-button.vue.d.ts +1 -1
- package/dist/components/admin/buttons/sort-button.vue.d.ts +2 -1
- package/dist/components/admin/buttons/status-transition-button.vue.d.ts +19 -14
- package/dist/components/admin/buttons/status-transition-button.vue.js +3 -1
- package/dist/components/admin/buttons/update-button.vue.d.ts +3 -3
- package/dist/components/admin/feedback/linear-progress.vue.d.ts +1 -1
- package/dist/components/admin/fields/api-key-field.vue.d.ts +27 -9
- package/dist/components/admin/fields/api-key-field.vue.js +3 -1
- package/dist/components/admin/fields/array-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/badge-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/boolean-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/chip-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/color-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/cron-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/currency-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/date-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/duration-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/email-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/file-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/file-field.vue.js +3 -3
- package/dist/components/admin/fields/function-field.vue.d.ts +3 -3
- package/dist/components/admin/fields/image-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/image-field.vue.js +3 -3
- package/dist/components/admin/fields/json-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/number-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/phone-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/rating-field.vue.d.ts +22 -7
- package/dist/components/admin/fields/rating-field.vue.js +3 -1
- package/dist/components/admin/fields/record-field.vue.d.ts +3 -3
- package/dist/components/admin/fields/reference-array-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/reference-field.vue.d.ts +2 -1
- package/dist/components/admin/fields/reference-many-count.vue.d.ts +2 -2
- package/dist/components/admin/fields/reference-many-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/reference-one-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/select-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/select-field.vue.js +1 -1
- package/dist/components/admin/fields/subscription-plan-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/text-array-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/text-field.vue.d.ts +2 -8
- package/dist/components/admin/fields/url-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/usage-meter-field.vue.d.ts +22 -7
- package/dist/components/admin/fields/usage-meter-field.vue.js +3 -1
- package/dist/components/admin/fields/webhook-endpoint-field.vue.d.ts +2 -2
- package/dist/components/admin/fields/wrapper-field.vue.d.ts +3 -3
- package/dist/components/admin/fields/wrapper-field.vue.js +6 -0
- package/dist/components/admin/inputs/api-key-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/array-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/autocomplete-array-input.vue.d.ts +14 -6
- package/dist/components/admin/inputs/autocomplete-array-input.vue.js +2 -3
- package/dist/components/admin/inputs/autocomplete-input.vue.d.ts +14 -6
- package/dist/components/admin/inputs/autocomplete-input.vue.js +2 -3
- package/dist/components/admin/inputs/boolean-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/checkbox-group-input.vue.d.ts +1 -1
- package/dist/components/admin/inputs/choice-input-props.d.ts +7 -7
- package/dist/components/admin/inputs/color-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/cron-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/currency-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/date-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/date-time-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/duration-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/file-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/nullable-boolean-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/number-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/password-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/phone-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/radio-button-group-input.vue.d.ts +1 -1
- package/dist/components/admin/inputs/rating-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/reference-array-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/reference-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/resettable-text-input.vue.d.ts +2 -1
- package/dist/components/admin/inputs/search-input.vue.d.ts +3 -3
- package/dist/components/admin/inputs/select-array-input.vue.d.ts +14 -5
- package/dist/components/admin/inputs/select-array-input.vue.js +1 -1
- package/dist/components/admin/inputs/select-input.vue.d.ts +14 -7
- package/dist/components/admin/inputs/select-input.vue.js +1 -1
- package/dist/components/admin/inputs/subscription-plan-picker.vue.d.ts +2 -2
- package/dist/components/admin/inputs/text-array-input.vue.d.ts +2 -2
- package/dist/components/admin/inputs/text-input.vue.d.ts +2 -1
- package/dist/components/admin/inputs/time-input.vue.d.ts +2 -1
- package/dist/components/admin/inputs/use-choice-input.d.ts +13 -19
- package/dist/components/admin/inputs/use-choice-input.js +4 -1
- package/dist/components/admin/inputs/webhook-endpoint-input.vue.d.ts +2 -2
- package/dist/components/admin/list/calendar-list.vue.d.ts +8 -8
- package/dist/components/admin/list/data-table-col.vue.d.ts +2 -2
- package/dist/components/admin/list/data-table-number-col.vue.d.ts +2 -1
- package/dist/components/admin/list/filter-form.vue.js +2 -10
- package/dist/components/admin/list/filter-live-search.vue.d.ts +1 -1
- package/dist/components/admin/list/kanban-board.vue.d.ts +41 -0
- package/dist/components/admin/list/kanban-board.vue.js +275 -0
- package/dist/components/admin/list/kanban-board2.vue.js +4 -0
- package/dist/components/admin/list/list-icons.d.ts +2 -0
- package/dist/components/admin/list/list-icons.js +7 -0
- package/dist/components/admin/list/tree-list.vue.d.ts +7 -6
- package/dist/components/admin/list/tree-list.vue.js +3 -9
- package/dist/components/admin/view/labeled.vue.d.ts +6 -5
- package/dist/components/admin/view/labeled.vue.js +4 -1
- package/dist/components/admin/view/tabbed-show-layout-tab.vue.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/maps/geo-json-field.vue.d.ts +2 -1
- package/dist/components/maps/lat-lng-field.vue.d.ts +3 -3
- package/dist/components/maps/lat-lng-input.vue.d.ts +4 -4
- package/dist/components/maps-draw/shape-input.vue.d.ts +4 -4
- package/dist/components/maps-draw/simplify-input.vue.d.ts +2 -2
- package/dist/components/maps-osm/geocoding-input.vue.d.ts +6 -6
- package/dist/components/maps-osm/map-with-search.vue.d.ts +4 -4
- package/dist/components/maps-osm/osm-feature-operator.vue.d.ts +3 -3
- package/dist/components/maps-osm/reverse-geocode-field.vue.d.ts +3 -3
- package/dist/components/mdx-editor/mdx-field.vue.d.ts +2 -2
- package/dist/components/mdx-editor/mdx-input.vue.d.ts +2 -2
- package/dist/components/monaco/monaco-json-field.vue.d.ts +2 -2
- package/dist/components/monaco/monaco-json-input.vue.d.ts +2 -2
- package/dist/components/ui/alert.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.vue.d.ts +1 -1
- package/dist/components/ui/command/command-dialog.vue.d.ts +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.vue.js +9 -3
- package/dist/components/ui/input.vue.d.ts +2 -2
- package/dist/components/ui/sidebar/sidebar-menu-button.vue.d.ts +1 -1
- package/dist/components/ui/textarea.vue.d.ts +2 -2
- package/dist/controllers/use-controller-for-id.d.ts +6 -2
- package/dist/controllers/use-controller-for-id.js +2 -1
- package/dist/create-resource-components.d.ts +743 -0
- package/dist/create-resource-components.js +171 -0
- package/dist/data/create-chelone-hooks.d.ts +28 -8
- package/dist/data/mutations.d.ts +28 -8
- package/dist/form/use-input.d.ts +9 -6
- package/dist/form/use-input.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +248 -243
- package/dist/label/use-get-record-representation.d.ts +2 -1
- package/dist/label/use-get-record-representation.js +1 -13
- package/dist/record/use-field-value.d.ts +22 -11
- package/dist/record/use-field-value.js +3 -20
- package/package.json +4 -4
- package/dist/components/admin/fields/get-path.d.ts +0 -7
- package/dist/components/admin/fields/get-path.js +0 -14
|
@@ -5,28 +5,39 @@
|
|
|
5
5
|
* clean-room, zero-lodash). Returns a `ComputedRef` so a field re-renders when
|
|
6
6
|
* the ambient record resolves (React re-renders instead; Vue tracks the ref).
|
|
7
7
|
*
|
|
8
|
-
* Path semantics match `lodash/get`: dot members
|
|
9
|
-
* indices (`tags[1].label`),
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* Path semantics match `lodash/get` through core's `getAtPath`: dot members
|
|
9
|
+
* (`author.name`), bracket indices (`tags[1].label`), numeric-dot indices
|
|
10
|
+
* (`tags.0.label`) and a literal `"a.b"` key all resolve; `defaultValue`
|
|
11
|
+
* replaces ONLY a resolved `undefined`, never a present `null` / `0` / `false`
|
|
12
|
+
* / `""`. Reads from the RecordContext (NOT a source scope) on purpose — a
|
|
13
|
+
* field tracks the record, not the form's source prefix.
|
|
13
14
|
*/
|
|
14
|
-
import type
|
|
15
|
+
import { type LooseRecord, type SourceProp, type SourceValue } from "@chelone/core";
|
|
15
16
|
import { type ComputedRef } from "vue";
|
|
16
17
|
import { type RecordValue } from "./record-context.js";
|
|
17
|
-
export interface UseFieldValueOptions<RecordType = LooseRecord> {
|
|
18
|
+
export interface UseFieldValueOptions<RecordType = LooseRecord, TPath extends SourceProp<RecordType> = SourceProp<RecordType>> {
|
|
18
19
|
/** The field path — dot members and/or bracket/numeric indices. */
|
|
19
|
-
source:
|
|
20
|
+
source: TPath;
|
|
20
21
|
/** Override the ambient record (a static record wins over the context ref). */
|
|
21
22
|
record?: RecordValue<RecordType>;
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Returned only when the resolved value is `undefined`. Untyped on purpose:
|
|
25
|
+
* the result type is the record's value at `source`, not the default's.
|
|
26
|
+
*/
|
|
23
27
|
defaultValue?: unknown;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
|
-
* The value at `source` off the ambient (or overridden) record, reactively.
|
|
30
|
+
* The value at `source` off the ambient (or overridden) record, reactively. A
|
|
31
|
+
* typed `record` and a literal `source` give the value's type;
|
|
32
|
+
* `useFieldValue<Post>(...)` alone infers no path, so the value is the union of
|
|
33
|
+
* Post's value types.
|
|
34
|
+
*
|
|
35
|
+
* The type does not include `undefined` for a record that has not loaded: before
|
|
36
|
+
* the ambient record resolves, `.value` is `undefined`, so guard it in a view
|
|
37
|
+
* that renders while loading.
|
|
27
38
|
*
|
|
28
39
|
* @example
|
|
29
40
|
* const name = useFieldValue({ source: "author.name" });
|
|
30
41
|
* // template: {{ name }}
|
|
31
42
|
*/
|
|
32
|
-
export declare function useFieldValue<RecordType = LooseRecord>(options: UseFieldValueOptions<RecordType>): ComputedRef<
|
|
43
|
+
export declare function useFieldValue<RecordType = LooseRecord, TPath extends SourceProp<RecordType> = SourceProp<RecordType>>(options: UseFieldValueOptions<RecordType, TPath>): ComputedRef<SourceValue<RecordType, TPath>>;
|
|
@@ -1,30 +1,13 @@
|
|
|
1
|
+
import { getAtPath } from "@chelone/core";
|
|
1
2
|
import { inject, computed } from "vue";
|
|
2
3
|
import { RecordContextKey } from "./record-context.js";
|
|
3
|
-
function toPathSegments(source) {
|
|
4
|
-
if (source === "") return [];
|
|
5
|
-
const segments = [];
|
|
6
|
-
const pattern = /\[([^\]]*)\]|[^.[\]]+/g;
|
|
7
|
-
let match = pattern.exec(source);
|
|
8
|
-
while (match !== null) {
|
|
9
|
-
segments.push(match[1] !== void 0 ? match[1] : match[0]);
|
|
10
|
-
match = pattern.exec(source);
|
|
11
|
-
}
|
|
12
|
-
return segments;
|
|
13
|
-
}
|
|
14
|
-
function getAtPath(record, source, defaultValue) {
|
|
15
|
-
let current = record;
|
|
16
|
-
for (const key of toPathSegments(source)) {
|
|
17
|
-
if (current == null || typeof current !== "object") return defaultValue;
|
|
18
|
-
current = current[key];
|
|
19
|
-
}
|
|
20
|
-
return current === void 0 ? defaultValue : current;
|
|
21
|
-
}
|
|
22
4
|
function useFieldValue(options) {
|
|
23
5
|
const { source, defaultValue } = options;
|
|
24
6
|
const injected = inject(RecordContextKey, null);
|
|
25
7
|
return computed(() => {
|
|
26
8
|
const record = options.record !== void 0 ? options.record : injected?.value;
|
|
27
|
-
|
|
9
|
+
const value = getAtPath(record, source);
|
|
10
|
+
return value === void 0 ? defaultValue : value;
|
|
28
11
|
});
|
|
29
12
|
}
|
|
30
13
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chelone/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"cronstrue": "^3.24.0",
|
|
59
59
|
"libphonenumber-js": "^1.13.8",
|
|
60
|
-
"@chelone/core": "0.
|
|
60
|
+
"@chelone/core": "0.4.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@guolao/vue-monaco-editor": "^1.6.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"terra-draw-maplibre-gl-adapter": "^1.5.0",
|
|
77
77
|
"vue": "^3.4.0",
|
|
78
78
|
"vue-router": "^4.0.0",
|
|
79
|
-
"@chelone/supabase": "0.
|
|
79
|
+
"@chelone/supabase": "0.4.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@chelone/supabase": {
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"vue-router": "^4.0.0",
|
|
151
151
|
"vue-tsc": "^2.0.0",
|
|
152
152
|
"zod": "^3.24.0",
|
|
153
|
-
"@chelone/supabase": "0.
|
|
153
|
+
"@chelone/supabase": "0.4.0"
|
|
154
154
|
},
|
|
155
155
|
"scripts": {
|
|
156
156
|
"build": "vite build && vue-tsc -p tsconfig.build.json && node ../../scripts/strip-dts-css-imports.mjs dist && node ../../scripts/dts-extensions.mjs dist",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read a value at a dot path off `record`. Clean-room stand-in for
|
|
3
|
-
* `lodash/get(record, path)` (chelone stays zero-lodash) — shared by the
|
|
4
|
-
* per-item title/src lookups in `<FileField>` / `<ImageField>`'s array branch.
|
|
5
|
-
* Mirrors the identical helper in the React twins.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getPath(record: unknown, path: string): unknown;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function getPath(record, path) {
|
|
2
|
-
if (record != null && typeof record === "object" && path in record) {
|
|
3
|
-
return record[path];
|
|
4
|
-
}
|
|
5
|
-
let current = record;
|
|
6
|
-
for (const key of path.split(".")) {
|
|
7
|
-
if (current == null || typeof current !== "object") return void 0;
|
|
8
|
-
current = current[key];
|
|
9
|
-
}
|
|
10
|
-
return current;
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
getPath
|
|
14
|
-
};
|