@chobantonov/jsonforms-react-antd-extended-renderers 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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -2
  3. package/lib/cells/asCell.d.ts +32 -0
  4. package/lib/components/AntdArrayFrame.d.ts +8 -0
  5. package/lib/components/AntdEditorButton.d.ts +10 -0
  6. package/lib/components/AntdEditorFrame.d.ts +3 -0
  7. package/lib/components/AntdEditorLoading.d.ts +8 -0
  8. package/lib/components/AntdEditorSurface.d.ts +7 -0
  9. package/lib/components/AntdMaskInput.d.ts +40 -0
  10. package/lib/components/PickerFormItem.d.ts +6 -0
  11. package/lib/hooks/useAntdEditorTheme.d.ts +8 -0
  12. package/lib/index.d.ts +45 -0
  13. package/lib/jsonforms-react-antd-extended.cjs.js +2 -0
  14. package/lib/jsonforms-react-antd-extended.cjs.js.map +1 -0
  15. package/lib/jsonforms-react-antd-extended.esm.js +906 -0
  16. package/lib/jsonforms-react-antd-extended.esm.js.map +1 -0
  17. package/lib/renderers/AntdAgGridControlRenderer.d.ts +2 -0
  18. package/lib/renderers/AntdButtonRenderer.d.ts +3 -0
  19. package/lib/renderers/AntdColorControlRenderer.d.ts +30 -0
  20. package/lib/renderers/AntdCronControlRenderer.d.ts +43 -0
  21. package/lib/renderers/AntdDurationControlRenderer.d.ts +5 -0
  22. package/lib/renderers/AntdMarkupLabelRenderer.d.ts +18 -0
  23. package/lib/renderers/AntdMaskControlRenderer.d.ts +9 -0
  24. package/lib/renderers/AntdMonacoControlRenderer.d.ts +1 -0
  25. package/lib/renderers/AntdNullControlRenderer.d.ts +5 -0
  26. package/lib/renderers/AntdSplitLayoutRenderer.d.ts +6 -0
  27. package/lib/renderers/index.d.ts +8 -0
  28. package/lib/util/colorFormat.d.ts +11 -0
  29. package/package.json +78 -3
  30. package/src/cells/asCell.tsx +47 -0
  31. package/src/components/AntdArrayFrame.tsx +69 -0
  32. package/src/components/AntdEditorButton.tsx +37 -0
  33. package/src/components/AntdEditorFrame.tsx +16 -0
  34. package/src/components/AntdEditorLoading.tsx +13 -0
  35. package/src/components/AntdEditorSurface.tsx +52 -0
  36. package/src/components/AntdMaskInput.tsx +95 -0
  37. package/src/components/PickerFormItem.tsx +23 -0
  38. package/src/hooks/useAntdEditorTheme.ts +63 -0
  39. package/src/index.tsx +166 -0
  40. package/src/renderers/AntdAgGridControlRenderer.tsx +56 -0
  41. package/src/renderers/AntdButtonRenderer.tsx +49 -0
  42. package/src/renderers/AntdColorControlRenderer.tsx +313 -0
  43. package/src/renderers/AntdCronControlRenderer.tsx +393 -0
  44. package/src/renderers/AntdDurationControlRenderer.tsx +274 -0
  45. package/src/renderers/AntdMarkupLabelRenderer.tsx +27 -0
  46. package/src/renderers/AntdMaskControlRenderer.tsx +19 -0
  47. package/src/renderers/AntdMonacoControlRenderer.tsx +21 -0
  48. package/src/renderers/AntdNullControlRenderer.tsx +70 -0
  49. package/src/renderers/AntdSplitLayoutRenderer.tsx +122 -0
  50. package/src/renderers/index.ts +8 -0
  51. package/src/util/colorFormat.ts +42 -0
