@byline/ui 2.1.3 → 2.2.1

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.
@@ -24,6 +24,8 @@ const placeholderForField = (f)=>{
24
24
  return false;
25
25
  case 'integer':
26
26
  return 0;
27
+ case 'counter':
28
+ return;
27
29
  case 'richText':
28
30
  case 'datetime':
29
31
  return;
@@ -113,6 +113,22 @@ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabe
113
113
  id: htmlId,
114
114
  components: components
115
115
  });
116
+ case 'counter':
117
+ return /*#__PURE__*/ jsx(NumericalField, {
118
+ field: hideLabel ? {
119
+ ...field,
120
+ label: void 0,
121
+ readOnly: true
122
+ } : {
123
+ ...field,
124
+ readOnly: true
125
+ },
126
+ defaultValue: defaultValue,
127
+ onChange: handleChange,
128
+ path: path,
129
+ id: htmlId,
130
+ components: components
131
+ });
116
132
  case 'file':
117
133
  return /*#__PURE__*/ jsx(FileField, {
118
134
  field: hideLabel ? {
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
- import type { DecimalField, FieldComponentSlots, FloatField, IntegerField } from '@byline/core';
8
+ import type { CounterField, DecimalField, FieldComponentSlots, FloatField, IntegerField } from '@byline/core';
9
9
  export declare const NumericalField: ({ field, value, defaultValue, onChange, id, path, components, }: {
10
- field: IntegerField | FloatField | DecimalField;
10
+ field: IntegerField | FloatField | DecimalField | CounterField;
11
11
  value?: string | number | null;
12
12
  defaultValue?: string | number | null;
13
13
  onChange?: (value: string) => void;
@@ -45,6 +45,7 @@ const NumericalField = ({ field, value, defaultValue, onChange, id, path, compon
45
45
  name: field.name,
46
46
  label: suppressInputLabel ? void 0 : field.label,
47
47
  required: !field.optional,
48
+ readOnly: field.readOnly,
48
49
  helpText: suppressInputHelpText ? void 0 : field.helpText,
49
50
  value: displayValue,
50
51
  onChange: (e)=>onChange?.(e.target.value),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "license": "MPL-2.0",
6
- "version": "2.1.3",
6
+ "version": "2.2.1",
7
7
  "engines": {
8
8
  "node": ">=20.9.0"
9
9
  },
@@ -65,9 +65,9 @@
65
65
  "react-diff-viewer-continued": "^4.2.2",
66
66
  "zod": "^4.4.3",
67
67
  "zod-form-data": "^3.0.1",
68
- "@byline/admin": "2.1.3",
69
- "@byline/client": "2.1.3",
70
- "@byline/core": "2.1.3"
68
+ "@byline/admin": "2.2.1",
69
+ "@byline/core": "2.2.1",
70
+ "@byline/client": "2.2.1"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": "^19.0.0",
@@ -35,6 +35,9 @@ export const placeholderForField = (f: Field): any => {
35
35
  return false
36
36
  case 'integer':
37
37
  return 0
38
+ case 'counter':
39
+ // Allocator-assigned in the lifecycle layer; absent at form-init time.
40
+ return undefined
38
41
  case 'richText':
39
42
  case 'datetime':
40
43
  return undefined
@@ -184,6 +184,24 @@ export const FieldRenderer = ({
184
184
  components={components}
185
185
  />
186
186
  )
187
+ case 'counter':
188
+ // Counter values are allocator-assigned; force readOnly at the
189
+ // renderer level so the widget is always non-editable regardless
190
+ // of whether the developer set `field.readOnly` explicitly.
191
+ return (
192
+ <NumericalField
193
+ field={
194
+ hideLabel
195
+ ? { ...field, label: undefined, readOnly: true }
196
+ : { ...field, readOnly: true }
197
+ }
198
+ defaultValue={defaultValue}
199
+ onChange={handleChange}
200
+ path={path}
201
+ id={htmlId}
202
+ components={components}
203
+ />
204
+ )
187
205
  case 'file':
188
206
  return (
189
207
  <FileField
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import type {
10
+ CounterField,
10
11
  DecimalField,
11
12
  Field,
12
13
  FieldComponentSlots,
@@ -26,7 +27,7 @@ export const NumericalField = ({
26
27
  path,
27
28
  components,
28
29
  }: {
29
- field: IntegerField | FloatField | DecimalField
30
+ field: IntegerField | FloatField | DecimalField | CounterField
30
31
  value?: string | number | null
31
32
  defaultValue?: string | number | null
32
33
  onChange?: (value: string) => void
@@ -91,6 +92,7 @@ export const NumericalField = ({
91
92
  name={field.name}
92
93
  label={suppressInputLabel ? undefined : field.label}
93
94
  required={!field.optional}
95
+ readOnly={field.readOnly}
94
96
  helpText={suppressInputHelpText ? undefined : field.helpText}
95
97
  value={displayValue}
96
98
  onChange={(e) => onChange?.(e.target.value)}