@contractspec/lib.design-system 4.2.0 → 4.3.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.
Files changed (133) hide show
  1. package/README.md +95 -0
  2. package/dist/browser/components/data-view/DataViewGrid.js +1 -0
  3. package/dist/browser/components/data-view/DataViewList.js +1 -1
  4. package/dist/browser/components/data-view/DataViewRenderer.js +1 -1
  5. package/dist/browser/components/data-view/DataViewTable.js +1 -1
  6. package/dist/browser/components/data-view/collection.js +1 -0
  7. package/dist/browser/components/data-view/utils.js +1 -1
  8. package/dist/browser/components/molecules/Tabs.js +1 -1
  9. package/dist/browser/components/object-reference/DefaultObjectReferenceParts.js +1 -0
  10. package/dist/browser/components/object-reference/ObjectReferenceHandler.js +1 -0
  11. package/dist/browser/components/object-reference/ReferenceIcon.js +1 -0
  12. package/dist/browser/components/object-reference/actions.js +1 -0
  13. package/dist/browser/components/object-reference/index.js +1 -0
  14. package/dist/browser/components/object-reference/maps.js +1 -0
  15. package/dist/browser/components/object-reference/runtime.js +1 -0
  16. package/dist/browser/components/object-reference/types.js +0 -0
  17. package/dist/browser/components/object-reference/useObjectReferenceController.js +1 -0
  18. package/dist/browser/components/shell/AppShell.js +1 -0
  19. package/dist/browser/components/shell/AppShell.types.js +0 -0
  20. package/dist/browser/components/shell/PageOutline.js +1 -0
  21. package/dist/browser/components/shell/ShellSidebar.js +1 -0
  22. package/dist/browser/components/shell/index.js +1 -0
  23. package/dist/browser/components/shell/outline.js +1 -0
  24. package/dist/browser/components/shell/types.js +0 -0
  25. package/dist/browser/design-system.feature.js +1 -1
  26. package/dist/browser/index.js +1 -1
  27. package/dist/browser/renderers/form-contract/renderer.js +1 -1
  28. package/dist/browser/renderers/form-contract/shell.js +1 -1
  29. package/dist/browser/shell.js +1 -0
  30. package/dist/components/data-view/DataViewGrid.d.ts +12 -0
  31. package/dist/components/data-view/DataViewGrid.js +1 -0
  32. package/dist/components/data-view/DataViewGrid.native.d.ts +12 -0
  33. package/dist/components/data-view/DataViewList.d.ts +3 -2
  34. package/dist/components/data-view/DataViewList.js +1 -1
  35. package/dist/components/data-view/DataViewList.native.d.ts +12 -0
  36. package/dist/components/data-view/DataViewRenderer.d.ts +8 -2
  37. package/dist/components/data-view/DataViewRenderer.js +1 -1
  38. package/dist/components/data-view/DataViewRenderer.native.d.ts +8 -2
  39. package/dist/components/data-view/DataViewTable.d.ts +3 -2
  40. package/dist/components/data-view/DataViewTable.js +1 -1
  41. package/dist/components/data-view/DataViewTable.native.d.ts +3 -2
  42. package/dist/components/data-view/collection.d.ts +16 -0
  43. package/dist/components/data-view/collection.js +1 -0
  44. package/dist/components/data-view/utils.js +1 -1
  45. package/dist/components/molecules/Tabs.js +1 -1
  46. package/dist/components/object-reference/DefaultObjectReferenceParts.d.ts +18 -0
  47. package/dist/components/object-reference/DefaultObjectReferenceParts.js +1 -0
  48. package/dist/components/object-reference/DefaultObjectReferenceParts.native.d.ts +13 -0
  49. package/dist/components/object-reference/ObjectReferenceHandler.d.ts +2 -0
  50. package/dist/components/object-reference/ObjectReferenceHandler.js +1 -0
  51. package/dist/components/object-reference/ObjectReferenceHandler.native.d.ts +2 -0
  52. package/dist/components/object-reference/ReferenceIcon.d.ts +7 -0
  53. package/dist/components/object-reference/ReferenceIcon.js +1 -0
  54. package/dist/components/object-reference/actions.d.ts +7 -0
  55. package/dist/components/object-reference/actions.js +1 -0
  56. package/dist/components/object-reference/index.d.ts +4 -0
  57. package/dist/components/object-reference/index.js +1 -0
  58. package/dist/components/object-reference/index.native.d.ts +4 -0
  59. package/dist/components/object-reference/maps.d.ts +8 -0
  60. package/dist/components/object-reference/maps.js +1 -0
  61. package/dist/components/object-reference/runtime.d.ts +12 -0
  62. package/dist/components/object-reference/runtime.js +1 -0
  63. package/dist/components/object-reference/types.d.ts +73 -0
  64. package/dist/components/object-reference/types.js +0 -0
  65. package/dist/components/object-reference/useObjectReferenceController.d.ts +13 -0
  66. package/dist/components/object-reference/useObjectReferenceController.js +1 -0
  67. package/dist/components/shell/AppShell.d.ts +2 -0
  68. package/dist/components/shell/AppShell.js +1 -0
  69. package/dist/components/shell/AppShell.native.d.ts +2 -0
  70. package/dist/components/shell/AppShell.types.d.ts +21 -0
  71. package/dist/components/shell/AppShell.types.js +0 -0
  72. package/dist/components/shell/PageOutline.d.ts +12 -0
  73. package/dist/components/shell/PageOutline.js +1 -0
  74. package/dist/components/shell/PageOutline.native.d.ts +11 -0
  75. package/dist/components/shell/ShellSidebar.d.ts +11 -0
  76. package/dist/components/shell/ShellSidebar.js +1 -0
  77. package/dist/components/shell/index.d.ts +5 -0
  78. package/dist/components/shell/index.js +1 -0
  79. package/dist/components/shell/index.native.d.ts +4 -0
  80. package/dist/components/shell/outline.d.ts +5 -0
  81. package/dist/components/shell/outline.js +1 -0
  82. package/dist/components/shell/types.d.ts +66 -0
  83. package/dist/components/shell/types.js +0 -0
  84. package/dist/design-system.feature.js +1 -1
  85. package/dist/index.d.ts +4 -0
  86. package/dist/index.js +1 -1
  87. package/dist/native/components/data-view/DataViewGrid.js +1 -0
  88. package/dist/native/components/data-view/DataViewGrid.native.js +1 -0
  89. package/dist/native/components/data-view/DataViewList.js +1 -1
  90. package/dist/native/components/data-view/DataViewList.native.js +1 -0
  91. package/dist/native/components/data-view/DataViewRenderer.js +1 -1
  92. package/dist/native/components/data-view/DataViewRenderer.native.js +1 -1
  93. package/dist/native/components/data-view/DataViewTable.js +1 -1
  94. package/dist/native/components/data-view/DataViewTable.native.js +1 -1
  95. package/dist/native/components/data-view/collection.js +1 -0
  96. package/dist/native/components/data-view/utils.js +1 -1
  97. package/dist/native/components/molecules/Tabs.js +1 -1
  98. package/dist/native/components/molecules/Tabs.native.js +1 -1
  99. package/dist/native/components/object-reference/DefaultObjectReferenceParts.js +1 -0
  100. package/dist/native/components/object-reference/DefaultObjectReferenceParts.native.js +1 -0
  101. package/dist/native/components/object-reference/ObjectReferenceHandler.js +1 -0
  102. package/dist/native/components/object-reference/ObjectReferenceHandler.native.js +1 -0
  103. package/dist/native/components/object-reference/ReferenceIcon.js +1 -0
  104. package/dist/native/components/object-reference/actions.js +1 -0
  105. package/dist/native/components/object-reference/index.js +1 -0
  106. package/dist/native/components/object-reference/index.native.js +1 -0
  107. package/dist/native/components/object-reference/maps.js +1 -0
  108. package/dist/native/components/object-reference/runtime.js +1 -0
  109. package/dist/native/components/object-reference/types.js +0 -0
  110. package/dist/native/components/object-reference/useObjectReferenceController.js +1 -0
  111. package/dist/native/components/shell/AppShell.js +1 -0
  112. package/dist/native/components/shell/AppShell.native.js +1 -0
  113. package/dist/native/components/shell/AppShell.types.js +0 -0
  114. package/dist/native/components/shell/PageOutline.js +1 -0
  115. package/dist/native/components/shell/PageOutline.native.js +1 -0
  116. package/dist/native/components/shell/ShellSidebar.js +1 -0
  117. package/dist/native/components/shell/index.js +1 -0
  118. package/dist/native/components/shell/index.native.js +1 -0
  119. package/dist/native/components/shell/outline.js +1 -0
  120. package/dist/native/components/shell/types.js +0 -0
  121. package/dist/native/design-system.feature.js +1 -1
  122. package/dist/native/index.js +1 -1
  123. package/dist/native/renderers/form-contract/renderer.js +1 -1
  124. package/dist/native/renderers/form-contract/shell.js +1 -1
  125. package/dist/native/shell.js +1 -0
  126. package/dist/native/shell.native.js +1 -0
  127. package/dist/renderers/form-contract/renderer.js +1 -1
  128. package/dist/renderers/form-contract/shell.d.ts +9 -0
  129. package/dist/renderers/form-contract/shell.js +1 -1
  130. package/dist/shell.d.ts +1 -0
  131. package/dist/shell.js +1 -0
  132. package/dist/shell.native.d.ts +1 -0
  133. package/package.json +343 -7