@@ -0,0 +1,274 @@
1
+ import { PickerFormItem } from '../components/PickerFormItem';
2
+ import {
3
+ useExtendedTranslator,
4
+ useDurationControl,
5
+ durationComponentFields,
6
+ durationFieldMax,
7
+ } from '@chobantonov/jsonforms-react-extended-renderers';
8
+ import {
9
+ usePreTouchErrors,
10
+ useClearAffordance,
11
+ useI18n,
12
+ } from '@chobantonov/jsonforms-react-antd-renderers';
13
+ import ClockCircleOutlined from '@ant-design/icons/ClockCircleOutlined';
14
+ import {
15
+ and,
16
+ ControlProps,
17
+ formatIs,
18
+ isStringControl,
19
+ RankedTester,
20
+ rankWith,
21
+ } from '@jsonforms/core';
22
+ import { withJsonFormsControlProps } from '@jsonforms/react';
23
+ import {
24
+ Button,
25
+ Flex,
26
+ Input,
27
+ InputNumber,
28
+ Popover,
29
+ Segmented,
30
+ Select,
31
+ Space,
32
+ theme as antTheme,
33
+ } from 'antd';
34
+ import CloseOutlined from '@ant-design/icons/CloseOutlined';
35
+ import React from 'react';
36
+
37
+ export const antdDurationControlTester: RankedTester = rankWith(
38
+ 3,
39
+ and(isStringControl, formatIs('duration')),
40
+ );
41
+
42
+ /** Each picker component's translation key, so none is a bare English word. */
43
+ const fieldLabelKeys = {
44
+ weeks: 'duration.weeks',
45
+ years: 'duration.years',
46
+ months: 'duration.months',
47
+ days: 'duration.days',
48
+ hours: 'duration.hours',
49
+ minutes: 'duration.minutes',
50
+ seconds: 'duration.seconds',
51
+ } as const;
52
+
53
+ export const AntdDurationControl = (props: ControlProps) => {
54
+ const { token } = antTheme.useToken();
55
+ /*
56
+ See `usePreTouchErrors` in the base package: the filtered message, plus the
57
+ touch state it needs. Unchanged unless filtering is switched on.
58
+ */
59
+ const { errors: filteredErrors, onBlur: onBlurTouch } = usePreTouchErrors({
60
+ errors: props.errors,
61
+ path: props.path,
62
+ schema: props.schema,
63
+ uischema: props.uischema as any,
64
+ config: props.config,
65
+ });
66
+
67
+ const t = useExtendedTranslator();
68
+ const label = useI18n();
69
+ const state = useDurationControl(props);
70
+ const { open, draft: parts } = state;
71
+ // hooks run before the visibility guard
72
+ const { allowClear, affordanceProps } = useClearAffordance(
73
+ Boolean(state.value),
74
+ );
75
+ if (!props.visible) return null;
76
+ const value = state.value;
77
+ const localError = state.error;
78
+ /*
79
+ Only the units in play, and weeks as a mode rather than a row.
80
+
81
+ The previous picker drew all seven components, so "2 days, 3 hours" was two
82
+ useful rows among five zeros - and Weeks sat first, greyed, with nothing
83
+ saying that it cannot be combined with the others. Both are fixed here;
84
+ see `useDurationControl` for why weeks is a mode.
85
+ */
86
+ /*
87
+ The unit column's width, in characters, taken from the longest label the
88
+ panel can show rather than from the rows it happens to be showing: adding
89
+ or removing a unit must not resize the ones already on screen.
90
+ */
91
+ const unitColumn =
92
+ Math.max(
93
+ ...(state.mode === 'weeks'
94
+ ? ['weeks' as const]
95
+ : durationComponentFields
96
+ ).map((field) => label(fieldLabelKeys[field]).length),
97
+ ) + 2;
98
+ const picker = (
99
+ <Flex vertical gap='small' style={{ width: 300 }}>
100
+ <Segmented
101
+ block
102
+ size='small'
103
+ disabled={state.disabled}
104
+ value={state.mode}
105
+ onChange={(next) => state.setMode(next as 'weeks' | 'components')}
106
+ options={[
107
+ { value: 'components', label: label('duration.modeComponents') },
108
+ { value: 'weeks', label: label('duration.modeWeeks') },
109
+ ]}
110
+ />
111
+ {state.activeFields.map((field) => (
112
+ /*
113
+ A two-column grid, not a flex row. A flex item keeps its natural
114
+ width, which is why the number-and-unit group sat at about half the
115
+ panel while the add control below it ran the full width; a grid item
116
+ stretches, and the second column stays open whether or not a remove
117
+ button is drawn, so the rows line up with each other and with the
118
+ add control.
119
+ */
120
+ <div
121
+ key={field}
122
+ style={{
123
+ display: 'grid',
124
+ gridTemplateColumns: `1fr ${token.controlHeight}px`,
125
+ alignItems: 'center',
126
+ columnGap: token.paddingXXS,
127
+ }}
128
+ >
129
+ {/*
130
+ `Space.Compact` rather than the input's `addonAfter`: antd 6
131
+ deprecates the addon props on `InputNumber` in favour of this and
132
+ warns about them in development. It also renders the addon itself,
133
+ which is what lets the unit column below have a width.
134
+ */}
135
+ <Space.Compact block>
136
+ <InputNumber
137
+ style={{ flex: 1, minWidth: 0 }}
138
+ /*
139
+ Floored at zero and capped only at the exact-integer limit:
140
+ a duration's components are quantities, so `PT90M` and
141
+ `P400D` are ordinary values, not overflow.
142
+ */
143
+ min={0}
144
+ max={durationFieldMax}
145
+ disabled={state.disabled}
146
+ aria-label={label(fieldLabelKeys[field])}
147
+ onChange={(next) => state.changePart(field, Number(next ?? 0))}
148
+ value={parts[field]}
149
+ />
150
+ <Space.Addon
151
+ disabled={state.disabled}
152
+ style={{
153
+ /*
154
+ One width for every unit in the panel, measured from the
155
+ longest label rather than fixed in pixels: the labels are
156
+ translated, and "Minutes" and "Минути" are not the same
157
+ width. Sizing to the longest keeps every input box the same
158
+ size in every locale instead of leaving a ragged edge.
159
+ */
160
+ width: `${unitColumn}ch`,
161
+ justifyContent: 'center',
162
+ }}
163
+ >
164
+ {label(fieldLabelKeys[field])}
165
+ </Space.Addon>
166
+ </Space.Compact>
167
+ {state.mode === 'components' && state.activeFields.length > 1 ? (
168
+ <Button
169
+ size='small'
170
+ type='text'
171
+ disabled={state.disabled}
172
+ aria-label={label('duration.removeUnit', {
173
+ unit: label(fieldLabelKeys[field]),
174
+ })}
175
+ onClick={() => state.removeField(field)}
176
+ >
177
+ <CloseOutlined />
178
+ </Button>
179
+ ) : (
180
+ /* Holds the column open so a row without a button still aligns. */
181
+ <span aria-hidden='true' />
182
+ )}
183
+ </div>
184
+ ))}
185
+ {state.addableFields.length > 0 && (
186
+ <Select<(typeof state.addableFields)[number]>
187
+ size='small'
188
+ /* Stops where the inputs do: the button column plus its gap. */
189
+ style={{
190
+ width: `calc(100% - ${token.controlHeight + token.paddingXXS}px)`,
191
+ }}
192
+ value={undefined}
193
+ disabled={state.disabled}
194
+ placeholder={label('duration.addUnit')}
195
+ aria-label={label('duration.addUnit')}
196
+ onChange={(field) => state.addField(field)}
197
+ options={state.addableFields.map((field) => ({
198
+ value: field,
199
+ label: label(fieldLabelKeys[field]),
200
+ }))}
201
+ />
202
+ )}
203
+ {state.showActions && (
204
+ <Flex justify='end' gap='small'>
205
+ <Button onClick={() => state.close()}>
206
+ {/*
207
+ The temporal-action convention: an explicit label is translated
208
+ as a key first and used literally if it does not resolve.
209
+ */}
210
+ {state.options.cancelLabel
211
+ ? (t(state.options.cancelLabel) ?? state.options.cancelLabel)
212
+ : label('duration.cancel')}
213
+ </Button>
214
+ <Button
215
+ onClick={() => {
216
+ state.apply();
217
+ }}
218
+ type='primary'
219
+ >
220
+ {state.options.okLabel
221
+ ? (t(state.options.okLabel) ?? state.options.okLabel)
222
+ : label('duration.ok')}
223
+ </Button>
224
+ </Flex>
225
+ )}
226
+ </Flex>
227
+ );
228
+ return (
229
+ <PickerFormItem props={props} error={localError || filteredErrors}>
230
+ {/*
231
+ One field, like the color control: the ISO 8601 value stays editable as
232
+ text and the picker hangs off an icon inside the input rather than
233
+ sitting beside it as a second widget.
234
+ */}
235
+ <Input
236
+ allowClear={allowClear}
237
+ {...affordanceProps}
238
+ disabled={state.disabled}
239
+ onChange={(event) =>
240
+ props.handleChange(props.path, event.currentTarget.value || undefined)
241
+ }
242
+ onBlur={onBlurTouch}
243
+ placeholder={state.options.placeholder ?? 'P1DT2H'}
244
+ autoFocus={state.options.focus}
245
+ status={localError || filteredErrors ? 'error' : undefined}
246
+ value={value ?? ''}
247
+ styles={{
248
+ prefix: { lineHeight: 0, display: 'flex', alignItems: 'center' },
249
+ }}
250
+ prefix={
251
+ <Popover
252
+ content={picker}
253
+ onOpenChange={(next) => (next ? state.openPicker() : state.close())}
254
+ open={open}
255
+ placement='bottomLeft'
256
+ trigger='click'
257
+ >
258
+ <ClockCircleOutlined
259
+ role='button'
260
+ aria-label={t('editor.chooseDuration')}
261
+ style={{
262
+ cursor: state.disabled ? 'not-allowed' : 'pointer',
263
+ color: token.colorTextTertiary,
264
+ }}
265
+ />
266
+ </Popover>
267
+ }
268
+ />
269
+ </PickerFormItem>
270
+ );
271
+ };
272
+
273
+ export const AntdDurationControlRenderer =
274
+ withJsonFormsControlProps(AntdDurationControl);
@@ -0,0 +1,27 @@
1
+ import { createMarkupLabelRenderer } from '@chobantonov/jsonforms-react-extended-renderers';
2
+ import { Typography } from 'antd';
3
+ import React from 'react';
4
+
5
+ /**
6
+ * The markup label, wearing antd's typography.
7
+ *
8
+ * The `block` flag is ignored, and that is the interesting part: antd's
9
+ * `Typography.Paragraph` renders a **`div`**, not a `<p>` (checked - antd's
10
+ * own `component` default for it is `"div"`; `Typography` is an `article` and
11
+ * `Typography.Text` a `span`). So it is safe to wrap parsed Markdown in,
12
+ * which for a library whose paragraph really is a `<p>` it would not be.
13
+ * Using it for both modes keeps the two looking identical, which matters more
14
+ * here than honouring a distinction antd does not draw.
15
+ *
16
+ * `marginBottom: 0`: antd gives a paragraph a bottom margin, which inside a
17
+ * form's own vertical rhythm reads as an unexplained gap under one label. A
18
+ * host that wants the margin back switches `typography` off and styles the
19
+ * text itself, which is what that option is for.
20
+ */
21
+ export const AntdMarkupLabelRenderer = createMarkupLabelRenderer(
22
+ ({ children }) => (
23
+ <Typography.Paragraph style={{ marginBottom: 0 }}>
24
+ {children}
25
+ </Typography.Paragraph>
26
+ ),
27
+ );
@@ -0,0 +1,19 @@
1
+ import { ControlProps, RankedTester } from '@jsonforms/core';
2
+ import { withJsonFormsControlProps } from '@jsonforms/react';
3
+ import { InputControl } from '@chobantonov/jsonforms-react-antd-renderers';
4
+ import { extendedMaskTester } from '@chobantonov/jsonforms-react-extended-renderers';
5
+ import React from 'react';
6
+ import { AntdMaskInput } from '../components/AntdMaskInput';
7
+
8
+ /**
9
+ * Selection is `options.mask` carrying a pattern, on a string with no format of
10
+ * its own. See `maskControls.ts` for why presence alone is not enough.
11
+ */
12
+ export const antdMaskControlTester: RankedTester = extendedMaskTester;
13
+
14
+ export const AntdMaskControl = (props: ControlProps) => (
15
+ <InputControl {...props} input={AntdMaskInput} />
16
+ );
17
+
18
+ export const AntdMaskControlRenderer =
19
+ withJsonFormsControlProps(AntdMaskControl);
@@ -0,0 +1,21 @@
1
+ import { createMonacoControlRenderer } from '@chobantonov/jsonforms-react-extended-renderers';
2
+ import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
3
+ import { AntdEditorToggleButton } from '../components/AntdEditorButton';
4
+ import { AntdEditorFrame } from '../components/AntdEditorFrame';
5
+ import {
6
+ AntdEditorLoadError,
7
+ AntdEditorLoading,
8
+ } from '../components/AntdEditorLoading';
9
+ import { AntdEditorSurface } from '../components/AntdEditorSurface';
10
+ import { useAntdEditorTheme } from '../hooks/useAntdEditorTheme';
11
+
12
+ export const AntdMonacoControlRenderer = createMonacoControlRenderer({
13
+ Frame: AntdEditorFrame,
14
+ Button: AntdEditorToggleButton,
15
+ MaximizeIcon: FullscreenOutlined,
16
+ MinimizeIcon: FullscreenExitOutlined,
17
+ Surface: AntdEditorSurface,
18
+ useEditorTheme: useAntdEditorTheme,
19
+ Loading: AntdEditorLoading,
20
+ LoadError: AntdEditorLoadError,
21
+ });
@@ -0,0 +1,70 @@
1
+ import {
2
+ ControlFormItem,
3
+ usePreTouchErrors,
4
+ } from '@chobantonov/jsonforms-react-antd-renderers';
5
+ import {
6
+ and,
7
+ ControlProps,
8
+ JsonSchema,
9
+ RankedTester,
10
+ rankWith,
11
+ schemaMatches,
12
+ uiTypeIs,
13
+ } from '@jsonforms/core';
14
+ import { withJsonFormsControlProps } from '@jsonforms/react';
15
+ import { Checkbox } from 'antd';
16
+ import React from 'react';
17
+
18
+ export const antdNullControlTester: RankedTester = rankWith(
19
+ 3,
20
+ and(
21
+ uiTypeIs('Control'),
22
+ schemaMatches((schema: JsonSchema) => schema.type === 'null'),
23
+ ),
24
+ );
25
+
26
+ export const AntdNullControl = (props: ControlProps) => {
27
+ // See `usePreTouchErrors`; unchanged unless filtering is on.
28
+ const { errors, onFocus, onBlur } = usePreTouchErrors({
29
+ errors: props.errors,
30
+ path: props.path,
31
+ schema: props.schema,
32
+ uischema: props.uischema as any,
33
+ config: props.config,
34
+ });
35
+ if (!props.visible) return null;
36
+ return (
37
+ <ControlFormItem
38
+ errors={errors || undefined}
39
+ help={errors || props.description}
40
+ >
41
+ <Checkbox
42
+ checked={props.data === null}
43
+ disabled={!props.enabled}
44
+ onFocus={onFocus}
45
+ onBlur={onBlur}
46
+ /*
47
+ Indeterminate means "neither of the two states this control has" -
48
+ a value that is not `null` and is not absent either. It used to be
49
+ `data !== null`, which made an absent property indeterminate too: the
50
+ commonest state of all, nothing recorded yet, was drawn as though the
51
+ data were broken. Section 19 wants the genuinely out-of-domain value
52
+ marked, not the empty one.
53
+ */
54
+ indeterminate={props.data !== null && props.data !== undefined}
55
+ onChange={(event) =>
56
+ props.handleChange(
57
+ props.path,
58
+ event.target.checked ? null : undefined,
59
+ )
60
+ }
61
+ >
62
+ {props.label}
63
+ {props.required ? ' *' : ''}
64
+ </Checkbox>
65
+ </ControlFormItem>
66
+ );
67
+ };
68
+
69
+ export const AntdNullControlRenderer =
70
+ withJsonFormsControlProps(AntdNullControl);
@@ -0,0 +1,122 @@
1
+ import { useEffectiveElements } from '@chobantonov/jsonforms-react-renderer-common/layout/layoutContext';
2
+ import {
3
+ initialSplitSizes,
4
+ splitCssSize,
5
+ } from '@chobantonov/jsonforms-react-extended-renderers';
6
+ import {
7
+ and,
8
+ Layout,
9
+ LayoutProps,
10
+ or,
11
+ RankedTester,
12
+ rankWith,
13
+ UISchemaElement,
14
+ uiTypeIs,
15
+ } from '@jsonforms/core';
16
+ import { JsonFormsDispatch, withJsonFormsLayoutProps } from '@jsonforms/react';
17
+ import { Splitter } from 'antd';
18
+ import React from 'react';
19
+
20
+ export const hasAntdSplitLayoutVariant = (uischema: UISchemaElement) =>
21
+ String(uischema.options?.variant ?? '').toLowerCase() === 'splitter';
22
+
23
+ export const antdSplitLayoutTester: RankedTester = rankWith(
24
+ 5,
25
+ and(
26
+ or(uiTypeIs('HorizontalLayout'), uiTypeIs('VerticalLayout')),
27
+ hasAntdSplitLayoutVariant,
28
+ ),
29
+ );
30
+
31
+ export const AntdSplitLayout = (props: LayoutProps) => {
32
+ const layout = props.uischema as Layout;
33
+ const vertical = layout.type === 'VerticalLayout';
34
+ const options = { ...props.config, ...layout.options };
35
+ /*
36
+ "Only effective visible UI-schema children participate. Hidden children
37
+ leave layout." A hidden pane used to keep its share and its separator.
38
+ */
39
+ const elements = useEffectiveElements(
40
+ layout.elements,
41
+ props.path,
42
+ props.config,
43
+ );
44
+ /* "Initial sizes use normal sizing", not equal shares. */
45
+ const shares = initialSplitSizes(elements);
46
+ /* "`resizable` defaults true." */
47
+ const resizable = (options as any).resizable !== false;
48
+ if (!props.visible) return null;
49
+ return (
50
+ <Splitter
51
+ /*
52
+ Remount when the number of panes changes.
53
+
54
+ antd applies `defaultSize` once, on mount. A pane revealed by a rule
55
+ therefore arrives beside siblings whose sizes were resolved without it
56
+ - the previous single pane stays at `flex-basis: 100%` and the new one
57
+ falls back to `auto`, so it is squeezed to nothing and looks as though
58
+ it never rendered. It did; it just had no width.
59
+
60
+ The cost is that the panes remount, losing focus and any local state
61
+ inside them at that moment. That is the better trade: the set of panes
62
+ just changed, so the old sizes no longer describe this layout, and a
63
+ pane you cannot see is worse than one that re-mounts.
64
+
65
+ The shared splitter needs none of this - it recomputes whenever the
66
+ stored size count stops matching the pane count.
67
+ */
68
+ key={elements.length}
69
+ orientation={vertical ? 'vertical' : 'horizontal'}
70
+ {...((options as any)?.wrap === true
71
+ ? {
72
+ 'data-layout-diagnostic':
73
+ '`wrap` is not supported together with the splitter variant; ignored.',
74
+ }
75
+ : {})}
76
+ style={{
77
+ height: vertical
78
+ ? (splitCssSize(options.height) ?? '20rem')
79
+ : undefined,
80
+ minHeight: vertical ? splitCssSize(options.minHeight) : undefined,
81
+ }}
82
+ >
83
+ {elements.map((element, index) => (
84
+ <Splitter.Panel
85
+ defaultSize={`${shares[index]}%`}
86
+ key={index}
87
+ min='10%'
88
+ resizable={resizable}
89
+ >
90
+ <div
91
+ /*
92
+ `border-box` is load-bearing, not tidiness: this pane is sized to
93
+ the full height of its slot and then given padding. Under the
94
+ default `content-box` the padding is added *outside* that height,
95
+ so every pane overflows by exactly its padding and shows a
96
+ scrollbar over content that fits.
97
+ */
98
+ style={{
99
+ boxSizing: 'border-box',
100
+ height: '100%',
101
+ minWidth: 0,
102
+ overflow: 'auto',
103
+ padding: 12,
104
+ }}
105
+ >
106
+ <JsonFormsDispatch
107
+ cells={props.cells}
108
+ enabled={props.enabled}
109
+ path={props.path}
110
+ renderers={props.renderers}
111
+ schema={props.schema}
112
+ uischema={element}
113
+ />
114
+ </div>
115
+ </Splitter.Panel>
116
+ ))}
117
+ </Splitter>
118
+ );
119
+ };
120
+
121
+ export const AntdSplitLayoutRenderer =
122
+ withJsonFormsLayoutProps(AntdSplitLayout);
@@ -0,0 +1,8 @@
1
+ export * from './AntdButtonRenderer';
2
+ export * from './AntdColorControlRenderer';
3
+ export * from './AntdCronControlRenderer';
4
+ export * from './AntdDurationControlRenderer';
5
+ export * from './AntdMaskControlRenderer';
6
+ export * from './AntdNullControlRenderer';
7
+ export * from './AntdSplitLayoutRenderer';
8
+ export * from './AntdMarkupLabelRenderer';
@@ -0,0 +1,42 @@
1
+ import type { ColorSaveFormat } from '@chobantonov/jsonforms-react-renderer-common/formats/colorFormat';
2
+ export {
3
+ COLOR_SAVE_FORMATS,
4
+ DEFAULT_COLOR_SAVE_FORMAT,
5
+ asColorSaveFormat,
6
+ normalizeHue,
7
+ parseColor,
8
+ isColor,
9
+ isTransparent,
10
+ hslToRgb,
11
+ hsbToRgb,
12
+ rgbToHsb,
13
+ serializeColor,
14
+ toCssColor,
15
+ placeholderKeyFor,
16
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/colorFormat';
17
+ export type {
18
+ ColorSaveFormat,
19
+ Rgba,
20
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/colorFormat';
21
+
22
+ /**
23
+ * Which of antd's three picker panels matches a save format.
24
+ *
25
+ * Total, because every save format is one the picker can edit - that is why
26
+ * `hsl` output was dropped. `hex3` edits on the hex panel and is quantized on
27
+ * commit; it is a narrower hex, not a different model.
28
+ */
29
+ export const pickerFormatFor = (
30
+ format: ColorSaveFormat,
31
+ ): 'hex' | 'rgb' | 'hsb' => {
32
+ switch (format) {
33
+ case 'rgb':
34
+ return 'rgb';
35
+ case 'hsb':
36
+ return 'hsb';
37
+ case 'hex':
38
+ case 'hex3':
39
+ default:
40
+ return 'hex';
41
+ }
42
+ };