@quixomatic/rpf 0.3.1 → 0.3.3

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 (180) hide show
  1. package/CHANGELOG.md +236 -0
  2. package/README.md +4 -2
  3. package/assets/dev-host/boot.js +7 -223
  4. package/assets/dev-host/boot.js.LEGAL.txt +0 -22
  5. package/assets/dev-host/chunks/{accordion-O6VUPQ32.js → accordion-7MNNAFNO.js} +2 -2
  6. package/assets/dev-host/chunks/{alert-PRAGKG5L.js → alert-GIZIVENB.js} +2 -2
  7. package/assets/dev-host/chunks/{alert-dialog-SCBXM23J.js → alert-dialog-7NG5WNXK.js} +2 -2
  8. package/assets/dev-host/chunks/{avatar-WXPKQ3Z5.js → avatar-BCPZUJGX.js} +2 -2
  9. package/assets/dev-host/chunks/{breadcrumb-IJQJQ5JV.js → breadcrumb-T2XOHRDG.js} +2 -2
  10. package/assets/dev-host/chunks/button-TGT2523L.js +2 -0
  11. package/assets/dev-host/chunks/calendar-TOTKKMY2.js +2 -0
  12. package/assets/dev-host/chunks/{card-EY3LK2GB.js → card-LOSZVZYW.js} +2 -2
  13. package/assets/dev-host/chunks/{chart-2PHC6UIE.js → chart-43TBOZGK.js} +2 -2
  14. package/assets/dev-host/chunks/{chart-blocks-PZPCWCNT.js → chart-blocks-HLNNWNB5.js} +2 -2
  15. package/assets/dev-host/chunks/{chart-frame-MNUFXAPU.js → chart-frame-FNM5OPZU.js} +2 -2
  16. package/assets/dev-host/chunks/{chat-TTESCYES.js → chat-QVZ4BUWR.js} +2 -2
  17. package/assets/dev-host/chunks/{checkbox-Y2UGSRR4.js → checkbox-AFUTB4DV.js} +2 -2
  18. package/assets/dev-host/chunks/{chunk-UWANBOC6.js → chunk-2FVHAZMZ.js} +2 -2
  19. package/assets/dev-host/chunks/{chunk-CWDPAB6V.js → chunk-34RXMJIM.js} +2 -2
  20. package/assets/dev-host/chunks/chunk-354OFHNU.js +219 -0
  21. package/assets/dev-host/chunks/chunk-354OFHNU.js.LEGAL.txt +23 -0
  22. package/assets/dev-host/chunks/{chunk-CCXMDKVL.js → chunk-3LMPMW3Q.js} +2 -2
  23. package/assets/dev-host/chunks/{chunk-3H6F4X7R.js → chunk-4XESWRTW.js} +2 -2
  24. package/assets/dev-host/chunks/{chunk-PYWKHILP.js → chunk-7FCGD4LS.js} +2 -2
  25. package/assets/dev-host/chunks/{chunk-AVSRGCSF.js → chunk-7JQIKRBV.js} +2 -2
  26. package/assets/dev-host/chunks/{chunk-PHK25MY7.js → chunk-DU3VFETH.js} +2 -2
  27. package/assets/dev-host/chunks/{chunk-2IZ44WWI.js → chunk-E5JYU6CR.js} +2 -2
  28. package/assets/dev-host/chunks/{chunk-BB4IX5QA.js → chunk-FBZMZ5S2.js} +2 -2
  29. package/assets/dev-host/chunks/{chunk-GWDGPUGM.js → chunk-GSJT5YWB.js} +2 -2
  30. package/assets/dev-host/chunks/{chunk-OXJ6LWKI.js → chunk-HCQR5YME.js} +3 -3
  31. package/assets/dev-host/chunks/{chunk-APP2HKWR.js → chunk-HGBRF6KW.js} +2 -2
  32. package/assets/dev-host/chunks/{chunk-6ARM5VDH.js → chunk-HVTUE7NV.js} +2 -2
  33. package/assets/dev-host/chunks/{chunk-M7A47ZSM.js → chunk-IY3GAGI7.js} +2 -2
  34. package/assets/dev-host/chunks/{chunk-MGLBTOXD.js → chunk-KY2HARU6.js} +2 -2
  35. package/assets/dev-host/chunks/{chunk-EDEL6XSO.js → chunk-ND526XXU.js} +2 -2
  36. package/assets/dev-host/chunks/{chunk-UXUS6DNI.js → chunk-NMFZMT4R.js} +2 -2
  37. package/assets/dev-host/chunks/{chunk-XE5RQ73V.js → chunk-NPJXSRRT.js} +2 -2
  38. package/assets/dev-host/chunks/{chunk-FJRWQRLM.js → chunk-OUCK2LIZ.js} +2 -2
  39. package/assets/dev-host/chunks/{chunk-Z76KXEPD.js → chunk-OXLXEX2R.js} +2 -2
  40. package/assets/dev-host/chunks/{chunk-BH6FGVDP.js → chunk-PB5RYDO5.js} +2 -2
  41. package/assets/dev-host/chunks/{chunk-TQPXDAVH.js → chunk-QJVIEN5R.js} +2 -2
  42. package/assets/dev-host/chunks/{chunk-57M36GYM.js → chunk-QZ3NJHFR.js} +2 -2
  43. package/assets/dev-host/chunks/{chunk-FZPMZMFU.js → chunk-SC7J7HFI.js} +2 -2
  44. package/assets/dev-host/chunks/{chunk-X34AFUS2.js → chunk-SKBWMIS5.js} +2 -2
  45. package/assets/dev-host/chunks/{chunk-LTVKSGLG.js → chunk-UCEBXCOI.js} +2 -2
  46. package/assets/dev-host/chunks/{chunk-T7JFBQSG.js → chunk-UNKI7HPL.js} +2 -2
  47. package/assets/dev-host/chunks/{chunk-F5MKIWPQ.js → chunk-UPZXXDXM.js} +2 -2
  48. package/assets/dev-host/chunks/{chunk-ML6HCGK5.js → chunk-XBWE3IIB.js} +2 -2
  49. package/assets/dev-host/chunks/{chunk-NJX7QY3Z.js → chunk-YFI7GTF6.js} +2 -2
  50. package/assets/dev-host/chunks/{chunk-NI6ZJ6DH.js → chunk-YJM2Y722.js} +2 -2
  51. package/assets/dev-host/chunks/{chunk-WLBNJ4K3.js → chunk-ZNWVTDCV.js} +2 -2
  52. package/assets/dev-host/chunks/{chunk-UUJ5X322.js → chunk-ZTMZ7LJW.js} +2 -2
  53. package/assets/dev-host/chunks/{chunk-OW6AVFQA.js → chunk-ZZ2RYU7S.js} +2 -2
  54. package/assets/dev-host/chunks/{code-block-H2ETQV3M.js → code-block-IKYEIWY2.js} +2 -2
  55. package/assets/dev-host/chunks/code-editor-KDRLM33B.js +2 -0
  56. package/assets/dev-host/chunks/{collapsible-4ZOFMWLB.js → collapsible-WK7PDWEV.js} +2 -2
  57. package/assets/dev-host/chunks/{color-picker-RRCCLR54.js → color-picker-VPSOGTDM.js} +2 -2
  58. package/assets/dev-host/chunks/{combobox-U4455OMJ.js → combobox-GYLAHYVX.js} +2 -2
  59. package/assets/dev-host/chunks/{contrast-badge-KDF65X7J.js → contrast-badge-QZW62DMF.js} +2 -2
  60. package/assets/dev-host/chunks/{date-range-picker-WJYHAHRM.js → date-range-picker-6Q2JGR43.js} +2 -2
  61. package/assets/dev-host/chunks/{dialog-I6AGHWB3.js → dialog-HDQAIAFZ.js} +2 -2
  62. package/assets/dev-host/chunks/{dropdown-menu-LSOMXDWG.js → dropdown-menu-E7K3YNXS.js} +2 -2
  63. package/assets/dev-host/chunks/{empty-NLQODUSK.js → empty-JCVCSM3V.js} +2 -2
  64. package/assets/dev-host/chunks/{font-picker-3TLYYZJH.js → font-picker-7FBJCSTQ.js} +2 -2
  65. package/assets/dev-host/chunks/{frame-HA7UIYZF.js → frame-LZ2IUISE.js} +2 -2
  66. package/assets/dev-host/chunks/{heading-7M24WKK6.js → heading-GX36VR3U.js} +2 -2
  67. package/assets/dev-host/chunks/{hover-card-HSHOQPOI.js → hover-card-ONEUZ7TU.js} +2 -2
  68. package/assets/dev-host/chunks/{image-R7XGYKVH.js → image-E3BYZ2HA.js} +2 -2
  69. package/assets/dev-host/chunks/{input-YECXNM53.js → input-G7S4OLSN.js} +2 -2
  70. package/assets/dev-host/chunks/{input-group-GFKXSZM7.js → input-group-54JRMLWQ.js} +2 -2
  71. package/assets/dev-host/chunks/{kbd-V25ZMVCM.js → kbd-TKMXF542.js} +2 -2
  72. package/assets/dev-host/chunks/label-YIVRPKQJ.js +2 -0
  73. package/assets/dev-host/chunks/{label-value-6Z6ATP55.js → label-value-V7QDIDAP.js} +2 -2
  74. package/assets/dev-host/chunks/{logo-AAMBHX2W.js → logo-DBA4NHQE.js} +2 -2
  75. package/assets/dev-host/chunks/{number-field-6TCQAVTR.js → number-field-FPC3YXDC.js} +2 -2
  76. package/assets/dev-host/chunks/{pill-7L57ZNRJ.js → pill-4WVEOBR4.js} +2 -2
  77. package/assets/dev-host/chunks/{popover-3P6YNKH3.js → popover-GQD2U5SP.js} +2 -2
  78. package/assets/dev-host/chunks/{progress-RBCJRVM7.js → progress-TITSWD2A.js} +2 -2
  79. package/assets/dev-host/chunks/{radio-group-NJWXZCX3.js → radio-group-YA3OUIPB.js} +2 -2
  80. package/assets/dev-host/chunks/{resizable-XF4P6OKR.js → resizable-XQKUCHIS.js} +2 -2
  81. package/assets/dev-host/chunks/rich-text-2RYBPVRF.js +2 -0
  82. package/assets/dev-host/chunks/{rich-text-editor-T6KWD4P3.js → rich-text-editor-IX7RIMLI.js} +2 -2
  83. package/assets/dev-host/chunks/{scroll-row-LMI7JCFR.js → scroll-row-MZZQZYLM.js} +2 -2
  84. package/assets/dev-host/chunks/{select-F3MZWTTS.js → select-5U37ZHLQ.js} +2 -2
  85. package/assets/dev-host/chunks/separator-JATMMEKS.js +2 -0
  86. package/assets/dev-host/chunks/{sheet-EXRT4MFB.js → sheet-KTVNRYAO.js} +2 -2
  87. package/assets/dev-host/chunks/{side-panel-IBHLEANN.js → side-panel-2UVNFRIF.js} +2 -2
  88. package/assets/dev-host/chunks/{sidebar-VKQMQMF2.js → sidebar-GR4A2LDD.js} +2 -2
  89. package/assets/dev-host/chunks/{skeleton-KIRVQ4EO.js → skeleton-XE2TGBGQ.js} +2 -2
  90. package/assets/dev-host/chunks/{slider-XKYDL5MR.js → slider-BGGGQLSH.js} +2 -2
  91. package/assets/dev-host/chunks/{split-button-WP6LALDS.js → split-button-KLVGWHNN.js} +2 -2
  92. package/assets/dev-host/chunks/{stepper-KR6PXZHW.js → stepper-AY3NGEDC.js} +2 -2
  93. package/assets/dev-host/chunks/{switch-P6NJELJJ.js → switch-A2VSCLHA.js} +2 -2
  94. package/assets/dev-host/chunks/{tabs-PFPRJNVZ.js → tabs-2IO6EIED.js} +2 -2
  95. package/assets/dev-host/chunks/textarea-YQH2OPGH.js +2 -0
  96. package/assets/dev-host/chunks/{toggle-group-PS7JN2JM.js → toggle-group-3SDBWJ2G.js} +2 -2
  97. package/assets/dev-host/chunks/{tooltip-S4RBC3O4.js → tooltip-4QJ2SWCS.js} +2 -2
  98. package/assets/dev-host/chunks/{tree-NQF6ZJLH.js → tree-CFIKTPFC.js} +2 -2
  99. package/assets/dev-host/kit-candidates.json +1 -1
  100. package/assets/dev-host/kit-manifest.json +1 -1
  101. package/assets/dev-host/stage.js +54 -0
  102. package/assets/forge-app/app/assets/{_forge-shiki-langs-DaJjT17w.js → _forge-shiki-langs-Bm9NaYXm.js} +1 -1
  103. package/assets/forge-app/app/assets/{appendItems-CWJJlOE7.js → appendItems-DrlkyU0a.js} +1 -1
  104. package/assets/forge-app/app/assets/{core-Dl2d1S-D.js → core-8OhGxroQ.js} +1 -1
  105. package/assets/forge-app/app/assets/{diff-view-Chujmqzi.js → diff-view-rgZLuZMg.js} +4 -4
  106. package/assets/forge-app/app/assets/file-panel-CpPZ9DXB.js +1199 -0
  107. package/assets/forge-app/app/assets/{highlights-BxaWC1ve.js → highlights-C-SEG213.js} +1 -1
  108. package/assets/forge-app/app/assets/index-DWGc27yI.css +1 -0
  109. package/assets/forge-app/app/assets/index-DXDXX5UZ.js +298 -0
  110. package/assets/forge-app/app/assets/{loader-BMv9OYvr.js → loader-Du5I86pW.js} +1 -1
  111. package/assets/forge-app/app/assets/{shiki-CoRI3zWj.js → shiki-Bf12fWbJ.js} +2 -2
  112. package/assets/forge-app/app/assets/{stream-tokenizer-BMtK_3oz.js → stream-tokenizer-DdzFthqp.js} +1 -1
  113. package/assets/forge-app/app/assets/{terminal-view-D3CiLjfu.js → terminal-view-Co0jXSWF.js} +1 -1
  114. package/assets/forge-app/app/assets/{themes-CLX9vH7e.js → themes-BrkVmSlQ.js} +2 -2
  115. package/assets/forge-app/app/assets/{useNextRenderData-dgMkjxGZ.js → useNextRenderData-BKv-kpPs.js} +3 -3
  116. package/assets/forge-app/app/index.html +2 -2
  117. package/assets/forge-app/server.mjs +2677 -8753
  118. package/dist/cli.mjs +13247 -7148
  119. package/examples/component-workspace/README.md +23 -0
  120. package/examples/component-workspace/components/@example/greeting/component.json +8 -0
  121. package/examples/component-workspace/components/@example/greeting/main.tsx +22 -0
  122. package/examples/component-workspace/components/@example/greeting/options.schema.json +6 -0
  123. package/examples/component-workspace/forge.workspace.json +7 -0
  124. package/examples/component-workspace/stage.json +11 -0
  125. package/examples/header-slot-widget/README.md +30 -0
  126. package/examples/header-slot-widget/components/@example/page-actions/component.json +8 -0
  127. package/examples/header-slot-widget/components/@example/page-actions/main.tsx +37 -0
  128. package/examples/header-slot-widget/components/@example/page-actions/options.schema.json +9 -0
  129. package/examples/index.json +159 -0
  130. package/examples/layout-regions/README.md +41 -0
  131. package/examples/layout-regions/components/@example/workspace-shell/component.json +21 -0
  132. package/examples/layout-regions/components/@example/workspace-shell/main.tsx +61 -0
  133. package/examples/layout-regions/components/@example/workspace-shell/options.schema.json +29 -0
  134. package/examples/layout-regions/components/@example/workspace-shell/styles.css +95 -0
  135. package/examples/portal-list-page/README.md +22 -0
  136. package/examples/portal-list-page/portal.mjs +40 -0
  137. package/examples/portal-record-page/README.md +23 -0
  138. package/examples/portal-record-page/portal.mjs +62 -0
  139. package/examples/primitive-and-utility/README.md +19 -0
  140. package/examples/primitive-and-utility/components/@example/number-format/component.json +6 -0
  141. package/examples/primitive-and-utility/components/@example/number-format/main.tsx +30 -0
  142. package/examples/primitive-and-utility/components/@example/stat-tile/component.json +6 -0
  143. package/examples/primitive-and-utility/components/@example/stat-tile/main.tsx +45 -0
  144. package/examples/primitive-and-utility/components/@example/work-summary/component.json +9 -0
  145. package/examples/primitive-and-utility/components/@example/work-summary/main.tsx +31 -0
  146. package/examples/primitive-and-utility/components/@example/work-summary/options.schema.json +6 -0
  147. package/examples/primitive-and-utility/components/@example/work-summary/server.js +27 -0
  148. package/examples/side-panel/README.md +18 -0
  149. package/examples/side-panel/components/@example/help-button/component.json +8 -0
  150. package/examples/side-panel/components/@example/help-button/main.tsx +26 -0
  151. package/examples/side-panel/components/@example/help-button/options.schema.json +7 -0
  152. package/examples/side-panel/portal.mjs +46 -0
  153. package/examples/theme/README.md +16 -0
  154. package/examples/theme/themes/teal-harbor/theme.css +11 -0
  155. package/examples/theme/themes/teal-harbor/theme.json +8 -0
  156. package/examples/theme/themes/teal-harbor/tokens.json +72 -0
  157. package/examples/widget-options/README.md +25 -0
  158. package/examples/widget-options/components/@example/notice-banner/component.json +14 -0
  159. package/examples/widget-options/components/@example/notice-banner/main.tsx +60 -0
  160. package/examples/widget-options/components/@example/notice-banner/options.schema.json +24 -0
  161. package/examples/widget-server-user/README.md +21 -0
  162. package/examples/widget-server-user/components/@example/user-card/component.json +9 -0
  163. package/examples/widget-server-user/components/@example/user-card/main.tsx +51 -0
  164. package/examples/widget-server-user/components/@example/user-card/options.schema.json +6 -0
  165. package/examples/widget-server-user/components/@example/user-card/server.js +27 -0
  166. package/package.json +7 -3
  167. package/skills/react-portal/SKILL.md +23 -1
  168. package/skills/react-portal/references/cli.md +11 -0
  169. package/skills/react-portal/references/components.md +40 -2
  170. package/assets/dev-host/chunks/button-4JMBKYN4.js +0 -2
  171. package/assets/dev-host/chunks/calendar-XXLCAUPG.js +0 -2
  172. package/assets/dev-host/chunks/code-editor-2JYERJLS.js +0 -2
  173. package/assets/dev-host/chunks/label-LJT4V2CT.js +0 -2
  174. package/assets/dev-host/chunks/rich-text-7OMYZ564.js +0 -2
  175. package/assets/dev-host/chunks/separator-JRJYKM4Z.js +0 -2
  176. package/assets/dev-host/chunks/textarea-2JXA5XWS.js +0 -2
  177. package/assets/forge-app/app/assets/file-panel-le_M5nHe.js +0 -1199
  178. package/assets/forge-app/app/assets/index-BwYJlfwT.css +0 -1
  179. package/assets/forge-app/app/assets/index-UP3KtgHV.js +0 -291
  180. /package/assets/dev-host/chunks/{chunk-OXJ6LWKI.js.LEGAL.txt → chunk-HCQR5YME.js.LEGAL.txt} +0 -0
