@svadmin/ui 0.81.0 → 0.82.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.
@@ -1,6 +1,6 @@
1
1
  import type { Component } from 'svelte';
2
2
  import type { FieldDefinition } from '@svadmin/core';
3
- import { type Static, type TSchema } from '@sinclair/typebox';
3
+ import { type Static, type TSchema } from 'typebox';
4
4
  import { type SafeSchema } from '@svadmin/core/schema';
5
5
  export interface FieldDisplayProps {
6
6
  value: unknown;
@@ -1,4 +1,4 @@
1
- import { Type } from '@sinclair/typebox';
1
+ import { Type } from 'typebox';
2
2
  import { closeContractSchema, createExactSchemaValidator } from '@svadmin/core/schema';
3
3
  import { definedOptions } from '@svadmin/core/options';
4
4
  import ValidatedField from './ValidatedField.svelte';
@@ -39,11 +39,13 @@ function validatedDisplay(schema, component, project = input => ({ value: input.
39
39
  return (internals, input) => ValidatedField(internals, { component, resolve, input });
40
40
  }
41
41
  const nullable = (schema) => Type.Union([schema, Type.Null(), Type.Undefined()]);
42
+ /** TypeBox 1.x removed Type.Date; a Date instance is modelled with Unsafe plus a Refine guard. */
43
+ const dateType = Type.Refine(Type.Unsafe({ type: 'Date' }), (value) => value instanceof globalThis.Date && !Number.isNaN(value.getTime()), () => 'Expected Date');
42
44
  const text = nullable(Type.String());
43
45
  const numeric = nullable(Type.Number());
44
46
  const scalar = nullable(Type.Union([Type.String(), Type.Number()]));
45
- const date = nullable(Type.Union([Type.String(), Type.Number(), Type.Date()]));
46
- const dateProperty = Type.Optional(Type.Union([Type.String(), Type.Number(), Type.Date(), Type.Null()]));
47
+ const date = nullable(Type.Union([Type.String(), Type.Number(), dateType]));
48
+ const dateProperty = Type.Optional(Type.Union([Type.String(), Type.Number(), dateType, Type.Null()]));
47
49
  const choices = Type.Optional(Type.Array(Type.Object({
48
50
  label: Type.String(), value: Type.Union([Type.String(), Type.Number()]),
49
51
  }, { additionalProperties: false })));
@@ -1,4 +1,7 @@
1
- export declare const jsonValueSchema: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
1
+ import { Type } from 'typebox';
2
+ export declare const jsonValueSchema: Type.TCyclic<{
3
+ JsonValue: Type.TUnion<[Type.TNull, Type.TBoolean, Type.TNumber, Type.TString, Type.TArray<Type.TRef<"JsonValue">>, Type.TRefine<Type.TRecord<"^.*$", Type.TRef<"JsonValue">>>]>;
4
+ }, "JsonValue">;
2
5
  export type JsonDisplay = {
3
6
  status: 'empty';
4
7
  } | {
@@ -1,9 +1,19 @@
1
- import { Type } from '@sinclair/typebox';
1
+ import { Type } from 'typebox';
2
2
  import { createExactSchemaValidator } from '@svadmin/core/schema';
3
- export const jsonValueSchema = Type.Recursive(Self => Type.Union([
4
- Type.Null(), Type.Boolean(), Type.Number(), Type.String(),
5
- Type.Array(Self), Type.Record(Type.String(), Self),
6
- ]));
3
+ /** TypeBox 1.x Record validation accepts class instances; keep JSON objects plain. */
4
+ function isPlainRecord(value) {
5
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
6
+ return false;
7
+ const prototype = Object.getPrototypeOf(value);
8
+ return prototype === Object.prototype || prototype === null;
9
+ }
10
+ export const jsonValueSchema = Type.Cyclic({
11
+ JsonValue: Type.Union([
12
+ Type.Null(), Type.Boolean(), Type.Number(), Type.String(),
13
+ Type.Array(Type.Ref('JsonValue')),
14
+ Type.Refine(Type.Record(Type.String(), Type.Ref('JsonValue')), isPlainRecord, () => 'Expected plain object'),
15
+ ]),
16
+ }, 'JsonValue');
7
17
  const validator = createExactSchemaValidator(jsonValueSchema);
8
18
  export function formatJsonValue(value) {
9
19
  if (value == null)
@@ -1,4 +1,4 @@
1
- import { Type } from '@sinclair/typebox';
1
+ import { Type } from 'typebox';
2
2
  import { checkExact, decodeBaseRecord, snapshotPlainData, rejectProviderResponse } from '@svadmin/core/schema';
3
3
  const recordShape = Type.Intersect([
4
4
  Type.Record(Type.String(), Type.Unknown()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.81.0",
3
+ "version": "0.82.0",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -88,7 +88,7 @@
88
88
  "@codemirror/lang-json": "^6.0.0",
89
89
  "@codemirror/lang-markdown": "^6.0.0",
90
90
  "@codemirror/lang-sql": "^6.0.0",
91
- "@svadmin/core": "^0.58.0",
91
+ "@svadmin/core": "^0.59.0",
92
92
  "@tanstack/svelte-query": "^6.1.48",
93
93
  "codemirror": "^6.0.0",
94
94
  "isomorphic-dompurify": "^3.23.0",
@@ -141,7 +141,7 @@
141
141
  "dependencies": {
142
142
  "@svadmin/devtools-contract": "^0.3.0",
143
143
  "@vibeunion/devtools-devframe": "^0.1.0",
144
- "@sinclair/typebox": "^0.34.52",
144
+ "typebox": "^1.3.34",
145
145
  "@floating-ui/dom": "^1.8.0",
146
146
  "esm-env": "^1.2.2",
147
147
  "@lucide/svelte": "^1.35.0",
@@ -176,7 +176,7 @@
176
176
  "@codemirror/lang-markdown": "^6.5.2",
177
177
  "@codemirror/lang-sql": "^6.10.0",
178
178
  "@happy-dom/global-registrator": "^20.11.12",
179
- "@svadmin/ai-elements": "^0.10.3",
179
+ "@svadmin/ai-elements": "^0.11.0",
180
180
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
181
181
  "@tailwindcss/cli": "4.3.3",
182
182
  "@testing-library/dom": "^10.4.1",