@@ -1,4 +1,4 @@
1
- import type { DataViewField, DataViewSpec } from '@contractspec/lib.contracts-spec/data-views';
1
+ import type { DataViewDensity, DataViewField, DataViewSpec } from '@contractspec/lib.contracts-spec/data-views';
2
2
  import * as React from 'react';
3
3
  export interface DataViewTableProps {
4
4
  spec: DataViewSpec;
@@ -10,8 +10,9 @@ export interface DataViewTableProps {
10
10
  emptyState?: React.ReactNode;
11
11
  headerActions?: React.ReactNode;
12
12
  footer?: React.ReactNode;
13
+ density?: DataViewDensity;
13
14
  }
14
- export declare function DataViewTable({ spec, items, className, onRowClick, toolbar, loading, emptyState, headerActions, footer, }: DataViewTableProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function DataViewTable({ spec, items, className, onRowClick, toolbar, loading, emptyState, headerActions, footer, density, }: DataViewTableProps): import("react/jsx-runtime").JSX.Element;
15
16
  export declare function DisplayValue({ item, fields, fieldKey, }: {
16
17
  item: Record<string, unknown>;
17
18
  fields: DataViewField[];
@@ -1 +1 @@
1
- import{jsx as E,jsxs as V}from"react/jsx-runtime";import{useDataViewTable as A}from"@contractspec/lib.presentation-runtime-react";import{HStack as F,VStack as h}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as X}from"@contractspec/lib.ui-kit-web/ui/text";import*as C from"react";import{resolveTranslationString as W,useDesignSystemTranslation as K}from"../../i18n/translation";import{DataTable as R}from"../data-table/DataTable";import{DataViewFormattedValue as Y,getAtPath as g}from"./utils";export function DataViewTable({spec:q,items:J,className:L,onRowClick:G,toolbar:O,loading:Z,emptyState:$,headerActions:B,footer:H}){const Q=K();if(q.view.kind!=="table")throw Error(`DataViewTable received view kind "${q.view.kind}", expected "table".`);const M=q.view,P=C.useMemo(()=>(M.rowExpansion?.fields??[]).map((z)=>M.fields.find((I)=>I.key===z)).filter((z)=>Boolean(z)),[M.fields,M.rowExpansion?.fields]),N=A({spec:q,data:J,renderValue:({value:z,field:I})=>E(Y,{value:z,format:I.format}),renderExpandedContent:P.length>0?({item:z,fields:I})=>E(h,{gap:"sm",className:"py-2",children:I.map((U)=>V(F,{justify:"between",align:"start",children:[E(X,{className:"font-medium text-muted-foreground text-sm",children:W(U.label,Q)}),E(X,{className:"text-right text-sm",children:E(DisplayValue,{item:z,fields:I,fieldKey:U.key})})]},U.key))}):void 0});return E(R,{controller:N,className:L,title:W(q.meta.title,Q),description:W(q.meta.description,Q),toolbar:O,loading:Z,headerActions:B,emptyState:$,footer:H,onRowPress:G?(z)=>G(z.original):void 0})}function D(q,J){return q.find((L)=>L.key===J)}export function DisplayValue({item:q,fields:J,fieldKey:L}){const G=D(J,L);if(!G)return"";const O=g(q,G.dataPath);return E(Y,{value:O,format:G.format})}
1
+ import{jsx as E,jsxs as _}from"react/jsx-runtime";import{useDataViewTable as C}from"@contractspec/lib.presentation-runtime-react";import{HStack as K,VStack as R}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as Z}from"@contractspec/lib.ui-kit-web/ui/text";import*as $ from"react";import{resolveTranslationString as X,useDesignSystemTranslation as g}from"../../i18n/translation";import{DataTable as D}from"../data-table/DataTable";import{DataViewFormattedValue as B,getAtPath as V}from"./utils";export function DataViewTable({spec:q,items:J,className:L,onRowClick:G,toolbar:O,loading:H,emptyState:P,headerActions:N,footer:A,density:Q}){const U=g();if(q.view.kind!=="table")throw Error(`DataViewTable received view kind "${q.view.kind}", expected "table".`);const Y=$.useMemo(()=>Q&&q.view.kind==="table"?{...q,view:{...q.view,density:Q}}:q,[Q,q]),M=Y.view,F=$.useMemo(()=>(M.rowExpansion?.fields??[]).map((z)=>M.fields.find((I)=>I.key===z)).filter((z)=>Boolean(z)),[M.fields,M.rowExpansion?.fields]),h=C({spec:Y,data:J,renderValue:({value:z,field:I})=>E(B,{value:z,format:I.format}),renderExpandedContent:F.length>0?({item:z,fields:I})=>E(R,{gap:"sm",className:"py-2",children:I.map((W)=>_(K,{justify:"between",align:"start",children:[E(Z,{className:"font-medium text-muted-foreground text-sm",children:X(W.label,U)}),E(Z,{className:"text-right text-sm",children:E(DisplayValue,{item:z,fields:I,fieldKey:W.key})})]},W.key))}):void 0});return E(D,{controller:h,className:L,title:X(q.meta.title,U),description:X(q.meta.description,U),toolbar:O,loading:H,headerActions:N,emptyState:P,footer:A,onRowPress:G?(z)=>G(z.original):void 0})}function b(q,J){return q.find((L)=>L.key===J)}export function DisplayValue({item:q,fields:J,fieldKey:L}){const G=b(J,L);if(!G)return"";const O=V(q,G.dataPath);return E(B,{value:O,format:G.format})}
@@ -1,4 +1,4 @@
1
- import type { DataViewField, DataViewSpec } from '@contractspec/lib.contracts-spec/data-views';
1
+ import type { DataViewDensity, DataViewField, DataViewSpec } from '@contractspec/lib.contracts-spec/data-views';
2
2
  import * as React from 'react';
3
3
  export interface DataViewTableProps {
4
4
  spec: DataViewSpec;
@@ -10,8 +10,9 @@ export interface DataViewTableProps {
10
10
  emptyState?: React.ReactNode;
11
11
  headerActions?: React.ReactNode;
12
12
  footer?: React.ReactNode;
13
+ density?: DataViewDensity;
13
14
  }
14
- export declare function DataViewTable({ spec, items, className, onRowClick, toolbar, loading, emptyState, headerActions, footer, }: DataViewTableProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function DataViewTable({ spec, items, className, onRowClick, toolbar, loading, emptyState, headerActions, footer, density, }: DataViewTableProps): import("react/jsx-runtime").JSX.Element;
15
16
  export declare function DisplayValue({ item, fields, fieldKey, }: {
16
17
  item: Record<string, unknown>;
17
18
  fields: DataViewField[];
@@ -0,0 +1,16 @@
1
+ import type { DataViewCollectionConfig, DataViewCollectionMode, DataViewCollectionViewModesConfig, DataViewConfig, DataViewDensity, DataViewSpec } from '@contractspec/lib.contracts-spec/data-views';
2
+ export interface ResolvedCollectionView {
3
+ spec: DataViewSpec;
4
+ mode: DataViewCollectionMode;
5
+ allowedModes: DataViewCollectionMode[];
6
+ }
7
+ export interface ResolveCollectionDensityInput {
8
+ density?: DataViewDensity;
9
+ defaultDensity?: DataViewDensity;
10
+ }
11
+ export declare function isDataViewCollectionKind(kind: DataViewConfig['kind']): kind is DataViewCollectionMode;
12
+ export declare function resolveAllowedCollectionModes(view: DataViewConfig): DataViewCollectionMode[];
13
+ export declare function getDataViewCollectionConfig(view: DataViewConfig): DataViewCollectionConfig | undefined;
14
+ export declare function getDataViewCollectionViewModesConfig(view: DataViewConfig): DataViewCollectionViewModesConfig | undefined;
15
+ export declare function resolveCollectionView(spec: DataViewSpec, requestedMode?: DataViewCollectionMode): ResolvedCollectionView;
16
+ export declare function resolveCollectionDensity(spec: DataViewSpec, input?: ResolveCollectionDensityInput): DataViewDensity;
@@ -0,0 +1 @@
1
+ const F=["list","grid","table"];export function isDataViewCollectionKind(h){return h==="list"||h==="grid"||h==="table"}export function resolveAllowedCollectionModes(h){const x=getDataViewCollectionConfig(h);if(!x||!isDataViewCollectionKind(h.kind))return isDataViewCollectionKind(h.kind)?[h.kind]:[];const z=getDataViewCollectionViewModesConfig(h),B=z?.allowedModes?.filter(K);if(B?.length)return P(B);if(x.toolbar?.viewMode===!0)return F;return z?F:[h.kind]}export function getDataViewCollectionConfig(h){if(!isDataViewCollectionKind(h.kind))return;return h.collection}export function getDataViewCollectionViewModesConfig(h){const x=getDataViewCollectionConfig(h),z=x?.toolbar?.viewMode;if(x?.viewModes)return x.viewModes;return typeof z==="object"?z:void 0}export function resolveCollectionView(h,x){const z=resolveAllowedCollectionModes(h.view),B=H(h.view,z),G=x&&z.includes(x)?x:B;return{spec:{...h,view:J(h.view,G)},mode:G,allowedModes:z}}export function resolveCollectionDensity(h,x={}){const z=h.view.kind==="table"?h.view.density:void 0;return x.density??z??getDataViewCollectionConfig(h.view)?.density??x.defaultDensity??"comfortable"}function H(h,x){const z=isDataViewCollectionKind(h.kind)&&getDataViewCollectionViewModesConfig(h)?.defaultMode;if(z&&x.includes(z))return z;if(isDataViewCollectionKind(h.kind)&&x.includes(h.kind))return h.kind;return x[0]??"list"}function J(h,x){const z=getDataViewCollectionConfig(h),B={fields:h.fields,primaryField:h.primaryField,secondaryFields:h.secondaryFields,filters:h.filters,filterScope:h.filterScope,actions:h.actions,collection:z};if(x==="list")return{...B,kind:"list",layout:h.kind==="list"?h.layout:"compact"};if(x==="grid")return{...B,kind:"grid",columns:h.kind==="grid"?h.columns:void 0};if(h.kind==="table")return{...h,...B,kind:"table"};return{...B,kind:"table",density:z?.density}}function K(h){return h==="list"||h==="grid"||h==="table"}function P(h){return F.filter((x)=>h.includes(x))}
@@ -1 +1 @@
1
- import{jsx as m}from"react/jsx-runtime";import{MarkdownRenderer as a}from"../molecules/MarkdownRenderer";export function getAtPath(t,e){if(!t)return;if(!e)return t;const r=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=t;for(const o of r){if(n==null||typeof n!=="object"&&!Array.isArray(n))return;n=n[o]}return n}export function DataViewFormattedValue({value:t,format:e}){if(t==null)return"";switch(e){case"boolean":return t?"Yes":"No";case"currency":return typeof t==="number"?new Intl.NumberFormat(void 0,{style:"currency",currency:"USD"}).format(t):String(t);case"percentage":return typeof t==="number"?`${(t*100).toFixed(1)}%`:String(t);case"date":return i(t,{dateStyle:"medium"});case"dateTime":return i(t,{dateStyle:"medium",timeStyle:"short"});case"markdown":return m(a,{content:t});default:return String(t)}}function i(t,e){if(t instanceof Date)return new Intl.DateTimeFormat(void 0,e).format(t);if(typeof t==="string"||typeof t==="number"){const r=new Date(t);if(!Number.isNaN(r.getTime()))return new Intl.DateTimeFormat(void 0,e).format(r)}return String(t??"")}
1
+ import{jsx as l}from"react/jsx-runtime";import{MarkdownRenderer as u}from"../molecules/MarkdownRenderer";export function getAtPath(n,t){if(!n)return;if(!t)return n;const e=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let i=n;for(const r of e){if(i==null||typeof i!=="object"&&!Array.isArray(i))return;i=i[r]}return i}export function DataViewFormattedValue({value:n,format:t}){if(n==null)return"";switch(typeof t==="string"?t:t?.type){case"boolean":return n?"Yes":"No";case"number":return m(n,t);case"currency":return d(n,t);case"percent":case"percentage":return p(n,t);case"date":return o(n,typeof t==="object"&&t.type==="date"?t:{dateStyle:"medium"});case"time":return o(n,typeof t==="object"&&t.type==="time"?t:{timeStyle:"short"});case"datetime":case"dateTime":return o(n,typeof t==="object"&&t.type==="datetime"?t:{dateStyle:"medium",timeStyle:"short"});case"duration":return g(n,t);case"markdown":return l(u,{content:n});default:return String(n)}}function m(n,t){if(typeof n!=="number")return String(n);const e=typeof t==="object"&&t.type==="number"?t:void 0;return new Intl.NumberFormat(e?.locale,{minimumFractionDigits:e?.minimumFractionDigits,maximumFractionDigits:e?.maximumFractionDigits,useGrouping:e?.useGrouping,notation:e?.notation,signDisplay:e?.signDisplay}).format(n)}function d(n,t){if(typeof n!=="number")return String(n);const e=typeof t==="object"&&t.type==="currency"?t:void 0;return new Intl.NumberFormat(e?.locale,{style:"currency",currency:e?.currency??"USD",currencyDisplay:e?.currencyDisplay,minimumFractionDigits:e?.rounded?0:e?.minimumFractionDigits,maximumFractionDigits:e?.rounded?0:e?.maximumFractionDigits,useGrouping:e?.useGrouping,notation:e?.notation,signDisplay:e?.signDisplay}).format(n)}function p(n,t){if(typeof n!=="number")return String(n);const e=typeof t==="object"&&t.type==="percent"?t:void 0,i=e?.valueScale==="whole"?n/100:n;return new Intl.NumberFormat(e?.locale,{style:"percent",minimumFractionDigits:e?.minimumFractionDigits??1,maximumFractionDigits:e?.maximumFractionDigits??1,useGrouping:e?.useGrouping,notation:e?.notation,signDisplay:e?.signDisplay}).format(i)}function o(n,t){const{locale:e,...i}=t;if(n instanceof Date)return new Intl.DateTimeFormat(e,i).format(n);if(typeof n==="string"||typeof n==="number"){const r=new Date(n);if(!Number.isNaN(r.getTime()))return new Intl.DateTimeFormat(e,i).format(r)}return String(n??"")}function g(n,t){if(typeof n!=="number")return String(n);const e=typeof t==="object"&&t.type==="duration"?t:void 0,i=e?.unit??"second";if(e?.display==="digital")return y(f(n,i));return new Intl.NumberFormat(e?.locale,{style:"unit",unit:i,unitDisplay:e?.display==="narrow"?"narrow":e?.display,maximumFractionDigits:2}).format(n)}function y(n){const t=n<0?"-":"",e=Math.round(Math.abs(n)),i=Math.floor(e/3600),r=Math.floor(e%3600/60),c=e%60,s=[r,c].map((a)=>String(a).padStart(2,"0")).join(":");return i>0?`${t}${i}:${s}`:`${t}${s}`}function f(n,t){switch(t){case"millisecond":return n/1000;case"minute":return n*60;case"hour":return n*3600;case"day":return n*86400;case"week":return n*604800;case"month":return n*2629746;case"year":return n*31556952;case"second":default:return n}}
@@ -1 +1 @@
1
- import{jsx as H}from"react/jsx-runtime";import{Tabs as R,TabsContent as S,TabsList as U,TabsTrigger as X}from"@contractspec/lib.ui-kit-web/ui/tabs";import{useThemedPrimitive as G}from"../primitives/themed";export function Tabs({value:z,defaultValue:A,onValueChange:B,className:D,children:q,orientation:F,dir:E,activationMode:J,componentKey:O,themeVariant:Q}){console.log("tabs web");const I=G({defaultComponentKey:"Tabs",componentKey:O,themeVariant:Q,className:D});return H(R,{...I.props,value:z,defaultValue:A,onValueChange:B,className:I.className,orientation:F,dir:E,activationMode:J,children:q})}export function TabsList({className:z,children:A,componentKey:B,themeVariant:D}){const q=G({defaultComponentKey:"TabsList",componentKey:B,themeVariant:D,className:z});return H(U,{...q.props,className:q.className,children:A})}export function TabsTrigger({value:z,disabled:A,className:B,children:D,componentKey:q,themeVariant:F}){const E=G({defaultComponentKey:"TabsTrigger",componentKey:q,themeVariant:F,className:B});return H(X,{...E.props,value:z,disabled:A,className:E.className,children:D})}export function TabsContent({value:z,forceMount:A,className:B,children:D,componentKey:q,themeVariant:F}){const E=G({defaultComponentKey:"TabsContent",componentKey:q,themeVariant:F,className:B});return H(S,{...E.props,value:z,forceMount:A?!0:void 0,className:E.className,children:D})}
1
+ import{jsx as H}from"react/jsx-runtime";import{Tabs as R,TabsContent as S,TabsList as U,TabsTrigger as X}from"@contractspec/lib.ui-kit-web/ui/tabs";import{useThemedPrimitive as G}from"../primitives/themed";export function Tabs({value:z,defaultValue:A,onValueChange:B,className:D,children:q,orientation:F,dir:E,activationMode:J,componentKey:O,themeVariant:Q}){const I=G({defaultComponentKey:"Tabs",componentKey:O,themeVariant:Q,className:D});return H(R,{...I.props,value:z,defaultValue:A,onValueChange:B,className:I.className,orientation:F,dir:E,activationMode:J,children:q})}export function TabsList({className:z,children:A,componentKey:B,themeVariant:D}){const q=G({defaultComponentKey:"TabsList",componentKey:B,themeVariant:D,className:z});return H(U,{...q.props,className:q.className,children:A})}export function TabsTrigger({value:z,disabled:A,className:B,children:D,componentKey:q,themeVariant:F}){const E=G({defaultComponentKey:"TabsTrigger",componentKey:q,themeVariant:F,className:B});return H(X,{...E.props,value:z,disabled:A,className:E.className,children:D})}export function TabsContent({value:z,forceMount:A,className:B,children:D,componentKey:q,themeVariant:F}){const E=G({defaultComponentKey:"TabsContent",componentKey:q,themeVariant:F,className:B});return H(S,{...E.props,value:z,forceMount:A?!0:void 0,className:E.className,children:D})}
@@ -0,0 +1,18 @@
1
+ import type { ObjectReferenceActionDescriptor, ObjectReferenceHandlerProps, ObjectReferenceRenderContext } from './types';
2
+ export declare function DefaultObjectReferenceTrigger({ context, iconRenderer, interactivityVisibility, className, }: {
3
+ context: ObjectReferenceRenderContext;
4
+ iconRenderer?: IconRenderer;
5
+ interactivityVisibility: NonNullable<ObjectReferenceHandlerProps['interactivityVisibility']>;
6
+ className?: string;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export declare function DefaultReferenceDetail({ reference, }: {
9
+ reference: ObjectReferenceHandlerProps['reference'];
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ export declare function DefaultActionButton({ action, reference, iconRenderer, onClick, }: {
12
+ action: ObjectReferenceActionDescriptor;
13
+ reference: ObjectReferenceHandlerProps['reference'];
14
+ iconRenderer?: IconRenderer;
15
+ onClick: () => void;
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ type IconRenderer = ObjectReferenceHandlerProps['iconRenderer'];
18
+ export {};
@@ -0,0 +1 @@
1
+ import{jsx as r,jsxs as i}from"react/jsx-runtime";import{cn as c}from"../../lib/utils";import{getObjectReferenceDisplayValue as l}from"./actions";import{ReferenceIcon as a,ReferenceSearchIcon as m}from"./ReferenceIcon";export function DefaultObjectReferenceTrigger({context:e,iconRenderer:d,interactivityVisibility:t,className:n}){const{reference:o}=e;return i("span",{className:c("inline-flex min-w-0 items-center gap-1.5 text-foreground text-sm transition-colors hover:text-primary",t==="underline"&&"underline decoration-muted-foreground/50 underline-offset-4 hover:decoration-primary",n),children:[r(a,{context:{iconKey:o.iconKey??o.kind,reference:o},iconRenderer:d}),r("span",{className:"truncate",children:o.label}),t==="icon"?r(m,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null]})}export function DefaultReferenceDetail({reference:e}){const d=l(e),t=Object.entries(e.metadata??{});return i("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:[r("div",{className:"font-medium text-foreground",children:d}),e.href?r("div",{className:"mt-1 break-all text-muted-foreground",children:e.href}):null,t.length>0?r("dl",{className:"mt-3 grid gap-2",children:t.map(([n,o])=>i("div",{className:"grid gap-0.5",children:[r("dt",{className:"font-medium text-muted-foreground text-xs uppercase",children:n}),r("dd",{className:"break-words text-foreground",children:String(o)})]},n))}):null]})}export function DefaultActionButton({action:e,reference:d,iconRenderer:t,onClick:n}){return i("button",{type:"button",className:c("flex min-h-11 w-full items-center gap-3 rounded-md border border-border px-3 py-2 text-left text-sm transition-colors hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",e.variant==="primary"&&"border-primary/40 bg-primary/10",e.variant==="danger"&&"border-destructive/40 text-destructive",e.disabled&&"cursor-not-allowed opacity-50"),disabled:e.disabled,onClick:n,children:[r(a,{context:{iconKey:e.iconKey??e.id,reference:d,action:e},iconRenderer:t}),i("span",{className:"min-w-0 flex-1",children:[r("span",{className:"block font-medium",children:e.label}),e.description?r("span",{className:"block text-muted-foreground text-xs",children:e.description}):null]})]})}
@@ -0,0 +1,13 @@
1
+ import type { ObjectReferenceActionDescriptor, ObjectReferenceHandlerProps, ObjectReferenceRenderContext } from './types';
2
+ export declare function NativeObjectReferenceTrigger({ context, iconRenderer, interactivityVisibility, }: {
3
+ context: ObjectReferenceRenderContext;
4
+ iconRenderer?: ObjectReferenceHandlerProps['iconRenderer'];
5
+ interactivityVisibility: NonNullable<ObjectReferenceHandlerProps['interactivityVisibility']>;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export declare function NativeReferenceDetail({ reference, }: {
8
+ reference: ObjectReferenceHandlerProps['reference'];
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export declare function NativeActionButton({ action, onPress, }: {
11
+ action: ObjectReferenceActionDescriptor;
12
+ onPress: () => void;
13
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { ObjectReferenceHandlerProps } from './types';
2
+ export declare function ObjectReferenceHandler({ reference, actions, interactivityVisibility, defaultOpen, open, onOpenChange, actionHandlers, onAction, onActionError, copyText, copyHandler, openHref, renderTrigger, renderDetail, renderAction, iconRenderer, className, panelClassName, }: ObjectReferenceHandlerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as z,jsxs as G}from"react/jsx-runtime";import{Sheet as b,SheetContent as D,SheetDescription as w,SheetHeader as O,SheetTitle as A}from"@contractspec/lib.ui-kit-web/ui/sheet";import{Tooltip as R,TooltipContent as T,TooltipTrigger as h}from"@contractspec/lib.ui-kit-web/ui/tooltip";import*as u from"react";import{cn as _}from"../../lib/utils";import{DefaultActionButton as g,DefaultObjectReferenceTrigger as y,DefaultReferenceDetail as d}from"./DefaultObjectReferenceParts";import{useObjectReferenceController as j}from"./useObjectReferenceController";export function ObjectReferenceHandler({reference:q,actions:J,interactivityVisibility:X="underline",defaultOpen:Y=!1,open:Z,onOpenChange:$,actionHandlers:k,onAction:B,onActionError:P,copyText:E,copyHandler:V,openHref:v,renderTrigger:K,renderDetail:L,renderAction:M,iconRenderer:Q,className:N,panelClassName:m}){const{context:I,resolvedActions:S,resolvedOpen:C,runAction:U,setOpen:W}=j({reference:q,actions:J,defaultOpen:Y,open:Z,onOpenChange:$,actionHandlers:k,copyText:E,copyHandler:V,openHref:v,onAction:B,onActionError:P,defaultCopy:p,defaultOpenHref:x}),H=K?K(I):z(y,{context:I,iconRenderer:Q,interactivityVisibility:X,className:N});return G(b,{open:C,onOpenChange:W,children:[G(R,{children:[z(h,{asChild:!0,children:z("button",{type:"button",className:"contents","aria-label":q.ariaLabel??`Open ${q.label}`,onClick:()=>W(!0),children:H})}),z(T,{children:q.ariaLabel??q.label})]}),G(D,{className:_("sm:max-w-md",m),children:[G(O,{children:[z(A,{children:q.label}),q.description?z(w,{children:q.description}):null]}),G("div",{className:"flex flex-col gap-4 px-4 pb-4",children:[L?L(I):z(d,{reference:q}),z("div",{className:"flex flex-col gap-2",children:S.map((F)=>M?z(u.Fragment,{children:M({...I,action:F,runAction:U})},F.id):z(g,{action:F,reference:q,iconRenderer:Q,onClick:()=>U(F)},F.id))})]})]})]})}async function p(q,J){if(typeof navigator<"u"&&navigator.clipboard){await navigator.clipboard.writeText(q);return}throw Error("Clipboard is not available.")}async function x(q,J){if(typeof window<"u")window.open(q,"_blank","noopener,noreferrer")}
@@ -0,0 +1,2 @@
1
+ import type { ObjectReferenceHandlerProps } from './types';
2
+ export declare function ObjectReferenceHandler({ reference, actions, interactivityVisibility, defaultOpen, open, onOpenChange, actionHandlers, onAction, onActionError, copyText, copyHandler, openHref, renderTrigger, renderDetail, renderAction, iconRenderer, className, panelClassName, }: ObjectReferenceHandlerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Search } from 'lucide-react';
2
+ import type { ObjectReferenceHandlerProps, ObjectReferenceIconRenderContext } from './types';
3
+ export declare function ReferenceIcon({ context, iconRenderer, }: {
4
+ context: ObjectReferenceIconRenderContext;
5
+ iconRenderer?: ObjectReferenceHandlerProps['iconRenderer'];
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export { Search as ReferenceSearchIcon };
@@ -0,0 +1 @@
1
+ import{jsx as p,Fragment as f}from"react/jsx-runtime";import{Copy as a,ExternalLink as r,FileText as s,MapPin as o,Phone as t,Search,User as c}from"lucide-react";const R={address:o,phone:t,user:c,customer:c,file:s,url:r,custom:Search,copy:a,map:o,phoneAction:t,"external-link":r};export function ReferenceIcon({context:e,iconRenderer:n}){if(n)return p(f,{children:n(e)});const i=R[e.iconKey]??Search;return p(i,{className:"h-4 w-4 shrink-0 text-muted-foreground"})}export{Search as ReferenceSearchIcon};
@@ -0,0 +1,7 @@
1
+ import type { ObjectReferenceActionDescriptor, ObjectReferenceDescriptor } from './types';
2
+ export { createMapsProviderHref, createMapsReferenceActions, type ObjectReferenceMapsActionOptions, type ObjectReferenceMapsProvider, } from './maps';
3
+ export declare function getObjectReferenceDisplayValue(reference: ObjectReferenceDescriptor): string;
4
+ export declare function createCopyReferenceAction(reference: ObjectReferenceDescriptor, label?: string): ObjectReferenceActionDescriptor;
5
+ export declare function createOpenReferenceAction(reference: ObjectReferenceDescriptor, label?: string): ObjectReferenceActionDescriptor | null;
6
+ export declare function createPhoneReferenceAction(reference: ObjectReferenceDescriptor, label?: string): ObjectReferenceActionDescriptor | null;
7
+ export declare function createDefaultObjectReferenceActions(reference: ObjectReferenceDescriptor): ObjectReferenceActionDescriptor[];
@@ -0,0 +1 @@
1
+ export{createMapsProviderHref,createMapsReferenceActions}from"./maps";import{createMapsReferenceActions as c}from"./maps";function n(e){return e.trim().replace(/\s+/g," ")}export function getObjectReferenceDisplayValue(e){return e.value??e.href??e.label}export function createCopyReferenceAction(e,t="Copy"){return{id:"copy",label:t,description:"Copy this reference",iconKey:"copy",metadata:{copyText:getObjectReferenceDisplayValue(e)}}}export function createOpenReferenceAction(e,t="Open details"){if(!e.href)return null;return{id:"open",label:t,description:"Open the related page or resource",href:e.href,iconKey:"external-link"}}export function createPhoneReferenceAction(e,t="Call"){if(e.kind!=="phone")return null;const r=n(e.value??e.label);if(!r)return null;return{id:"call",label:t,description:"Call this phone number",href:`tel:${r.replace(/[^\d+]/g,"")}`,iconKey:"phone"}}export function createDefaultObjectReferenceActions(e){return[createCopyReferenceAction(e),createOpenReferenceAction(e),createPhoneReferenceAction(e),...c(e)].filter((t)=>Boolean(t))}
@@ -0,0 +1,4 @@
1
+ export { createCopyReferenceAction, createDefaultObjectReferenceActions, createMapsProviderHref, createMapsReferenceActions, createOpenReferenceAction, createPhoneReferenceAction, getObjectReferenceDisplayValue, type ObjectReferenceMapsActionOptions, type ObjectReferenceMapsProvider, } from './actions';
2
+ export { ObjectReferenceHandler } from './ObjectReferenceHandler';
3
+ export { type ExecuteObjectReferenceActionOptions, executeObjectReferenceAction, } from './runtime';
4
+ export type { JsonPrimitive, JsonValue, ObjectReferenceActionDescriptor, ObjectReferenceActionEvent, ObjectReferenceActionHandler, ObjectReferenceActionRenderContext, ObjectReferenceActionVariant, ObjectReferenceCopyHandler, ObjectReferenceDescriptor, ObjectReferenceHandlerProps, ObjectReferenceIconRenderContext, ObjectReferenceInteractivityVisibility, ObjectReferenceKind, ObjectReferenceMetadata, ObjectReferenceOpenHrefHandler, ObjectReferenceRenderContext, } from './types';
@@ -0,0 +1 @@
1
+ export{createCopyReferenceAction,createDefaultObjectReferenceActions,createMapsProviderHref,createMapsReferenceActions,createOpenReferenceAction,createPhoneReferenceAction,getObjectReferenceDisplayValue}from"./actions";export{ObjectReferenceHandler}from"./ObjectReferenceHandler";export{executeObjectReferenceAction}from"./runtime";
@@ -0,0 +1,4 @@
1
+ export { createCopyReferenceAction, createDefaultObjectReferenceActions, createMapsProviderHref, createMapsReferenceActions, createOpenReferenceAction, createPhoneReferenceAction, getObjectReferenceDisplayValue, type ObjectReferenceMapsActionOptions, type ObjectReferenceMapsProvider, } from './actions';
2
+ export { ObjectReferenceHandler } from './ObjectReferenceHandler';
3
+ export { type ExecuteObjectReferenceActionOptions, executeObjectReferenceAction, } from './runtime';
4
+ export type { JsonPrimitive, JsonValue, ObjectReferenceActionDescriptor, ObjectReferenceActionEvent, ObjectReferenceActionHandler, ObjectReferenceActionRenderContext, ObjectReferenceActionVariant, ObjectReferenceCopyHandler, ObjectReferenceDescriptor, ObjectReferenceHandlerProps, ObjectReferenceIconRenderContext, ObjectReferenceInteractivityVisibility, ObjectReferenceKind, ObjectReferenceMetadata, ObjectReferenceOpenHrefHandler, ObjectReferenceRenderContext, } from './types';
@@ -0,0 +1,8 @@
1
+ import type { ObjectReferenceActionDescriptor, ObjectReferenceDescriptor } from './types';
2
+ export type ObjectReferenceMapsProvider = 'apple' | 'google' | 'waze' | 'geo';
3
+ export interface ObjectReferenceMapsActionOptions {
4
+ providers?: ObjectReferenceMapsProvider[];
5
+ labelPrefix?: string;
6
+ }
7
+ export declare function createMapsProviderHref(provider: ObjectReferenceMapsProvider, query: string): string;
8
+ export declare function createMapsReferenceActions(reference: ObjectReferenceDescriptor, options?: ObjectReferenceMapsActionOptions): ObjectReferenceActionDescriptor[];
@@ -0,0 +1 @@
1
+ export function createMapsProviderHref(e,t){const r=encodeURIComponent(a(t));switch(e){case"apple":return`https://maps.apple.com/?q=${r}`;case"google":return`https://www.google.com/maps/search/?api=1&query=${r}`;case"waze":return`https://waze.com/ul?q=${r}&navigate=yes`;case"geo":return`geo:0,0?q=${r}`}}export function createMapsReferenceActions(e,t={}){if(e.kind!=="address")return[];const r=e.value??e.label;if(!a(r))return[];const n=t.providers??["google","apple","waze"],o=t.labelPrefix??"Open in";return n.map((c)=>({id:`maps.${c}`,label:`${o} ${s(c)}`,description:"Open navigation for this address",href:createMapsProviderHref(c,r),iconKey:"map",metadata:{provider:c}}))}function a(e){return e.trim().replace(/\s+/g," ")}function s(e){switch(e){case"apple":return"Apple Maps";case"google":return"Google Maps";case"waze":return"Waze";case"geo":return"Maps"}}
@@ -0,0 +1,12 @@
1
+ import type { ObjectReferenceActionEvent, ObjectReferenceHandlerProps } from './types';
2
+ export interface ExecuteObjectReferenceActionOptions {
3
+ actionHandlers?: ObjectReferenceHandlerProps['actionHandlers'];
4
+ copyText?: string;
5
+ copyHandler?: ObjectReferenceHandlerProps['copyHandler'];
6
+ openHref?: ObjectReferenceHandlerProps['openHref'];
7
+ onAction?: ObjectReferenceHandlerProps['onAction'];
8
+ onActionError?: ObjectReferenceHandlerProps['onActionError'];
9
+ defaultCopy?: ObjectReferenceHandlerProps['copyHandler'];
10
+ defaultOpenHref?: ObjectReferenceHandlerProps['openHref'];
11
+ }
12
+ export declare function executeObjectReferenceAction(event: ObjectReferenceActionEvent, options: ExecuteObjectReferenceActionOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ import{getObjectReferenceDisplayValue as c}from"./actions";export async function executeObjectReferenceAction(e,r){try{const n=r.actionHandlers?.[e.action.id];if(n)await n(e);else if(e.action.id==="copy")await t(e,r);else if(e.action.href)await o(e.action.href,e,r);await r.onAction?.(e)}catch(n){r.onActionError?.(n,e)}}function t(e,r){const n=r.copyText??i(e.action.metadata?.copyText)??c(e.reference);if(r.copyHandler)return r.copyHandler(n,e);if(r.defaultCopy)return r.defaultCopy(n,e);throw Error("Clipboard is not available.")}function o(e,r,n){if(n.openHref)return n.openHref(e,r);return n.defaultOpenHref?.(e,r)}function i(e){return typeof e==="string"?e:void 0}
@@ -0,0 +1,73 @@
1
+ import type * as React from 'react';
2
+ export type ObjectReferenceKind = 'address' | 'phone' | 'user' | 'customer' | 'file' | 'url' | 'custom';
3
+ export type ObjectReferenceInteractivityVisibility = 'none' | 'underline' | 'icon';
4
+ export type ObjectReferenceActionVariant = 'default' | 'primary' | 'secondary' | 'danger';
5
+ export type JsonPrimitive = string | number | boolean | null;
6
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
7
+ readonly [key: string]: JsonValue;
8
+ };
9
+ export type ObjectReferenceMetadata = Record<string, JsonValue>;
10
+ export interface ObjectReferenceDescriptor {
11
+ id: string;
12
+ kind: ObjectReferenceKind;
13
+ label: string;
14
+ description?: string;
15
+ value?: string;
16
+ href?: string;
17
+ metadata?: ObjectReferenceMetadata;
18
+ iconKey?: string;
19
+ ariaLabel?: string;
20
+ }
21
+ export interface ObjectReferenceActionDescriptor {
22
+ id: string;
23
+ label: string;
24
+ description?: string;
25
+ href?: string;
26
+ disabled?: boolean;
27
+ variant?: ObjectReferenceActionVariant;
28
+ iconKey?: string;
29
+ metadata?: ObjectReferenceMetadata;
30
+ }
31
+ export interface ObjectReferenceActionEvent {
32
+ reference: ObjectReferenceDescriptor;
33
+ action: ObjectReferenceActionDescriptor;
34
+ source: 'action';
35
+ }
36
+ export type ObjectReferenceActionHandler = (event: ObjectReferenceActionEvent) => void | Promise<void>;
37
+ export type ObjectReferenceCopyHandler = (text: string, event: ObjectReferenceActionEvent) => void | Promise<void>;
38
+ export type ObjectReferenceOpenHrefHandler = (href: string, event: ObjectReferenceActionEvent) => void | Promise<void>;
39
+ export interface ObjectReferenceRenderContext {
40
+ reference: ObjectReferenceDescriptor;
41
+ actions: ObjectReferenceActionDescriptor[];
42
+ open: boolean;
43
+ setOpen: (open: boolean) => void;
44
+ }
45
+ export interface ObjectReferenceActionRenderContext extends ObjectReferenceRenderContext {
46
+ action: ObjectReferenceActionDescriptor;
47
+ runAction: (action: ObjectReferenceActionDescriptor) => void;
48
+ }
49
+ export interface ObjectReferenceIconRenderContext {
50
+ iconKey: string;
51
+ reference: ObjectReferenceDescriptor;
52
+ action?: ObjectReferenceActionDescriptor;
53
+ }
54
+ export interface ObjectReferenceHandlerProps {
55
+ reference: ObjectReferenceDescriptor;
56
+ actions?: ObjectReferenceActionDescriptor[];
57
+ interactivityVisibility?: ObjectReferenceInteractivityVisibility;
58
+ defaultOpen?: boolean;
59
+ open?: boolean;
60
+ onOpenChange?: (open: boolean) => void;
61
+ actionHandlers?: Record<string, ObjectReferenceActionHandler>;
62
+ onAction?: ObjectReferenceActionHandler;
63
+ onActionError?: (error: unknown, event: ObjectReferenceActionEvent) => void;
64
+ copyText?: string;
65
+ copyHandler?: ObjectReferenceCopyHandler;
66
+ openHref?: ObjectReferenceOpenHrefHandler;
67
+ renderTrigger?: (context: ObjectReferenceRenderContext) => React.ReactNode;
68
+ renderDetail?: (context: ObjectReferenceRenderContext) => React.ReactNode;
69
+ renderAction?: (context: ObjectReferenceActionRenderContext) => React.ReactNode;
70
+ iconRenderer?: (context: ObjectReferenceIconRenderContext) => React.ReactNode;
71
+ className?: string;
72
+ panelClassName?: string;
73
+ }
File without changes
@@ -0,0 +1,13 @@
1
+ import type { ObjectReferenceActionDescriptor, ObjectReferenceHandlerProps, ObjectReferenceRenderContext } from './types';
2
+ interface ControllerOptions extends ObjectReferenceHandlerProps {
3
+ defaultCopy?: ObjectReferenceHandlerProps['copyHandler'];
4
+ defaultOpenHref?: ObjectReferenceHandlerProps['openHref'];
5
+ }
6
+ export declare function useObjectReferenceController({ reference, actions, defaultOpen, open, onOpenChange, actionHandlers, onAction, onActionError, copyText, copyHandler, openHref, defaultCopy, defaultOpenHref, }: ControllerOptions): {
7
+ context: ObjectReferenceRenderContext;
8
+ resolvedActions: ObjectReferenceActionDescriptor[];
9
+ resolvedOpen: boolean;
10
+ runAction: (action: ObjectReferenceActionDescriptor) => void;
11
+ setOpen: (nextOpen: boolean) => void;
12
+ };
13
+ export {};
@@ -0,0 +1 @@
1
+ import*as q from"react";import{createDefaultObjectReferenceActions as $}from"./actions";import{executeObjectReferenceAction as D}from"./runtime";export function useObjectReferenceController({reference:k,actions:F,defaultOpen:W=!1,open:G,onOpenChange:I,actionHandlers:J,onAction:K,onActionError:L,copyText:M,copyHandler:N,openHref:P,defaultCopy:Q,defaultOpenHref:S}){const[X,Y]=q.useState(W),V=G!==void 0,w=G??X,z=q.useMemo(()=>F??$(k),[F,k]),B=q.useCallback((m)=>{if(!V)Y(m);I?.(m)},[V,I]),Z=q.useMemo(()=>({reference:k,actions:z,open:w,setOpen:B}),[k,z,w,B]),_=q.useCallback((m)=>{if(m.disabled)return;D({reference:k,action:m,source:"action"},{actionHandlers:J,copyText:M,copyHandler:N,openHref:P,onAction:K,onActionError:L,defaultCopy:Q,defaultOpenHref:S})},[J,N,M,Q,S,K,L,P,k]);return{context:Z,resolvedActions:z,resolvedOpen:w,runAction:_,setOpen:B}}
@@ -0,0 +1,2 @@
1
+ import type { AppShellProps } from './AppShell.types';
2
+ export declare function AppShell({ brand, logo, title, homeHref, navigation, commands, breadcrumbs, pageOutline, activeHref, activeOutlineId, userMenu, topbarStart, topbarEnd, children, className, contentClassName, onNavigate: _onNavigate, }: AppShellProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as k,jsxs as F}from"react/jsx-runtime";import{Dialog as R,DialogContent as P,DialogHeader as B,DialogTitle as T}from"@contractspec/lib.ui-kit-web/ui/dialog";import{cn as Q}from"@contractspec/lib.ui-kit-web/ui/utils";import{MenuIcon as w,PanelRightIcon as y}from"lucide-react";import*as D from"react";import{Button as I}from"../atoms/Button";import{NavBrand as g}from"../atoms/NavBrand";import{Breadcrumbs as u}from"../molecules/Breadcrumbs";import{CommandSearchTrigger as _}from"../molecules/CommandSearchTrigger";import{PageOutline as N}from"./PageOutline";import{ShellSidebar as x}from"./ShellSidebar";function d({sections:q,activeHref:G}){return k("nav",{className:"flex flex-col gap-5","aria-label":"Application navigation",children:q.map((A,J)=>F("div",{className:"flex flex-col gap-2",children:[A.title&&k("div",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:A.title}),k("div",{className:"flex flex-col gap-1",children:A.items.map((z)=>k(C,{item:z,activeHref:G},z.key??z.href??String(z.label)))})]},A.key??J))})}function C({item:q,activeHref:G,depth:A=0}){const J=q.active||Boolean(q.href)&&Boolean(G)&&(q.match==="startsWith"?G?.startsWith(q.href??""):G===q.href),z=F("span",{className:Q("inline-flex min-w-0 items-center gap-2",A>0&&"pl-4"),children:[q.icon,k("span",{className:"truncate",children:q.label}),q.badge?k("span",{className:"ml-auto text-muted-foreground text-xs",children:q.badge}):null]});return F("div",{className:"flex flex-col gap-1",children:[q.href?k("a",{href:q.href,target:q.target,"aria-current":J?"page":void 0,"aria-label":q.ariaLabel,onClick:()=>q.onSelect?.(),className:Q("rounded-xs px-2 py-2 text-sm hover:bg-accent hover:text-accent-foreground",J&&"bg-accent font-medium text-accent-foreground"),children:z}):k("button",{type:"button","aria-label":q.ariaLabel,onClick:()=>q.onSelect?.(),className:Q("rounded-xs px-2 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground",J&&"bg-accent font-medium text-accent-foreground"),children:z}),q.children?.length?k("div",{className:"flex flex-col gap-1",children:q.children.map((K)=>k(C,{item:K,activeHref:G,depth:A+1},K.key??K.href??String(K.label)))}):null]})}export function AppShell({brand:q,logo:G,title:A,homeHref:J,navigation:z=[],commands:K=[],breadcrumbs:Y=[],pageOutline:U=[],activeHref:Z,activeOutlineId:$,userMenu:V,topbarStart:M,topbarEnd:S,children:b,className:H,contentClassName:p,onNavigate:f}){const[O,E]=D.useState(!1),[v,W]=D.useState(!1),L=q??k(g,{href:J,logo:G,title:A}),X=(h=!1)=>K.length?k(_,{groups:K,placeholder:"Search or run action...",compact:h}):null;return F("div",{className:Q("min-h-svh bg-background",H),children:[k("header",{className:"sticky top-0 z-30 border-b bg-background/95 backdrop-blur-xs supports-backdrop-filter:bg-background/60",children:F("div",{className:"flex h-14 items-center gap-3 px-3 md:px-4",children:[k(I,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":"Open navigation",onPress:()=>E(!0),children:k(w,{className:"h-4 w-4"})}),k("div",{className:"min-w-0 md:hidden",children:L}),k("div",{className:"hidden min-w-0 md:block",children:M}),k("div",{className:"min-w-0 flex-1",children:Y.length?k(u,{items:Y}):null}),k("div",{className:"hidden shrink-0 md:block",children:X()}),U.length?k(I,{variant:"ghost",size:"icon",className:"lg:hidden","aria-label":"Open page outline",onPress:()=>W(!0),children:k(y,{className:"h-4 w-4"})}):null,S,V]})}),F("div",{className:"grid min-h-[calc(100svh-3.5rem)] grid-cols-1 md:grid-cols-[280px_minmax(0,1fr)] lg:grid-cols-[280px_minmax(0,1fr)_240px]",children:[k("aside",{className:"hidden border-r md:block",children:k(x,{sections:z,brand:L,commandTrigger:X(),footer:V,activeHref:Z})}),k("main",{className:Q("min-w-0 px-4 py-5 md:px-6",p),children:b}),U.length?k("aside",{className:"hidden px-4 py-5 lg:block",children:k(N,{items:U,activeId:$})}):null]}),k(R,{open:O,onOpenChange:E,children:F(P,{className:"max-h-[85svh] overflow-auto sm:max-w-sm",children:[k(B,{children:k(T,{children:"Menu"})}),F("div",{className:"flex flex-col gap-4",children:[X(),k(d,{sections:z,activeHref:Z}),V]})]})}),k(R,{open:v,onOpenChange:W,children:F(P,{className:"max-h-[85svh] overflow-auto sm:max-w-sm",children:[k(B,{children:k(T,{children:"On this page"})}),k(N,{items:U,activeId:$,variant:"compact",onNavigate:()=>W(!1)})]})})]})}
@@ -0,0 +1,2 @@
1
+ import type { AppShellProps } from './AppShell.types';
2
+ export declare function AppShell({ brand, logo, title, navigation, commands, breadcrumbs, pageOutline, activeHref, activeOutlineId, userMenu, topbarEnd, children, className, homeHref: _homeHref, topbarStart: _topbarStart, contentClassName, onNavigate, }: AppShellProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type * as React from 'react';
2
+ import type { PageOutlineItem, ShellBreadcrumbItem, ShellCommandGroup, ShellNavItem, ShellNavSection } from './types';
3
+ export interface AppShellProps {
4
+ brand?: React.ReactNode;
5
+ logo?: React.ReactNode;
6
+ title?: React.ReactNode;
7
+ homeHref?: string;
8
+ navigation?: ShellNavSection[];
9
+ commands?: ShellCommandGroup[];
10
+ breadcrumbs?: ShellBreadcrumbItem[];
11
+ pageOutline?: PageOutlineItem[];
12
+ activeHref?: string;
13
+ activeOutlineId?: string;
14
+ userMenu?: React.ReactNode;
15
+ topbarStart?: React.ReactNode;
16
+ topbarEnd?: React.ReactNode;
17
+ children: React.ReactNode;
18
+ className?: string;
19
+ contentClassName?: string;
20
+ onNavigate?: (item: ShellNavItem) => void;
21
+ }
File without changes
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { PageOutlineItem, PageOutlineLevel } from './types';
3
+ export interface PageOutlineProps extends React.HTMLAttributes<HTMLElement> {
4
+ items: PageOutlineItem[];
5
+ activeId?: string;
6
+ onNavigate?: (item: PageOutlineItem) => void;
7
+ ariaLabel?: string;
8
+ variant?: 'rail' | 'compact';
9
+ maxLevel?: PageOutlineLevel;
10
+ }
11
+ export declare function PageOutline({ items, activeId, onNavigate, ariaLabel, variant, maxLevel, className, ...props }: PageOutlineProps): import("react/jsx-runtime").JSX.Element | null;
12
+ export declare function usePageOutlineActiveItem(ids: string[], options?: IntersectionObserverInit): string | undefined;
@@ -0,0 +1 @@
1
+ import{jsx as H}from"react/jsx-runtime";import{cn as S}from"@contractspec/lib.ui-kit-web/ui/utils";import*as M from"react";import{resolvePageOutlineItems as U}from"./outline";export function PageOutline({items:z,activeId:E,onNavigate:J,ariaLabel:K="On this page",variant:F="rail",maxLevel:C=3,className:B,...D}){const G=M.useMemo(()=>U(z,C),[z,C]);if(!G.length)return null;return H("nav",{"aria-label":K,className:S("text-muted-foreground text-sm",F==="rail"?"sticky top-20 max-h-[calc(100svh-6rem)] overflow-auto border-l pl-4":"rounded-md border p-3",B),...D,children:H("ol",{className:"m-0 list-none space-y-1 p-0",children:G.map((q)=>{const Q=E===q.id,T=q.href??`#${q.id}`;return H("li",{children:H("a",{href:T,"aria-current":Q?"location":void 0,onClick:()=>J?.(q),className:S("block rounded-xs px-2 py-1 transition-colors hover:bg-accent hover:text-accent-foreground",q.resolvedLevel===2&&"pl-5",q.resolvedLevel===3&&"pl-8 text-xs",Q&&"bg-accent font-medium text-accent-foreground"),children:q.label})},`${q.id}-${q.resolvedLevel}`)})})})}export function usePageOutlineActiveItem(z,E){const[J,K]=M.useState(z[0]);M.useEffect(()=>{if(!z.length||typeof IntersectionObserver>"u")return;const F=new IntersectionObserver((C)=>{const B=C.filter((D)=>D.isIntersecting).sort((D,G)=>G.intersectionRatio-D.intersectionRatio)[0];if(B?.target.id)K(B.target.id)},E??{rootMargin:"-20% 0px -65% 0px",threshold:[0,0.25,0.5,1]});for(const C of z){const B=document.getElementById(C);if(B)F.observe(B)}return()=>F.disconnect()},[z,E]);return J}
@@ -0,0 +1,11 @@
1
+ import type { PageOutlineItem, PageOutlineLevel } from './types';
2
+ export interface PageOutlineProps {
3
+ items: PageOutlineItem[];
4
+ activeId?: string;
5
+ onNavigate?: (item: PageOutlineItem) => void;
6
+ ariaLabel?: string;
7
+ maxLevel?: PageOutlineLevel;
8
+ className?: string;
9
+ }
10
+ export declare function PageOutline({ items, activeId, onNavigate, ariaLabel, maxLevel, className, }: PageOutlineProps): import("react/jsx-runtime").JSX.Element | null;
11
+ export declare function usePageOutlineActiveItem(ids: string[]): string | undefined;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import type { ShellNavSection } from './types';
3
+ export interface ShellSidebarProps {
4
+ sections: ShellNavSection[];
5
+ brand?: React.ReactNode;
6
+ commandTrigger?: React.ReactNode;
7
+ footer?: React.ReactNode;
8
+ activeHref?: string;
9
+ className?: string;
10
+ }
11
+ export declare function ShellSidebar({ sections, brand, commandTrigger, footer, activeHref, className, }: ShellSidebarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as z,jsxs as O}from"react/jsx-runtime";import{Sidebar as A,SidebarContent as F,SidebarFooter as L,SidebarGroup as P,SidebarGroupContent as R,SidebarGroupLabel as B,SidebarHeader as K,SidebarMenu as X,SidebarMenuBadge as N,SidebarMenuButton as C,SidebarMenuItem as G,SidebarProvider as I,SidebarRail as T}from"@contractspec/lib.ui-kit-web/ui/sidebar";import{cn as Y}from"@contractspec/lib.ui-kit-web/ui/utils";function M(q,D){if(q.active)return!0;if(!D||!q.href)return!1;return q.match==="startsWith"?D.startsWith(q.href):D===q.href}function Z(q){return q.key??q.href??String(q.label)}function $({item:q,activeHref:D,depth:J=0}){const Q=M(q,D),V=Boolean(q.children?.length),U=O("span",{className:Y("inline-flex min-w-0 items-center gap-2",J>0&&"pl-4"),children:[q.icon,z("span",{className:"truncate",children:q.label})]});return O(G,{children:[z(C,{asChild:!!q.href,isActive:Q,"aria-label":q.href?void 0:q.ariaLabel,onClick:q.href?void 0:()=>q.onSelect?.(),children:q.href?z("a",{href:q.href,target:q.target,"aria-label":q.ariaLabel,onClick:()=>q.onSelect?.(),children:U}):U}),q.badge!=null&&z(N,{children:q.badge}),V&&z(X,{className:"mt-1",children:q.children?.map((E)=>z($,{item:E,activeHref:D,depth:J+1},Z(E)))})]})}export function ShellSidebar({sections:q,brand:D,commandTrigger:J,footer:Q,activeHref:V,className:U}){return z(I,{children:O(A,{className:U,children:[z(T,{}),O(K,{className:Y("gap-3",!D&&!J&&"hidden"),children:[D,J]}),z(F,{children:q.map((E,k)=>O(P,{children:[E.title&&z(B,{children:E.title}),z(R,{children:z(X,{children:E.items.map((W)=>z($,{item:W,activeHref:V},Z(W)))})})]},E.key??k))}),Q&&z(L,{children:Q})]})})}
@@ -0,0 +1,5 @@
1
+ export { AppShell } from './AppShell';
2
+ export type { AppShellProps } from './AppShell.types';
3
+ export { PageOutline, type PageOutlineProps, usePageOutlineActiveItem, } from './PageOutline';
4
+ export { ShellSidebar, type ShellSidebarProps } from './ShellSidebar';
5
+ export type { AppShellConfig, PageOutlineItem, PageOutlineLevel, ShellBreadcrumbItem, ShellCommandGroup, ShellCommandItem, ShellNavItem, ShellNavMatch, ShellNavSection, ShellUserMenu, ShellUserMenuItem, } from './types';
@@ -0,0 +1 @@
1
+ export{AppShell}from"./AppShell";export{PageOutline,usePageOutlineActiveItem}from"./PageOutline";export{ShellSidebar}from"./ShellSidebar";
@@ -0,0 +1,4 @@
1
+ export { AppShell } from './AppShell.native';
2
+ export type { AppShellProps } from './AppShell.types';
3
+ export { PageOutline, type PageOutlineProps, usePageOutlineActiveItem, } from './PageOutline.native';
4
+ export type { AppShellConfig, PageOutlineItem, PageOutlineLevel, ShellBreadcrumbItem, ShellCommandGroup, ShellCommandItem, ShellNavItem, ShellNavMatch, ShellNavSection, ShellUserMenu, ShellUserMenuItem, } from './types';
@@ -0,0 +1,5 @@
1
+ import type { PageOutlineItem, PageOutlineLevel } from './types';
2
+ export type ResolvedPageOutlineItem = PageOutlineItem & {
3
+ resolvedLevel: PageOutlineLevel;
4
+ };
5
+ export declare function resolvePageOutlineItems(items: PageOutlineItem[], maxLevel: PageOutlineLevel, parentLevel?: number): ResolvedPageOutlineItem[];
@@ -0,0 +1 @@
1
+ export function resolvePageOutlineItems(n,t,r=1){return n.flatMap((e)=>{const l=Math.min(e.level??r,t),a={...e,resolvedLevel:l},i=e.children?.length?resolvePageOutlineItems(e.children,t,Math.min(l+1,t)):[];return[a,...i]})}
@@ -0,0 +1,66 @@
1
+ import type * as React from 'react';
2
+ export type ShellNavMatch = 'exact' | 'startsWith';
3
+ export interface ShellNavItem {
4
+ key?: string;
5
+ label: React.ReactNode;
6
+ href?: string;
7
+ icon?: React.ReactNode;
8
+ badge?: React.ReactNode;
9
+ description?: React.ReactNode;
10
+ children?: ShellNavItem[];
11
+ active?: boolean;
12
+ match?: ShellNavMatch;
13
+ priority?: number;
14
+ target?: '_self' | '_blank';
15
+ ariaLabel?: string;
16
+ onSelect?: () => void;
17
+ commandId?: string;
18
+ }
19
+ export interface ShellNavSection {
20
+ key?: string;
21
+ title?: React.ReactNode;
22
+ items: ShellNavItem[];
23
+ }
24
+ export interface ShellCommandItem {
25
+ id: string;
26
+ label: string;
27
+ shortcut?: string;
28
+ onSelect?: () => void;
29
+ }
30
+ export interface ShellCommandGroup {
31
+ heading?: string;
32
+ items: ShellCommandItem[];
33
+ }
34
+ export interface ShellBreadcrumbItem {
35
+ href?: string;
36
+ label: React.ReactNode;
37
+ }
38
+ export interface ShellUserMenuItem {
39
+ label: React.ReactNode;
40
+ href?: string;
41
+ onSelect?: () => void;
42
+ icon?: React.ReactNode;
43
+ danger?: boolean;
44
+ }
45
+ export interface ShellUserMenu {
46
+ name?: string;
47
+ email?: string;
48
+ imageUrl?: string;
49
+ items: ShellUserMenuItem[];
50
+ }
51
+ export type PageOutlineLevel = 1 | 2 | 3;
52
+ export interface PageOutlineItem {
53
+ id: string;
54
+ label: React.ReactNode;
55
+ href?: string;
56
+ level?: PageOutlineLevel;
57
+ children?: PageOutlineItem[];
58
+ }
59
+ export interface AppShellConfig {
60
+ brand?: React.ReactNode;
61
+ navigation?: ShellNavSection[];
62
+ commands?: ShellCommandGroup[];
63
+ breadcrumbs?: ShellBreadcrumbItem[];
64
+ userMenu?: React.ReactNode;
65
+ pageOutline?: PageOutlineItem[];
66
+ }
File without changes
@@ -1 +1 @@
1
- import{defineFeature as g}from"@contractspec/lib.contracts-spec/features";export const DesignSystemFeature=g({meta:{key:"libs.design-system",version:"1.0.0",title:"Design System",description:"Design tokens and theming primitives",domain:"design-system",owners:["@contractspec-core"],tags:["package","libs","design-system"],stability:"experimental"}});
1
+ import{defineFeature as g}from"@contractspec/lib.contracts-spec/features";export const DesignSystemFeature=g({meta:{key:"libs.design-system",version:"1.0.0",title:"Design System",description:"Design tokens, theming primitives, and composed product-surface components",domain:"design-system",owners:["@contractspec-core"],tags:["package","libs","design-system","components"],stability:"experimental"}});
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export { Textarea } from './components/atoms/Textarea';
19
19
  export { DataTable, type DataTableProps, } from './components/data-table/DataTable';
20
20
  export { DataTableToolbar, type DataTableToolbarProps, } from './components/data-table/DataTableToolbar';
21
21
  export { DataViewDetail } from './components/data-view/DataViewDetail';
22
+ export { DataViewGrid } from './components/data-view/DataViewGrid';
22
23
  export { DataViewList } from './components/data-view/DataViewList';
23
24
  export { DataViewRenderer } from './components/data-view/DataViewRenderer';
24
25
  export { DataViewTable } from './components/data-view/DataViewTable';
@@ -80,6 +81,7 @@ export { SkeletonList } from './components/molecules/SkeletonList';
80
81
  export { StatCard, StatCardGroup } from './components/molecules/StatCard';
81
82
  export { StatusChip } from './components/molecules/StatusChip';
82
83
  export { Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps, TabsTrigger, type TabsTriggerProps, } from './components/molecules/Tabs';
84
+ export { createCopyReferenceAction, createDefaultObjectReferenceActions, createMapsProviderHref, createMapsReferenceActions, createOpenReferenceAction, createPhoneReferenceAction, getObjectReferenceDisplayValue, type ObjectReferenceActionDescriptor, type ObjectReferenceActionEvent, type ObjectReferenceActionHandler, type ObjectReferenceCopyHandler, type ObjectReferenceDescriptor, ObjectReferenceHandler, type ObjectReferenceHandlerProps, type ObjectReferenceInteractivityVisibility, type ObjectReferenceKind, type ObjectReferenceMapsProvider, type ObjectReferenceMetadata, type ObjectReferenceOpenHrefHandler, } from './components/object-reference';
83
85
  export { AcademyLayout } from './components/organisms/AcademyLayout';
84
86
  export { AppHeader } from './components/organisms/AppHeader';
85
87
  export { AppLayout } from './components/organisms/AppLayout';
@@ -107,6 +109,8 @@ export { PricingCarousel } from './components/organisms/PricingCarousel';
107
109
  export { PricingSection } from './components/organisms/PricingSection';
108
110
  export { TestimonialCarousel } from './components/organisms/TestimonialCarousel';
109
111
  export { PackageManagerProvider, type PackageManagerProviderProps, usePackageManager, } from './components/providers/PackageManagerProvider';
112
+ export type { AppShellConfig, PageOutlineItem, PageOutlineLevel, ShellBreadcrumbItem, ShellCommandGroup, ShellCommandItem, ShellNavItem, ShellNavMatch, ShellNavSection, ShellUserMenu, ShellUserMenuItem, } from './components/shell';
113
+ export { AppShell, type AppShellProps, PageOutline, type PageOutlineProps, ShellSidebar, type ShellSidebarProps, usePageOutlineActiveItem, } from './components/shell';
110
114
  export { ListPageTemplate } from './components/templates/lists/ListPageTemplate';
111
115
  export { BlockQuote, Code, H1, H2, H3, H4, Large, Lead, Muted, P, Small, Text, } from './components/typography';
112
116
  export { ComparisonView, type ComparisonViewProps, } from './components/visualization/ComparisonView';