@@ -0,0 +1,23 @@
1
+ # A record page: header, form, tabs, related lists, side panels and a variant
2
+
3
+ One URL (`record`, opened with `table` + `sys_id`) that works for every table, plus a **page variant** that gives
4
+ incidents their own arrangement. Configured entirely with React Portal's record widgets, placed by reference.
5
+
6
+ ## Files
7
+
8
+ - `portal.mjs`: a fragment. Merge the `pages` entry and the two `panels` into your portal.mjs.
9
+
10
+ ## What to notice
11
+
12
+ - The default placements: `record-tabs` in the shell's `tabs` header slot (Details, then a tab per side panel with
13
+ live counts) and `record-form`. The form draws the record header itself (title, highlights, presence) in the
14
+ shell's header slots. `record-header` is a primitive: import it into your own widget, never place it.
15
+ - `variants`: the first variant whose `condition` matches the URL params (`table=incident`) replaces the page's
16
+ placements. Here a `split` block puts the form beside a compact `activity-card`; block children are listed per
17
+ drop zone (`start`, `end`).
18
+ - `panels`: side panels with their own placements, offered on the pages in `pages`. `record-tabs` counts the
19
+ `attachments` and `related` panels by key (its `attachmentsPanel` / `relatedPanel` options default to those keys).
20
+ `body: 'full'` gives a panel's widgets the whole panel.
21
+ - The layout must render `<SidePanelRegion>` (app-shell does) for panels to open.
22
+
23
+ Read more: `read_doc concepts/page-variants`, `read_doc concepts/side-panels`, `read_doc primitives/record-header`.
@@ -0,0 +1,62 @@
1
+ export default {
2
+ pages: [
3
+ {
4
+ route: 'record',
5
+ name: 'Record',
6
+ order: 300,
7
+ contentWidth: 'full',
8
+ layoutOptions: { subheader: 'banner' },
9
+ widgets: [
10
+ { key: 'tabs', c: 'record-tabs', order: 150, options: { slot: 'tabs', counts: true } },
11
+ { key: 'form', c: 'record-form', order: 200 },
12
+ ],
13
+ variants: [
14
+ {
15
+ key: 'incident',
16
+ name: 'Incident',
17
+ order: 100,
18
+ condition: 'table=incident',
19
+ widgets: [
20
+ { key: 'tabs', c: 'record-tabs', order: 150, options: { slot: 'tabs', counts: true } },
21
+ {
22
+ key: 'layout',
23
+ c: 'split',
24
+ order: 200,
25
+ options: { template: 'minmax(0, 2fr) minmax(0, 1fr)', gap: '1.5rem' },
26
+ children: {
27
+ start: [{ key: 'form', c: 'record-form', order: 100 }],
28
+ end: [
29
+ {
30
+ key: 'activity',
31
+ c: 'activity-card',
32
+ order: 100,
33
+ options: { variant: 'compact', composer: true },
34
+ },
35
+ ],
36
+ },
37
+ },
38
+ ],
39
+ },
40
+ ],
41
+ },
42
+ ],
43
+ panels: [
44
+ {
45
+ key: 'attachments',
46
+ title: 'Attachments',
47
+ icon: 'paperclip',
48
+ pages: ['record'],
49
+ order: 100,
50
+ widgets: [{ key: 'files', c: 'attachments-card', order: 100, options: { layout: 'list' } }],
51
+ },
52
+ {
53
+ key: 'related',
54
+ title: 'Related',
55
+ icon: 'list-tree',
56
+ pages: ['record'],
57
+ body: 'full',
58
+ order: 200,
59
+ widgets: [{ key: 'lists', c: 'related-lists-card', order: 100, options: { layout: 'stacked' } }],
60
+ },
61
+ ],
62
+ };
@@ -0,0 +1,19 @@
1
+ # A primitive and a utility, imported by a widget
2
+
3
+ Three components that show the layering rule: shared UI goes in a **primitive**, shared logic in a **utility**, and
4
+ the placeable **widget** composes them.
5
+
6
+ | Component | Kind | Imported as |
7
+ |---|---|---|
8
+ | `example/stat-tile` | primitive | `import { StatTile } from 'components:example/stat-tile'` |
9
+ | `example/number-format` | utility | `import { useCompactFormat } from 'utilities:example/number-format'` |
10
+ | `example/work-summary` | widget (placed on pages) | not imported; `c: 'example/work-summary'` in portal.mjs |
11
+
12
+ ## Notes
13
+
14
+ - A primitive's default export is its Studio preview; importers get the named exports.
15
+ - A utility's `main.tsx` has no default export: hooks and helpers only.
16
+ - Record imports compile once per component and are shared by every widget that imports them; widgets never copy a
17
+ primitive's code.
18
+ - Copy all three into a workspace with `rpf examples copy primitive-and-utility --ns <your namespace>`: the
19
+ `example` namespace is renamed in folders and import specifiers.
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "Number format",
3
+ "kind": "utility",
4
+ "description": "Compact number formatting in the user's language",
5
+ "tailwind": false
6
+ }
@@ -0,0 +1,30 @@
1
+ import { useMemo } from 'react';
2
+ import { useUser } from '@portal/runtime';
3
+
4
+ /**
5
+ * utilities:example/number-format: compact number formatting in the user's language.
6
+ *
7
+ * A utility: code without UI, imported as `utilities:example/number-format`. Export every hook and helper by name so
8
+ * widgets and primitives share one implementation.
9
+ */
10
+
11
+ /**
12
+ * Formats a number compactly (1234 → "1.2K").
13
+ * @param value the number (non-numbers render as "–")
14
+ * @param locale a BCP 47 language tag (default: the runtime's)
15
+ * @returns the formatted text
16
+ */
17
+ export function formatCompact(value: unknown, locale?: string): string {
18
+ const n = typeof value === 'number' ? value : Number(value);
19
+ if (!Number.isFinite(n)) return '–';
20
+ return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 1 }).format(n);
21
+ }
22
+
23
+ /**
24
+ * A formatter bound to the signed-in user's language.
25
+ * @returns (value) => compact text
26
+ */
27
+ export function useCompactFormat(): (value: unknown) => string {
28
+ const { language } = useUser();
29
+ return useMemo(() => (value: unknown) => formatCompact(value, language || undefined), [language]);
30
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "Stat tile",
3
+ "kind": "primitive",
4
+ "description": "A labeled number with an optional hint, for KPI rows",
5
+ "tailwind": true
6
+ }
@@ -0,0 +1,45 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Card, CardContent } from 'components:card';
3
+ import { Skeleton } from 'components:skeleton';
4
+
5
+ /**
6
+ * components:example/stat-tile: a labeled number with an optional hint, for KPI rows and dashboards.
7
+ *
8
+ * A primitive: never placed on a page, imported by widgets (`import { StatTile } from 'components:example/stat-tile'`).
9
+ * Named exports are what importers get; the default export is only Studio's preview.
10
+ */
11
+
12
+ export interface StatTileProps {
13
+ label: string;
14
+ /** The formatted value; undefined renders a skeleton (data still loading). */
15
+ value?: ReactNode;
16
+ hint?: ReactNode;
17
+ className?: string;
18
+ }
19
+
20
+ /** One KPI tile. */
21
+ export function StatTile({ label, value, hint, className = '' }: StatTileProps) {
22
+ return (
23
+ <Card className={className}>
24
+ <CardContent className="flex flex-col gap-1">
25
+ <span className="text-sm text-muted-foreground">{label}</span>
26
+ {value === undefined ? (
27
+ <Skeleton className="h-8 w-16" />
28
+ ) : (
29
+ <span className="text-3xl font-semibold tabular-nums">{value}</span>
30
+ )}
31
+ {hint ? <span className="text-xs text-muted-foreground">{hint}</span> : null}
32
+ </CardContent>
33
+ </Card>
34
+ );
35
+ }
36
+
37
+ /** Shown in Studio's preview of the primitive. */
38
+ export default function StatTilePreview() {
39
+ return (
40
+ <div className="grid max-w-md grid-cols-2 gap-3">
41
+ <StatTile label="Open" value="12" hint="assigned to you" />
42
+ <StatTile label="Loading" />
43
+ </div>
44
+ );
45
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "Work summary",
3
+ "kind": "widget",
4
+ "description": "KPI tiles for the signed-in user's open work, built from the stat-tile primitive and number-format utility",
5
+ "placeable": true,
6
+ "serverMode": "on-load",
7
+ "tailwind": true,
8
+ "defaults": { "title": "My work" }
9
+ }
@@ -0,0 +1,31 @@
1
+ import { useServer } from '@portal/runtime';
2
+ import { StatTile } from 'components:example/stat-tile';
3
+ import { useCompactFormat } from 'utilities:example/number-format';
4
+
5
+ type Options = { title?: string };
6
+ type Counts = { open?: number; dueToday?: number; updatedThisWeek?: number };
7
+
8
+ /**
9
+ * components:example/work-summary: three KPI tiles for the signed-in user's open work.
10
+ *
11
+ * It composes the stat-tile primitive and the number-format utility (record imports of other components) instead of
12
+ * re-implementing either, and gets its numbers from server.js (serverMode "on-load").
13
+ */
14
+ export default function WorkSummary({ options = {} }: { options?: Options }) {
15
+ const { data, error } = useServer();
16
+ const fmt = useCompactFormat();
17
+ const counts = (data || {}) as Counts;
18
+ // undefined until the result arrives: StatTile shows a skeleton for an undefined value.
19
+ const value = (n: number | undefined) => (data === undefined ? undefined : fmt(n || 0));
20
+ if (error) return <p className="text-sm text-destructive">{error.message}</p>;
21
+ return (
22
+ <section className="flex flex-col gap-3">
23
+ {options.title ? <h2 className="text-lg font-semibold">{options.title}</h2> : null}
24
+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-3">
25
+ <StatTile label="Open" value={value(counts.open)} hint="assigned to you" />
26
+ <StatTile label="Due today" value={value(counts.dueToday)} />
27
+ <StatTile label="Updated this week" value={value(counts.updatedThisWeek)} />
28
+ </div>
29
+ </section>
30
+ );
31
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "title": { "type": "string", "title": "Title", "default": "My work" }
5
+ }
6
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Server script of components:example/work-summary: counts the visitor's open tasks.
3
+ *
4
+ * GlideRecordSecure applies the visitor's ACLs, so the counts only include tasks they may read. getRowCount() reads
5
+ * the whole result set: fine for one person's work; for big tables, aggregate after checking access yourself.
6
+ */
7
+ (function () {
8
+ /**
9
+ * Counts active tasks assigned to the visitor that match an extra encoded query.
10
+ * @param {string} extra an encoded query ('' for none)
11
+ * @returns {number} the row count
12
+ */
13
+ function count(extra) {
14
+ var gr = new GlideRecordSecure('task');
15
+ gr.addActiveQuery();
16
+ gr.addQuery('assigned_to', gs.getUserID());
17
+ if (extra) gr.addEncodedQuery(extra);
18
+ gr.query();
19
+ return gr.getRowCount();
20
+ }
21
+
22
+ data.open = count('');
23
+ data.dueToday = count('due_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
24
+ data.updatedThisWeek = count(
25
+ 'sys_updated_onONThis week@javascript:gs.beginningOfThisWeek()@javascript:gs.endOfThisWeek()'
26
+ );
27
+ })();
@@ -0,0 +1,18 @@
1
+ # A side panel with its own placements, opened from a page
2
+
3
+ ## Files
4
+
5
+ - `portal.mjs`: a fragment with a `panels` entry (`get-help`, two React Portal widgets placed inside it by
6
+ reference), a menu item that opens it (`{ panel: 'get-help' }`) and a page placement of the button below. Merge the
7
+ entries into your portal.mjs.
8
+ - `components/@example/help-button`: a widget that toggles the panel with `useSidePanel()`.
9
+
10
+ ## What to notice
11
+
12
+ - A panel is a record with placements, like a page. `pages: [...]` limits where it's offered (none = every page);
13
+ `body: 'full'` gives its widgets the whole panel; `width` sets its default width.
14
+ - Three ways to open one: a menu item `{ panel: '<key>' }`, `<Link panel="<key>">`, or `useSidePanel().openPanel` /
15
+ `toggle` in code. A page's `defaultPanel` opens one when the page loads.
16
+ - The layout decides where panels appear by rendering `<SidePanelRegion>` (push beside main, or overlay).
17
+
18
+ Read more: `read_doc concepts/side-panels`.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "Help button",
3
+ "kind": "widget",
4
+ "description": "Opens or closes a side panel from a page",
5
+ "placeable": true,
6
+ "tailwind": true,
7
+ "defaults": { "panel": "get-help", "label": "Get help" }
8
+ }
@@ -0,0 +1,26 @@
1
+ import { useSidePanel } from '@portal/runtime';
2
+ import { Button } from 'components:button';
3
+ import { Icon } from 'components:icon';
4
+
5
+ type Options = { panel?: string; label?: string };
6
+
7
+ /**
8
+ * components:example/help-button: opens (or closes) a side panel from a page.
9
+ *
10
+ * useSidePanel() exposes the open panel and openPanel / close / toggle. A panel opens only where it is offered (its
11
+ * `pages` in portal.mjs, or every page when it lists none) and only in a layout that renders <SidePanelRegion>;
12
+ * `available` is false otherwise, and the button hides. A menu item `{ panel: '<key>' }` or
13
+ * `<Link panel="<key>">` opens one without code.
14
+ */
15
+ export default function HelpButton({ options = {} }: { options?: Options }) {
16
+ const panels = useSidePanel();
17
+ const key = options.panel || 'get-help';
18
+ if (!panels.available || !panels.panels.some((p) => p.key === key)) return null;
19
+ const open = panels.open && panels.key === key;
20
+ return (
21
+ <Button variant={open ? 'secondary' : 'outline'} onClick={() => panels.toggle(key)} aria-pressed={open}>
22
+ <Icon name="life-buoy" />
23
+ {options.label || 'Get help'}
24
+ </Button>
25
+ );
26
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "panel": { "type": "string", "title": "Panel key", "default": "get-help" },
5
+ "label": { "type": "string", "title": "Label", "default": "Get help" }
6
+ }
7
+ }
@@ -0,0 +1,46 @@
1
+ export default {
2
+ pages: [
3
+ {
4
+ route: 'home',
5
+ name: 'Home',
6
+ order: 100,
7
+ widgets: [{ key: 'help', c: 'example/help-button', order: 900, options: { panel: 'get-help' } }],
8
+ },
9
+ ],
10
+ panels: [
11
+ {
12
+ key: 'get-help',
13
+ title: 'Get help',
14
+ icon: 'life-buoy',
15
+ order: 100,
16
+ widgets: [
17
+ {
18
+ key: 'articles',
19
+ c: 'kb-articles',
20
+ order: 100,
21
+ options: { title: 'Popular answers', modes: ['popular'], limit: 5, compact: true },
22
+ },
23
+ {
24
+ key: 'links',
25
+ c: 'quick-links',
26
+ order: 200,
27
+ options: {
28
+ title: 'Still stuck?',
29
+ columns: 2,
30
+ items: [
31
+ { label: 'Report an issue', icon: 'bug', to: 'catalog' },
32
+ { label: 'My requests', icon: 'inbox', to: 'requests' },
33
+ ],
34
+ },
35
+ },
36
+ ],
37
+ },
38
+ ],
39
+ menus: [
40
+ {
41
+ key: 'primary',
42
+ name: 'Primary',
43
+ items: [{ panel: 'get-help', label: 'Get help', icon: 'life-buoy', order: 900 }],
44
+ },
45
+ ],
46
+ };
@@ -0,0 +1,16 @@
1
+ # A theme: theme.json, tokens.json and theme.css
2
+
3
+ ## Files (`themes/<key>/`)
4
+
5
+ - `theme.json`: `key`, `name`, `source: "custom"`, `order`, `active`, `description`.
6
+ - `tokens.json`: `{ "light": { … }, "dark": { … } }`, token names without the leading `--` (OKLCH colors, fonts,
7
+ radius). Generated here with `rpf themes generate --color "#0f766e" --tint tinted --radius 0.75rem --out …`, which
8
+ also checks contrast; re-check after hand edits with `rpf themes generate --from-css themes/<key>/tokens.json`.
9
+ - `theme.css`: optional portal-wide base CSS (links, selection), loaded first. Never component styling.
10
+
11
+ ## Using it
12
+
13
+ Put the folder in a workspace and set `theme: 'teal-harbor'` in portal.mjs; the push creates the theme. Components
14
+ read tokens as Tailwind utilities (`bg-card`, `text-primary`) or raw variables (`var(--card)`).
15
+
16
+ The `react-portal-theme` skill covers the whole workflow (brand colors, fonts, contrast).
@@ -0,0 +1,11 @@
1
+ /*
2
+ * Portal-wide base CSS for the Teal Harbor theme, loaded before everything else. Only base elements (body text,
3
+ * links, selection): component styling belongs in components. Tokens are var(--primary) etc.; there are no
4
+ * --color-* variables at runtime.
5
+ */
6
+ a {
7
+ text-underline-offset: 0.2em;
8
+ }
9
+ ::selection {
10
+ background: color-mix(in oklch, var(--primary) 25%, transparent);
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "key": "teal-harbor",
3
+ "name": "Teal Harbor",
4
+ "source": "custom",
5
+ "order": 100,
6
+ "active": true,
7
+ "description": "A calm teal theme with tinted neutrals, light and dark"
8
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "light": {
3
+ "background": "oklch(0.99 0.00458 186.391)",
4
+ "foreground": "oklch(0.2 0.02016 186.391)",
5
+ "card": "oklch(1 0 0)",
6
+ "card-foreground": "oklch(0.2 0.02016 186.391)",
7
+ "popover": "oklch(1 0 0)",
8
+ "popover-foreground": "oklch(0.2 0.02016 186.391)",
9
+ "primary": "oklch(0.51094 0.08606 186.391)",
10
+ "primary-foreground": "oklch(0.985 0 0)",
11
+ "secondary": "oklch(0.955 0.01374 186.391)",
12
+ "secondary-foreground": "oklch(0.25 0.02291 186.391)",
13
+ "muted": "oklch(0.96 0.011 186.391)",
14
+ "muted-foreground": "oklch(0.5 0.02749 186.391)",
15
+ "accent": "oklch(0.945 0.01893 186.391)",
16
+ "accent-foreground": "oklch(0.28 0.05163 186.391)",
17
+ "destructive": "oklch(0.577 0.215 27.3)",
18
+ "destructive-foreground": "oklch(0.985 0 0)",
19
+ "border": "oklch(0.9 0.01374 186.391)",
20
+ "input": "oklch(0.66069 0.01374 186.391)",
21
+ "ring": "oklch(0.51094 0.08606 186.391)",
22
+ "sidebar": "oklch(0.975 0.00916 186.391)",
23
+ "sidebar-foreground": "oklch(0.25 0.02291 186.391)",
24
+ "sidebar-primary": "oklch(0.51094 0.08606 186.391)",
25
+ "sidebar-primary-foreground": "oklch(0.985 0 0)",
26
+ "sidebar-accent": "oklch(0.93 0.01721 186.391)",
27
+ "sidebar-accent-foreground": "oklch(0.22 0.04303 186.391)",
28
+ "sidebar-border": "oklch(0.9 0.01374 186.391)",
29
+ "sidebar-ring": "oklch(0.51094 0.08606 186.391)",
30
+ "radius": "0.75rem",
31
+ "font-sans": "Inter, ui-sans-serif, system-ui, sans-serif",
32
+ "chart-1": "oklch(0.62 0.08606 186.391)",
33
+ "chart-2": "oklch(0.62 0.07315 231.391)",
34
+ "chart-3": "oklch(0.62 0.08606 281.391)",
35
+ "chart-4": "oklch(0.62 0.07315 346.391)",
36
+ "chart-5": "oklch(0.62 0.08606 46.391)"
37
+ },
38
+ "dark": {
39
+ "background": "oklch(0.16 0.01374 186.391)",
40
+ "foreground": "oklch(0.96 0.00916 186.391)",
41
+ "card": "oklch(0.2 0.01649 186.391)",
42
+ "card-foreground": "oklch(0.96 0.00916 186.391)",
43
+ "popover": "oklch(0.21 0.01649 186.391)",
44
+ "popover-foreground": "oklch(0.96 0.00916 186.391)",
45
+ "primary": "oklch(0.71094 0.07745 186.391)",
46
+ "primary-foreground": "oklch(0.17 0.01833 186.391)",
47
+ "secondary": "oklch(0.27 0.01833 186.391)",
48
+ "secondary-foreground": "oklch(0.96 0.00916 186.391)",
49
+ "muted": "oklch(0.26 0.01833 186.391)",
50
+ "muted-foreground": "oklch(0.72 0.02749 186.391)",
51
+ "accent": "oklch(0.3 0.02582 186.391)",
52
+ "accent-foreground": "oklch(0.96 0.00916 186.391)",
53
+ "destructive": "oklch(0.68 0.19 24)",
54
+ "destructive-foreground": "oklch(0.17 0 0)",
55
+ "border": "oklch(1 0 0 / 0.12)",
56
+ "input": "oklch(0.4813 0.01374 186.391)",
57
+ "ring": "oklch(0.71094 0.07745 186.391)",
58
+ "sidebar": "oklch(0.14 0.01374 186.391)",
59
+ "sidebar-foreground": "oklch(0.94 0.00916 186.391)",
60
+ "sidebar-primary": "oklch(0.71094 0.07745 186.391)",
61
+ "sidebar-primary-foreground": "oklch(0.17 0.01833 186.391)",
62
+ "sidebar-accent": "oklch(1 0 0 / 0.07)",
63
+ "sidebar-accent-foreground": "oklch(0.96 0.00916 186.391)",
64
+ "sidebar-border": "oklch(1 0 0 / 0.1)",
65
+ "sidebar-ring": "oklch(0.71094 0.07745 186.391)",
66
+ "chart-1": "oklch(0.72 0.07745 186.391)",
67
+ "chart-2": "oklch(0.72 0.06884 231.391)",
68
+ "chart-3": "oklch(0.72 0.07745 281.391)",
69
+ "chart-4": "oklch(0.72 0.06884 346.391)",
70
+ "chart-5": "oklch(0.72 0.07745 46.391)"
71
+ }
72
+ }
@@ -0,0 +1,25 @@
1
+ # Widget options: schema, defaults and the options prop
2
+
3
+ A widget with no server script whose behavior is entirely placement options.
4
+
5
+ ## Files
6
+
7
+ - `options.schema.json`: JSON Schema that drives the page designer's form. Shown here: a plain string, a textarea
8
+ (`format: "textarea"`), an enum with quick-value buttons (`x-presets`), a color that becomes a CSS variable on the
9
+ placement (`format: "color"` + `x-css-var`), and a boolean.
10
+ - `component.json` `defaults`: the default options object. Effective options are the defaults overlaid (shallowly) by
11
+ the placement's `options`.
12
+ - `main.tsx`: reads `options` from its props. No `serverMode`, so no server script runs.
13
+
14
+ ## In portal.mjs
15
+
16
+ ```js
17
+ { key: 'maintenance', c: 'example/notice-banner', order: 50, options: { tone: 'warning', dismissible: true } }
18
+ ```
19
+
20
+ ## Notes
21
+
22
+ - Write full Tailwind class names (`TONES` maps a tone to its classes); a class built at runtime (`'bg-' + tone`) is
23
+ invisible to the compiler.
24
+ - Anything that grants authority (a table, a query) should be `"x-embed": "server"` so only a parent's server script
25
+ can set it.
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "Notice banner",
3
+ "kind": "widget",
4
+ "description": "A notice whose text, tone, icon, accent color, link and dismiss button are placement options",
5
+ "placeable": true,
6
+ "tailwind": true,
7
+ "defaults": {
8
+ "title": "Heads up",
9
+ "message": "Scheduled maintenance this Saturday from 08:00 to 10:00.",
10
+ "tone": "info",
11
+ "icon": "info",
12
+ "dismissible": false
13
+ }
14
+ }
@@ -0,0 +1,60 @@
1
+ import { useState } from 'react';
2
+ import { Link } from '@portal/runtime';
3
+ import { Button } from 'components:button';
4
+ import { Icon } from 'components:icon';
5
+
6
+ type Tone = 'info' | 'success' | 'warning';
7
+ type Options = {
8
+ title?: string;
9
+ message?: string;
10
+ tone?: Tone;
11
+ icon?: string;
12
+ linkLabel?: string;
13
+ linkPage?: string;
14
+ dismissible?: boolean;
15
+ };
16
+
17
+ /** Tailwind classes per tone: full class names, since classes built at runtime are invisible to the compiler. */
18
+ const TONES: Record<Tone, string> = {
19
+ info: 'border-info/40 bg-info/5',
20
+ success: 'border-success/40 bg-success/5',
21
+ warning: 'border-warning/40 bg-warning/5',
22
+ };
23
+
24
+ /**
25
+ * components:example/notice-banner: a notice whose text, tone, icon, link and dismiss button all come from options.
26
+ *
27
+ * Effective options = component.json `defaults` overlaid by the placement's `options` (shallow), so every field has
28
+ * a value even on a fresh placement. The accent color is a CSS variable the placement sets (`x-css-var` in
29
+ * options.schema.json), read here with a fallback to the theme's primary.
30
+ */
31
+ export default function NoticeBanner({ options = {} }: { options?: Options }) {
32
+ const [hidden, setHidden] = useState(false);
33
+ if (hidden) return null;
34
+ const tone: Tone = options.tone && TONES[options.tone] ? options.tone : 'info';
35
+ return (
36
+ <div
37
+ className={'flex items-start gap-3 rounded-lg border p-4 ' + TONES[tone]}
38
+ style={{ borderLeft: '4px solid var(--example-notice-accent, var(--primary))' }}
39
+ role="status"
40
+ >
41
+ {options.icon ? <Icon name={options.icon} className="mt-0.5 size-5 shrink-0" /> : null}
42
+ <div className="min-w-0 flex-1">
43
+ {options.title ? <p className="font-medium">{options.title}</p> : null}
44
+ {options.message ? (
45
+ <p className="whitespace-pre-line text-sm text-muted-foreground">{options.message}</p>
46
+ ) : null}
47
+ {options.linkPage ? (
48
+ <Link page={options.linkPage} className="mt-2 inline-block text-sm font-medium underline">
49
+ {options.linkLabel || 'Learn more'}
50
+ </Link>
51
+ ) : null}
52
+ </div>
53
+ {options.dismissible ? (
54
+ <Button size="icon-sm" variant="ghost" aria-label="Dismiss" onClick={() => setHidden(true)}>
55
+ <Icon name="x" />
56
+ </Button>
57
+ ) : null}
58
+ </div>
59
+ );
60
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "title": { "type": "string", "title": "Title" },
5
+ "message": { "type": "string", "title": "Message", "format": "textarea" },
6
+ "tone": {
7
+ "type": "string",
8
+ "title": "Tone",
9
+ "enum": ["info", "success", "warning"],
10
+ "default": "info",
11
+ "x-presets": ["info", "success", "warning"]
12
+ },
13
+ "icon": { "type": "string", "title": "Icon (Lucide name)", "default": "info" },
14
+ "accent": {
15
+ "type": "string",
16
+ "title": "Accent color",
17
+ "format": "color",
18
+ "x-css-var": "--example-notice-accent"
19
+ },
20
+ "linkLabel": { "type": "string", "title": "Link label" },
21
+ "linkPage": { "type": "string", "title": "Link to page (route)" },
22
+ "dismissible": { "type": "boolean", "title": "Can be dismissed", "default": false }
23
+ }
24
+ }