@atscript/ui 0.1.112 → 0.1.114

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/index.cjs CHANGED
@@ -144,9 +144,21 @@ function resolveFormProp(type, fnKey, staticKey, scope, opts) {
144
144
  function hasComputedAnnotations(prop) {
145
145
  return activeResolver.hasComputedAnnotations(prop);
146
146
  }
147
+ /**
148
+ * SSOT for field hidden resolution — resolves `@ui.form.fn.hidden`
149
+ * (dynamic, via the active resolver) with static `@ui.form.hidden`
150
+ * presence as the fallback. Absent both → `false` (visible).
151
+ */
152
+ function isFieldHidden(prop, scope) {
153
+ return resolveFieldProp(prop, "ui.form.fn.hidden", "ui.form.hidden", scope, { staticAsBoolean: true }) ?? false;
154
+ }
147
155
  function getFieldMeta(prop, key) {
148
156
  return prop.metadata.get(key);
149
157
  }
158
+ /** Checks whether a metadata key is present on an ATScript prop. */
159
+ function hasFieldMeta(prop, key) {
160
+ return prop.metadata.has(key);
161
+ }
150
162
  /** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
151
163
  function asArray(x) {
152
164
  return Array.isArray(x) ? x : [x];
@@ -775,6 +787,15 @@ function buildResolved(url, meta, targetType) {
775
787
  //#endregion
776
788
  //#region src/form/path-utils.ts
777
789
  /**
790
+ * Joins a dot-separated path prefix with a segment. Empty-safe on both
791
+ * sides: an empty segment returns the prefix as-is, an empty prefix
792
+ * returns the segment as-is (no leading/trailing dots).
793
+ */
794
+ function joinPath(prefix, segment) {
795
+ if (!segment) return prefix;
796
+ return prefix ? `${prefix}.${segment}` : segment;
797
+ }
798
+ /**
778
799
  * Gets a nested value by dot-separated path.
779
800
  * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
780
801
  * When `path` is empty, returns the root domain data (`obj.value`).
@@ -2267,6 +2288,34 @@ function getColumn(def, path) {
2267
2288
  return def.columns.find((c) => c.path === path);
2268
2289
  }
2269
2290
  //#endregion
2291
+ //#region src/table/navigate-href.ts
2292
+ /**
2293
+ * Compute the href a `processor: 'navigate'` action would open — synchronously,
2294
+ * at render time. Mirrors the interpolation `Client` performs when the action
2295
+ * is invoked (`action.value` with every `$1` replaced by the URL-encoded,
2296
+ * `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
2297
+ * render navigate actions as real `<a href>` anchors and native link behaviour
2298
+ * (middle-click → new tab, copy link, hover preview) just works.
2299
+ *
2300
+ * Returns `undefined` when no link is possible — the caller should fall back to
2301
+ * a button and let `Client` handle the invoke:
2302
+ *
2303
+ * - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
2304
+ * - row-level action with `id === undefined` — the row is not identifiable
2305
+ * (note this deliberately differs from `Client`, which navigates to the raw
2306
+ * template in that case; a raw-template href would be a broken link);
2307
+ * - row-level action with an empty `preferredId` — `$1` has nothing to encode.
2308
+ *
2309
+ * Table/rows-level navigate actions carry no `$1` placeholder and return
2310
+ * `action.value` verbatim.
2311
+ */
2312
+ function navigateHrefFor(action, id, preferredId) {
2313
+ if (action.processor !== "navigate") return void 0;
2314
+ if (action.level !== "row") return action.value;
2315
+ if (id === void 0 || preferredId.length === 0) return void 0;
2316
+ return action.value.replace(/\$1/g, (0, _atscript_db_client.encodeNavigateId)(id, preferredId));
2317
+ }
2318
+ //#endregion
2270
2319
  exports.DB_AMOUNT_CURRENCY = DB_AMOUNT_CURRENCY;
2271
2320
  exports.DB_AMOUNT_CURRENCY_REF = DB_AMOUNT_CURRENCY_REF;
2272
2321
  exports.DB_COLUMN_PRECISION = DB_COLUMN_PRECISION;
@@ -2387,7 +2436,9 @@ exports.getSortableColumns = getSortableColumns;
2387
2436
  exports.getThousandsSeparator = getThousandsSeparator;
2388
2437
  exports.groupInteger = groupInteger;
2389
2438
  exports.hasComputedAnnotations = hasComputedAnnotations;
2439
+ exports.hasFieldMeta = hasFieldMeta;
2390
2440
  exports.isArrayField = isArrayField;
2441
+ exports.isFieldHidden = isFieldHidden;
2391
2442
  exports.isObjectField = isObjectField;
2392
2443
  exports.isPathDirty = isPathDirty;
2393
2444
  exports.isPureLiteralUnion = isPureLiteralUnion;
@@ -2395,7 +2446,9 @@ exports.isTupleField = isTupleField;
2395
2446
  exports.isUnionField = isUnionField;
2396
2447
  exports.iteratePathAncestors = iteratePathAncestors;
2397
2448
  exports.joinDecimalString = joinDecimalString;
2449
+ exports.joinPath = joinPath;
2398
2450
  exports.mergeErrorMaps = mergeErrorMaps;
2451
+ exports.navigateHrefFor = navigateHrefFor;
2399
2452
  exports.optKey = optKey;
2400
2453
  exports.optLabel = optLabel;
2401
2454
  exports.parseColSpan = parseColSpan;
package/dist/index.d.cts CHANGED
@@ -289,12 +289,20 @@ declare function resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string
289
289
  declare function resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
290
290
  /** Check if a prop has dynamic annotations via the active resolver. */
291
291
  declare function hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
292
+ /**
293
+ * SSOT for field hidden resolution — resolves `@ui.form.fn.hidden`
294
+ * (dynamic, via the active resolver) with static `@ui.form.hidden`
295
+ * presence as the fallback. Absent both → `false` (visible).
296
+ */
297
+ declare function isFieldHidden(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): boolean;
292
298
  /**
293
299
  * Reads a static metadata value from an ATScript prop.
294
300
  * Typed overload for known AtscriptMetadata keys; falls back to `unknown` for other keys.
295
301
  */
296
302
  declare function getFieldMeta<K extends keyof AtscriptMetadata>(prop: TAtscriptAnnotatedType, key: K): AtscriptMetadata[K] | undefined;
297
303
  declare function getFieldMeta(prop: TAtscriptAnnotatedType, key: string): unknown;
304
+ /** Checks whether a metadata key is present on an ATScript prop. */
305
+ declare function hasFieldMeta(prop: TAtscriptAnnotatedType, key: string): boolean;
298
306
  /** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
299
307
  declare function asArray<T>(x: T | T[]): T[];
300
308
  /**
@@ -429,6 +437,12 @@ declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
429
437
  declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
430
438
  //#endregion
431
439
  //#region src/form/path-utils.d.ts
440
+ /**
441
+ * Joins a dot-separated path prefix with a segment. Empty-safe on both
442
+ * sides: an empty segment returns the prefix as-is, an empty prefix
443
+ * returns the segment as-is (no leading/trailing dots).
444
+ */
445
+ declare function joinPath(prefix: string, segment: string): string;
432
446
  /**
433
447
  * Gets a nested value by dot-separated path.
434
448
  * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
@@ -1182,4 +1196,27 @@ declare function getFilterableColumns(def: TableDef): ColumnDef[];
1182
1196
  /** Find a column by path. */
1183
1197
  declare function getColumn(def: TableDef, path: string): ColumnDef | undefined;
1184
1198
  //#endregion
1185
- export { type ClientFactory, type CloneUnwrap, type ColumnDef, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, isArrayField, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, mergeErrorMaps, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
1199
+ //#region src/table/navigate-href.d.ts
1200
+ /**
1201
+ * Compute the href a `processor: 'navigate'` action would open — synchronously,
1202
+ * at render time. Mirrors the interpolation `Client` performs when the action
1203
+ * is invoked (`action.value` with every `$1` replaced by the URL-encoded,
1204
+ * `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
1205
+ * render navigate actions as real `<a href>` anchors and native link behaviour
1206
+ * (middle-click → new tab, copy link, hover preview) just works.
1207
+ *
1208
+ * Returns `undefined` when no link is possible — the caller should fall back to
1209
+ * a button and let `Client` handle the invoke:
1210
+ *
1211
+ * - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
1212
+ * - row-level action with `id === undefined` — the row is not identifiable
1213
+ * (note this deliberately differs from `Client`, which navigates to the raw
1214
+ * template in that case; a raw-template href would be a broken link);
1215
+ * - row-level action with an empty `preferredId` — `$1` has nothing to encode.
1216
+ *
1217
+ * Table/rows-level navigate actions carry no `$1` placeholder and return
1218
+ * `action.value` verbatim.
1219
+ */
1220
+ declare function navigateHrefFor(action: TDbActionInfo$1, id: Record<string, unknown> | undefined, preferredId: readonly string[]): string | undefined;
1221
+ //#endregion
1222
+ export { type ClientFactory, type CloneUnwrap, type ColumnDef, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
package/dist/index.d.mts CHANGED
@@ -289,12 +289,20 @@ declare function resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string
289
289
  declare function resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
290
290
  /** Check if a prop has dynamic annotations via the active resolver. */
291
291
  declare function hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
292
+ /**
293
+ * SSOT for field hidden resolution — resolves `@ui.form.fn.hidden`
294
+ * (dynamic, via the active resolver) with static `@ui.form.hidden`
295
+ * presence as the fallback. Absent both → `false` (visible).
296
+ */
297
+ declare function isFieldHidden(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): boolean;
292
298
  /**
293
299
  * Reads a static metadata value from an ATScript prop.
294
300
  * Typed overload for known AtscriptMetadata keys; falls back to `unknown` for other keys.
295
301
  */
296
302
  declare function getFieldMeta<K extends keyof AtscriptMetadata>(prop: TAtscriptAnnotatedType, key: K): AtscriptMetadata[K] | undefined;
297
303
  declare function getFieldMeta(prop: TAtscriptAnnotatedType, key: string): unknown;
304
+ /** Checks whether a metadata key is present on an ATScript prop. */
305
+ declare function hasFieldMeta(prop: TAtscriptAnnotatedType, key: string): boolean;
298
306
  /** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
299
307
  declare function asArray<T>(x: T | T[]): T[];
300
308
  /**
@@ -429,6 +437,12 @@ declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
429
437
  declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
430
438
  //#endregion
431
439
  //#region src/form/path-utils.d.ts
440
+ /**
441
+ * Joins a dot-separated path prefix with a segment. Empty-safe on both
442
+ * sides: an empty segment returns the prefix as-is, an empty prefix
443
+ * returns the segment as-is (no leading/trailing dots).
444
+ */
445
+ declare function joinPath(prefix: string, segment: string): string;
432
446
  /**
433
447
  * Gets a nested value by dot-separated path.
434
448
  * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
@@ -1182,4 +1196,27 @@ declare function getFilterableColumns(def: TableDef): ColumnDef[];
1182
1196
  /** Find a column by path. */
1183
1197
  declare function getColumn(def: TableDef, path: string): ColumnDef | undefined;
1184
1198
  //#endregion
1185
- export { type ClientFactory, type CloneUnwrap, type ColumnDef, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, isArrayField, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, mergeErrorMaps, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
1199
+ //#region src/table/navigate-href.d.ts
1200
+ /**
1201
+ * Compute the href a `processor: 'navigate'` action would open — synchronously,
1202
+ * at render time. Mirrors the interpolation `Client` performs when the action
1203
+ * is invoked (`action.value` with every `$1` replaced by the URL-encoded,
1204
+ * `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
1205
+ * render navigate actions as real `<a href>` anchors and native link behaviour
1206
+ * (middle-click → new tab, copy link, hover preview) just works.
1207
+ *
1208
+ * Returns `undefined` when no link is possible — the caller should fall back to
1209
+ * a button and let `Client` handle the invoke:
1210
+ *
1211
+ * - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
1212
+ * - row-level action with `id === undefined` — the row is not identifiable
1213
+ * (note this deliberately differs from `Client`, which navigates to the raw
1214
+ * template in that case; a raw-template href would be a broken link);
1215
+ * - row-level action with an empty `preferredId` — `$1` has nothing to encode.
1216
+ *
1217
+ * Table/rows-level navigate actions carry no `$1` placeholder and return
1218
+ * `action.value` verbatim.
1219
+ */
1220
+ declare function navigateHrefFor(action: TDbActionInfo$1, id: Record<string, unknown> | undefined, preferredId: readonly string[]): string | undefined;
1221
+ //#endregion
1222
+ export { type ClientFactory, type CloneUnwrap, type ColumnDef, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Validator, createDataFromAnnotatedType, deserializeAnnotatedType, detectDiscriminator, flattenAnnotatedType } from "@atscript/typescript/utils";
2
- import { Client } from "@atscript/db-client";
2
+ import { Client, encodeNavigateId } from "@atscript/db-client";
3
3
  //#region src/shared/annotation-keys.ts
4
4
  const UI_TYPE = "ui.type";
5
5
  const UI_FORM_PLACEHOLDER = "ui.form.placeholder";
@@ -143,9 +143,21 @@ function resolveFormProp(type, fnKey, staticKey, scope, opts) {
143
143
  function hasComputedAnnotations(prop) {
144
144
  return activeResolver.hasComputedAnnotations(prop);
145
145
  }
146
+ /**
147
+ * SSOT for field hidden resolution — resolves `@ui.form.fn.hidden`
148
+ * (dynamic, via the active resolver) with static `@ui.form.hidden`
149
+ * presence as the fallback. Absent both → `false` (visible).
150
+ */
151
+ function isFieldHidden(prop, scope) {
152
+ return resolveFieldProp(prop, "ui.form.fn.hidden", "ui.form.hidden", scope, { staticAsBoolean: true }) ?? false;
153
+ }
146
154
  function getFieldMeta(prop, key) {
147
155
  return prop.metadata.get(key);
148
156
  }
157
+ /** Checks whether a metadata key is present on an ATScript prop. */
158
+ function hasFieldMeta(prop, key) {
159
+ return prop.metadata.has(key);
160
+ }
149
161
  /** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
150
162
  function asArray(x) {
151
163
  return Array.isArray(x) ? x : [x];
@@ -774,6 +786,15 @@ function buildResolved(url, meta, targetType) {
774
786
  //#endregion
775
787
  //#region src/form/path-utils.ts
776
788
  /**
789
+ * Joins a dot-separated path prefix with a segment. Empty-safe on both
790
+ * sides: an empty segment returns the prefix as-is, an empty prefix
791
+ * returns the segment as-is (no leading/trailing dots).
792
+ */
793
+ function joinPath(prefix, segment) {
794
+ if (!segment) return prefix;
795
+ return prefix ? `${prefix}.${segment}` : segment;
796
+ }
797
+ /**
777
798
  * Gets a nested value by dot-separated path.
778
799
  * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
779
800
  * When `path` is empty, returns the root domain data (`obj.value`).
@@ -2266,4 +2287,32 @@ function getColumn(def, path) {
2266
2287
  return def.columns.find((c) => c.path === path);
2267
2288
  }
2268
2289
  //#endregion
2269
- export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, StaticFieldResolver, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, isArrayField, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, mergeErrorMaps, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
2290
+ //#region src/table/navigate-href.ts
2291
+ /**
2292
+ * Compute the href a `processor: 'navigate'` action would open — synchronously,
2293
+ * at render time. Mirrors the interpolation `Client` performs when the action
2294
+ * is invoked (`action.value` with every `$1` replaced by the URL-encoded,
2295
+ * `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
2296
+ * render navigate actions as real `<a href>` anchors and native link behaviour
2297
+ * (middle-click → new tab, copy link, hover preview) just works.
2298
+ *
2299
+ * Returns `undefined` when no link is possible — the caller should fall back to
2300
+ * a button and let `Client` handle the invoke:
2301
+ *
2302
+ * - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
2303
+ * - row-level action with `id === undefined` — the row is not identifiable
2304
+ * (note this deliberately differs from `Client`, which navigates to the raw
2305
+ * template in that case; a raw-template href would be a broken link);
2306
+ * - row-level action with an empty `preferredId` — `$1` has nothing to encode.
2307
+ *
2308
+ * Table/rows-level navigate actions carry no `$1` placeholder and return
2309
+ * `action.value` verbatim.
2310
+ */
2311
+ function navigateHrefFor(action, id, preferredId) {
2312
+ if (action.processor !== "navigate") return void 0;
2313
+ if (action.level !== "row") return action.value;
2314
+ if (id === void 0 || preferredId.length === 0) return void 0;
2315
+ return action.value.replace(/\$1/g, encodeNavigateId(id, preferredId));
2316
+ }
2317
+ //#endregion
2318
+ export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, StaticFieldResolver, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/ui",
3
- "version": "0.1.112",
3
+ "version": "0.1.114",
4
4
  "description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
5
5
  "keywords": [
6
6
  "annotations",