@simpleplatform/ui-kit 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +488 -2
- package/custom-elements.json +24 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/status-badge.d.ts +4 -0
- package/dist/contracts/status-badge.d.ts.map +1 -0
- package/dist/contracts/status-badge.js +8 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +1 -0
- package/dist/elements/status-badge.d.ts +19 -0
- package/dist/elements/status-badge.d.ts.map +1 -0
- package/dist/elements/status-badge.js +123 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/mount-boundary.d.ts +13 -0
- package/dist/react/mount-boundary.d.ts.map +1 -0
- package/dist/react/mount-boundary.js +70 -0
- package/dist/react/record-activity.d.ts +11 -0
- package/dist/react/record-activity.d.ts.map +1 -0
- package/dist/react/record-activity.js +144 -0
- package/dist/react/record-bridge.d.ts +34 -0
- package/dist/react/record-bridge.d.ts.map +1 -0
- package/dist/react/record-bridge.js +8 -0
- package/dist/react/record-form.d.ts +11 -0
- package/dist/react/record-form.d.ts.map +1 -0
- package/dist/react/record-form.js +112 -0
- package/dist/react/status-badge.d.ts +15 -0
- package/dist/react/status-badge.d.ts.map +1 -0
- package/dist/react/status-badge.js +6 -0
- package/dist/runtime.d.ts +22 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +46 -0
- package/package.json +59 -3
- package/theme.css +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,489 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Simple UI Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@simpleplatform/ui-kit` provides supported, consistent UI for Simple Spaces.
|
|
4
|
+
It is deliberately small: use a managed component when Simple owns the
|
|
5
|
+
workflow; use the Space SDK directly when you need to own the UI yourself.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
This package is in alpha. `StatusBadge` is the current simple component.
|
|
10
|
+
Managed `RecordForm` and `RecordActivity` are pre-release interfaces and still require deployed
|
|
11
|
+
browser-parity approval. Record-header actions are exposed by the companion
|
|
12
|
+
Space SDK as `simple.ui.header`; they are not a UI Kit export.
|
|
13
|
+
Do not treat alpha APIs as a stable compatibility promise until they are
|
|
14
|
+
released with an explicit support policy.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @simpleplatform/ui-kit @simpleplatform/sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The kit needs version 3 of `@simpleplatform/sdk`, and React 18.3 or 19 for its
|
|
23
|
+
React bridges. Its peer range also accepts `0.0.0`, the number the SDK carries
|
|
24
|
+
inside this repository, so a Space that links both packages by folder path
|
|
25
|
+
installs without a warning.
|
|
26
|
+
|
|
27
|
+
Releases are tagged `v<version>-kit`. The package is below 1.0: a breaking
|
|
28
|
+
change raises the minor, and the default range `^0.1.0` never moves onto `0.2`
|
|
29
|
+
by itself.
|
|
30
|
+
|
|
31
|
+
## Current component: StatusBadge
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { StatusBadge } from '@simpleplatform/ui-kit/react'
|
|
35
|
+
import '@simpleplatform/ui-kit/theme.css'
|
|
36
|
+
|
|
37
|
+
export function DeploymentState() {
|
|
38
|
+
return <StatusBadge label="Ready" tone="success" />
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Required | Purpose |
|
|
43
|
+
| ------------- | ----------------------- | -------- | --------------------------------------------------------------------- |
|
|
44
|
+
| `label` | `string` | Yes | Visible status text. |
|
|
45
|
+
| `tone` | `SimpleStatusBadgeTone` | Yes | Semantic color: `neutral`, `info`, `success`, `warning`, or `danger`. |
|
|
46
|
+
| `description` | `string` | No | Additional context for assistive technology. |
|
|
47
|
+
|
|
48
|
+
Import the exported contract instead of maintaining a duplicate tone union:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import type { SimpleStatusBadgeTone } from '@simpleplatform/ui-kit/contracts'
|
|
52
|
+
import { SIMPLE_STATUS_BADGE_TONES } from '@simpleplatform/ui-kit/contracts'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Both exports are also available from the package root, `@simpleplatform/ui-kit`.
|
|
56
|
+
|
|
57
|
+
`StatusBadge` is a React bridge for the canonical
|
|
58
|
+
`<simple-status-badge>` Web Component. UI Kit components receive explicit
|
|
59
|
+
props; the package provides no React provider or implicit SDK client.
|
|
60
|
+
|
|
61
|
+
The Web Component can also be used without React. Import the `elements`
|
|
62
|
+
entry once before using its tag in HTML:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import '@simpleplatform/ui-kit/elements'
|
|
66
|
+
import '@simpleplatform/ui-kit/theme.css'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<simple-status-badge label="Ready" tone="success"></simple-status-badge>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Import `theme.css` in the Space entry point. It bundles the Geist font files
|
|
74
|
+
with the Space (so they load inside its cross-origin iframe) and provides
|
|
75
|
+
`StatusBadge` defaults that use the platform's own light and dark colors and
|
|
76
|
+
dimensions. The neutral tone follows the Space's `--secondary`, `--border`, and
|
|
77
|
+
`--secondary-foreground` tokens when defined (as HSL triplets, the platform's
|
|
78
|
+
convention), with fallback colors otherwise. A Space may override any
|
|
79
|
+
`--simple-status-badge-*` variable in its own CSS, and may override the default
|
|
80
|
+
font stack as well. These names stay component-local: the platform-wide semantic
|
|
81
|
+
CSS-variable contract is a separate project.
|
|
82
|
+
|
|
83
|
+
### Runtime boundary
|
|
84
|
+
|
|
85
|
+
The Simple host supplies the exact UI Runtime to the managed component bridge
|
|
86
|
+
during the Space handshake. `<RecordForm />` and `<RecordActivity />` load it automatically; the runtime
|
|
87
|
+
loader and URL are private implementation details, not supported Space APIs.
|
|
88
|
+
Space authors should never choose or hard-code a runtime URL.
|
|
89
|
+
|
|
90
|
+
The UI Kit reads host metadata and authorized callbacks from SDK-created record
|
|
91
|
+
handles through a versioned symbol. Space authors use the `RecordForm` and
|
|
92
|
+
`RecordActivity` components; there is no managed UI adapter package entry point.
|
|
93
|
+
|
|
94
|
+
### Framework support
|
|
95
|
+
|
|
96
|
+
The managed `RecordForm` and `RecordActivity` exports are currently available only from
|
|
97
|
+
`@simpleplatform/ui-kit/react`. Simple's renderer itself runs inside the Space
|
|
98
|
+
iframe, so React is not an architectural requirement for customer Spaces; the
|
|
99
|
+
current limitation is that a public framework-neutral form or activity element has not
|
|
100
|
+
been shipped. The private runtime elements are not supported HTML APIs.
|
|
101
|
+
|
|
102
|
+
The intended direction is to expose a public element from
|
|
103
|
+
`@simpleplatform/ui-kit/elements` and make the React component a thin adapter
|
|
104
|
+
over it. Vue, Svelte, or plain JavaScript could then pass a `RecordHandle` as an
|
|
105
|
+
element property and use the same managed form. Until that element has a
|
|
106
|
+
documented lifecycle, property, error, loading, and cleanup contract, non-React
|
|
107
|
+
Spaces can use `@simpleplatform/sdk/space` to build custom controls with
|
|
108
|
+
`simple.records.current()` or `simple.records.open()`. The managed `RecordForm`
|
|
109
|
+
itself remains available only through the React entry point.
|
|
110
|
+
|
|
111
|
+
## RecordForm
|
|
112
|
+
|
|
113
|
+
`RecordForm` is the default choice for a Record Space that wants the complete
|
|
114
|
+
Simple record experience without rebuilding it.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import type { RecordHandle } from '@simpleplatform/sdk/space'
|
|
118
|
+
import { connect } from '@simpleplatform/sdk/space'
|
|
119
|
+
import { RecordForm } from '@simpleplatform/ui-kit/react'
|
|
120
|
+
import { useEffect, useState } from 'react'
|
|
121
|
+
import '@simpleplatform/ui-kit/theme.css'
|
|
122
|
+
|
|
123
|
+
const client = connect({ targetOrigin: new URL(document.referrer).origin })
|
|
124
|
+
|
|
125
|
+
export function App() {
|
|
126
|
+
const [record, setRecord] = useState<RecordHandle | null>(null)
|
|
127
|
+
const [error, setError] = useState<Error | null>(null)
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
let active = true
|
|
131
|
+
void client
|
|
132
|
+
.then(simple => simple.records.current())
|
|
133
|
+
.then((value) => {
|
|
134
|
+
if (active)
|
|
135
|
+
setRecord(value)
|
|
136
|
+
})
|
|
137
|
+
.catch((reason: unknown) => {
|
|
138
|
+
if (active)
|
|
139
|
+
setError(reason instanceof Error ? reason : new Error('Could not load the record.'))
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
return () => {
|
|
143
|
+
active = false
|
|
144
|
+
}
|
|
145
|
+
}, [])
|
|
146
|
+
|
|
147
|
+
if (error)
|
|
148
|
+
return <p role="alert">{error.message}</p>
|
|
149
|
+
|
|
150
|
+
if (!record) {
|
|
151
|
+
return <p>Loading record…</p>
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return <RecordForm record={record} />
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The component mounts the same private React form renderer and field editors
|
|
159
|
+
used by Simple's standard record page inside the Space iframe. It includes:
|
|
160
|
+
|
|
161
|
+
- field layout, labels, help text, and required/read-only/visibility behavior;
|
|
162
|
+
- Record Behavior feedback and server validation messages;
|
|
163
|
+
- the platform's supported primitive and specialized field workflows,
|
|
164
|
+
including references, documents, secrets, enums, date/time, and JSON; and
|
|
165
|
+
- accessible labels, validation messages, and pending states.
|
|
166
|
+
|
|
167
|
+
The form also refreshes when the same `record` handle completes an
|
|
168
|
+
`update()` or `submit()` command elsewhere in the Space, including from a
|
|
169
|
+
`simple.ui.header` action. Live server subscriptions are still deferred; the
|
|
170
|
+
form renders its initial snapshot and snapshots produced by commands.
|
|
171
|
+
|
|
172
|
+
The platform remains the source of truth. `RecordForm` does not execute Record
|
|
173
|
+
Behaviors or persist records directly; it renders the managed record session
|
|
174
|
+
and calls the existing record commands. It accepts both the route-owned handle
|
|
175
|
+
from `simple.records.current()` and an opened handle from `simple.records.open()`.
|
|
176
|
+
An opened record session stays available until the Space connection ends, even
|
|
177
|
+
if its `RecordForm` is unmounted earlier. Simple's field implementations are
|
|
178
|
+
not published as customer extension points. The browser runtime is
|
|
179
|
+
inspectable, however; authorization and privileged operations must always be
|
|
180
|
+
enforced by the host/server, not by keeping client implementation hidden.
|
|
181
|
+
|
|
182
|
+
The private stylesheet and Radix overlays are contained inside the managed
|
|
183
|
+
form's Shadow DOM; the Space's theme custom properties can still inherit. The
|
|
184
|
+
platform and Space use the same field renderer through different adapters.
|
|
185
|
+
|
|
186
|
+
This integration is pre-release. Automated tests cover the private renderer,
|
|
187
|
+
field workflows, and bridge, but release still requires a deployed browser
|
|
188
|
+
comparison with the standard form and explicit approval. Do not treat this
|
|
189
|
+
documentation as confirmation of browser parity.
|
|
190
|
+
|
|
191
|
+
### What RecordForm does not expose
|
|
192
|
+
|
|
193
|
+
`RecordForm` is not a schema-driven form framework. The following stay inside
|
|
194
|
+
Simple and are not supported extension APIs:
|
|
195
|
+
|
|
196
|
+
- form schema and field metadata transport;
|
|
197
|
+
- field editor registry or per-field renderer replacement;
|
|
198
|
+
- RecordForm's document attachment/promotion lifecycle, reference search,
|
|
199
|
+
secret decryption, and JSON-editor internals. Document upload and promotion
|
|
200
|
+
are handled by the managed form's private host adapter; a standalone file
|
|
201
|
+
staging API is not currently exposed to Spaces.
|
|
202
|
+
- Record Behavior scheduling and host session events.
|
|
203
|
+
|
|
204
|
+
This boundary lets Simple improve complex field workflows without requiring
|
|
205
|
+
customer Spaces to track internal form contracts.
|
|
206
|
+
|
|
207
|
+
## RecordActivity
|
|
208
|
+
|
|
209
|
+
`RecordActivity` is the managed component for displaying the platform activity
|
|
210
|
+
stream (audit log changes and notes) for a record handle.
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import type { RecordHandle } from '@simpleplatform/sdk/space'
|
|
214
|
+
import { connect } from '@simpleplatform/sdk/space'
|
|
215
|
+
import { RecordActivity } from '@simpleplatform/ui-kit/react'
|
|
216
|
+
import { useEffect, useState } from 'react'
|
|
217
|
+
import '@simpleplatform/ui-kit/theme.css'
|
|
218
|
+
|
|
219
|
+
const client = connect({ targetOrigin: new URL(document.referrer).origin })
|
|
220
|
+
|
|
221
|
+
export function ActivityView() {
|
|
222
|
+
const [record, setRecord] = useState<RecordHandle | null>(null)
|
|
223
|
+
const [error, setError] = useState<Error | null>(null)
|
|
224
|
+
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
let active = true
|
|
227
|
+
void client
|
|
228
|
+
.then(simple => simple.record())
|
|
229
|
+
.then((value) => {
|
|
230
|
+
if (active)
|
|
231
|
+
setRecord(value)
|
|
232
|
+
})
|
|
233
|
+
.catch((reason: unknown) => {
|
|
234
|
+
if (active)
|
|
235
|
+
setError(reason instanceof Error ? reason : new Error('Could not load the record.'))
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
return () => {
|
|
239
|
+
active = false
|
|
240
|
+
}
|
|
241
|
+
}, [])
|
|
242
|
+
|
|
243
|
+
if (error)
|
|
244
|
+
return <p role="alert">{error.message}</p>
|
|
245
|
+
|
|
246
|
+
if (!record) {
|
|
247
|
+
return <p>Loading record…</p>
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return <RecordActivity record={record} />
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
| Prop | Type | Required | Purpose |
|
|
255
|
+
| -------- | -------------- | -------- | ------------------------------------------------------------------ |
|
|
256
|
+
| `record` | `RecordHandle` | Yes | A record handle from `simple.record()` or `simple.records.open()`. |
|
|
257
|
+
|
|
258
|
+
### Supported context and behavior
|
|
259
|
+
|
|
260
|
+
`RecordActivity` accepts the route record in a Record Space or an opened record
|
|
261
|
+
in a Record or standalone Space. The private record UI bridge supplies the target
|
|
262
|
+
application ID, table ID, record ID, and fields. When rendered without this
|
|
263
|
+
bridge or required identity metadata, it renders an accessible error alert with
|
|
264
|
+
a retry action. Metadata refreshes update the mounted activity element in place
|
|
265
|
+
so a note draft and the feed's pagination state are preserved.
|
|
266
|
+
|
|
267
|
+
The managed activity stream provides:
|
|
268
|
+
|
|
269
|
+
- **Audit changes**: Detailed change history for record fields, formatted with
|
|
270
|
+
field display names and human-readable diffs.
|
|
271
|
+
- **Notes**: Chronological view of collaborator notes with author information
|
|
272
|
+
and timestamps, plus note composer functionality to submit new notes.
|
|
273
|
+
- **Show more pagination**: Incremental loading of older audit events and notes
|
|
274
|
+
as users request more history.
|
|
275
|
+
- **Loading and failures**: The activity panel shows skeleton rows while its
|
|
276
|
+
initial queries load. Runtime setup errors render an accessible alert with a
|
|
277
|
+
"Try again" action. Activity query failures show the panel's inline error
|
|
278
|
+
message; that state currently has no separate retry control.
|
|
279
|
+
|
|
280
|
+
### Runtime boundary
|
|
281
|
+
|
|
282
|
+
Like `RecordForm`, `RecordActivity` mounts the canonical `<simple-record-activity>`
|
|
283
|
+
Web Component from the host-supplied Simple UI Runtime inside the Space iframe.
|
|
284
|
+
It receives `applicationId`, `tableId`, `recordId`, `fields`, `graphql`, and the
|
|
285
|
+
existing optional decrypt capability from the private record UI bridge. The
|
|
286
|
+
runtime descriptor, loader, and underlying GraphQL operations are
|
|
287
|
+
private implementation details and not customer extension points. This integration
|
|
288
|
+
is pre-release and subject to deployed browser-parity approval.
|
|
289
|
+
|
|
290
|
+
## Build a custom form instead
|
|
291
|
+
|
|
292
|
+
Use the Space SDK when a managed form is not the right presentation. You own
|
|
293
|
+
the markup, controls, and local UI state; the platform still owns behavior
|
|
294
|
+
execution, validation, authorization, and persistence.
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
const record = await simple.records.current()
|
|
298
|
+
|
|
299
|
+
await record.update({ status: 'active' })
|
|
300
|
+
|
|
301
|
+
const result = await record.submit()
|
|
302
|
+
if (!result.ok) {
|
|
303
|
+
const snapshot = record.snapshot()
|
|
304
|
+
console.log(snapshot.formInfo)
|
|
305
|
+
console.log(snapshot.errors.form)
|
|
306
|
+
console.log(snapshot.errors.fields)
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Use `record.update()` and `record.submit()` for the route record. Do not use
|
|
311
|
+
`simple.data.mutate()` to bypass its record workflow.
|
|
312
|
+
|
|
313
|
+
## Customize the Record Space header
|
|
314
|
+
|
|
315
|
+
A Record Space can replace persisted System **View Actions** in the platform
|
|
316
|
+
header while it is mounted.
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
simple.ui.header.actions.set([
|
|
320
|
+
{
|
|
321
|
+
icon: 'phone',
|
|
322
|
+
id: 'start-call',
|
|
323
|
+
label: 'Start call',
|
|
324
|
+
onClick: async () => {
|
|
325
|
+
await startCall()
|
|
326
|
+
},
|
|
327
|
+
type: 'primary',
|
|
328
|
+
},
|
|
329
|
+
])
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
`actions.set()` accepts actions in display order. Each action has:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
interface HeaderAction {
|
|
336
|
+
id: string
|
|
337
|
+
label: string
|
|
338
|
+
icon?: string
|
|
339
|
+
type?: 'primary' | 'secondary' | 'outline' | 'destructive'
|
|
340
|
+
disabled?: boolean
|
|
341
|
+
loading?: boolean
|
|
342
|
+
onClick: () => void | Promise<void>
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
The platform renders the buttons; the callback remains inside the Space. A
|
|
347
|
+
promise-returning callback automatically shows loading and disables that
|
|
348
|
+
button until it settles. Use `loading` and `disabled` when the action reflects
|
|
349
|
+
work that started outside the click handler.
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
simple.ui.header.actions.set([
|
|
354
|
+
{
|
|
355
|
+
disabled: syncing,
|
|
356
|
+
id: 'sync',
|
|
357
|
+
label: syncing ? 'Syncing…' : 'Sync now',
|
|
358
|
+
loading: syncing,
|
|
359
|
+
onClick: syncNow,
|
|
360
|
+
type: 'secondary',
|
|
361
|
+
},
|
|
362
|
+
])
|
|
363
|
+
}, [simple, syncing])
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Calling `actions.set([])` intentionally renders no main actions. While a custom
|
|
367
|
+
Record Space is active, `actions.set()` completely replaces the platform
|
|
368
|
+
`Update` button and persisted View Actions; the platform does not guess whether
|
|
369
|
+
your Space contains a form. The default actions return when the Space iframe
|
|
370
|
+
unloads or the user selects the standard view.
|
|
371
|
+
There is no `clearActions()` API.
|
|
372
|
+
|
|
373
|
+
The override does not take over platform-owned overflow controls such as
|
|
374
|
+
Delete, view recovery, or navigation. If a Space needs a save workflow, expose
|
|
375
|
+
it explicitly and call the record-level `record.submit()` command:
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
simple.ui.header.actions.set([
|
|
379
|
+
{
|
|
380
|
+
id: 'save-and-start-call',
|
|
381
|
+
label: 'Save and start call',
|
|
382
|
+
onClick: async () => {
|
|
383
|
+
const result = await record.submit()
|
|
384
|
+
if (!result.ok) {
|
|
385
|
+
simple.ui.toast.show({
|
|
386
|
+
description: 'Correct the validation messages in the form before saving again.',
|
|
387
|
+
title: 'Validation Error',
|
|
388
|
+
variant: 'destructive',
|
|
389
|
+
})
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
simple.ui.toast.show({
|
|
394
|
+
description: 'The record was updated successfully.',
|
|
395
|
+
title: 'Record updated',
|
|
396
|
+
})
|
|
397
|
+
await startCall()
|
|
398
|
+
},
|
|
399
|
+
type: 'primary',
|
|
400
|
+
},
|
|
401
|
+
])
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Expected record validation failures return `{ ok: false }`; they are rendered
|
|
405
|
+
by `RecordForm` or available from `record.snapshot()`. Unexpected rejected
|
|
406
|
+
header callbacks are reported to the developer console only; there is no
|
|
407
|
+
automatic toast, modal, or button error presentation. Catch failures and call
|
|
408
|
+
`simple.ui.toast.show()` when the Space should provide user-facing feedback.
|
|
409
|
+
`record.submit()` stays headless, and inline field/form messages remain the
|
|
410
|
+
source of detailed validation guidance.
|
|
411
|
+
|
|
412
|
+
## Record Space tabs
|
|
413
|
+
|
|
414
|
+
A Record Space can declare tabs in the platform header:
|
|
415
|
+
|
|
416
|
+
```tsx
|
|
417
|
+
import { useEffect, useState } from 'react'
|
|
418
|
+
|
|
419
|
+
export function MyRecordSpace({ simple }) {
|
|
420
|
+
const [activeTab, setActiveTab] = useState<string | null>(null)
|
|
421
|
+
|
|
422
|
+
useEffect(() => {
|
|
423
|
+
let mounted = true
|
|
424
|
+
|
|
425
|
+
simple.ui.tabs.set({
|
|
426
|
+
onChange: (tabId) => {
|
|
427
|
+
if (mounted)
|
|
428
|
+
setActiveTab(tabId)
|
|
429
|
+
},
|
|
430
|
+
tabs: [
|
|
431
|
+
{ default: true, icon: 'layout-dashboard', id: 'overview', title: 'Overview' },
|
|
432
|
+
{ badge: 2, icon: 'history', id: 'timeline', title: 'Timeline' },
|
|
433
|
+
{ badge: 'Beta', icon: 'settings', id: 'settings', title: 'Settings' },
|
|
434
|
+
],
|
|
435
|
+
}).then(({ selectedTabId }) => {
|
|
436
|
+
if (mounted)
|
|
437
|
+
setActiveTab(selectedTabId)
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
return () => {
|
|
441
|
+
mounted = false
|
|
442
|
+
}
|
|
443
|
+
}, [simple])
|
|
444
|
+
|
|
445
|
+
return <div>{activeTab === 'overview' ? <OverviewView /> : <OtherView />}</div>
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Tabs declaration accepts up to 32 tabs and requires an `onChange` callback. An
|
|
450
|
+
empty declaration clears the current tab strip and returns `selectedTabId: null`.
|
|
451
|
+
Each tab requires an `id` (matching `^[a-z0-9][a-z0-9_-]{0,63}$`) and a non-blank `title`
|
|
452
|
+
(up to 80 characters), and accepts optional `default: true`, kebab-case Lucide
|
|
453
|
+
`icon`, and a string (up to 20 characters) or finite non-negative integer `badge`.
|
|
454
|
+
If no tab sets `default: true`, the first tab defaults to active.
|
|
455
|
+
|
|
456
|
+
Programmatic selection uses `simple.ui.tabs.select(tabId)`, which resolves only
|
|
457
|
+
after host acknowledgement:
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
await simple.ui.tabs.select('timeline')
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Selection and URL routing remain host-owned. Host selection events use
|
|
464
|
+
`SPACE_UI_TABS_SELECTION_CHANGED` correlated by `registrationRequestId` and trigger
|
|
465
|
+
the iframe-local `onChange` callback. Calling `select()` with the currently active
|
|
466
|
+
tab resolves immediately without wire traffic; selecting an inactive tab reaches
|
|
467
|
+
the `onChange` callback once, deduplicating the response and event.
|
|
468
|
+
|
|
469
|
+
## Multiple records
|
|
470
|
+
|
|
471
|
+
The first release supports the route-owned primary record only. A future
|
|
472
|
+
secondary-record API will let a Space explicitly define a multi-record save
|
|
473
|
+
plan. `RecordForm` does not infer a save order from the forms on screen, and a
|
|
474
|
+
header action never silently submits every visible form.
|
|
475
|
+
|
|
476
|
+
For all-or-nothing multi-record workflows, use a server-side transactional
|
|
477
|
+
Action when that capability is available; sequential browser submits cannot
|
|
478
|
+
provide a transaction.
|
|
479
|
+
|
|
480
|
+
## Development
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
pnpm --filter @simpleplatform/ui-kit typecheck
|
|
484
|
+
pnpm --filter @simpleplatform/ui-kit test
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Every component release requires a public-contract test, accessibility
|
|
488
|
+
coverage, a packed-package consumer test, and a deployed SDK-built Space
|
|
489
|
+
fixture.
|