@caratlogic/design-system 0.1.13 → 0.1.18
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/README.md +1 -1
- package/dist/components/molecules/CustomField/CustomField.types.d.ts +28 -0
- package/dist/components/molecules/CustomField/CustomField.types.d.ts.map +1 -0
- package/dist/components/molecules/CustomField/CustomFieldInput.d.ts +43 -0
- package/dist/components/molecules/CustomField/CustomFieldInput.d.ts.map +1 -0
- package/dist/components/molecules/CustomField/CustomFieldValue.d.ts +17 -0
- package/dist/components/molecules/CustomField/CustomFieldValue.d.ts.map +1 -0
- package/dist/components/molecules/CustomField/fieldTypeIcon.d.ts +4 -0
- package/dist/components/molecules/CustomField/fieldTypeIcon.d.ts.map +1 -0
- package/dist/components/molecules/CustomField/fieldValueHelpers.d.ts +10 -0
- package/dist/components/molecules/CustomField/fieldValueHelpers.d.ts.map +1 -0
- package/dist/components/molecules/CustomField/index.d.ts +8 -0
- package/dist/components/molecules/CustomField/index.d.ts.map +1 -0
- package/dist/index.cjs.js +692 -341
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +684 -342
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value and type primitives shared by every custom-field surface —
|
|
3
|
+
* manufacturing stages and inventory Extra properties alike.
|
|
4
|
+
*
|
|
5
|
+
* Feature folders import from here; they never import from each other.
|
|
6
|
+
*/
|
|
7
|
+
/** KYC-aligned set the backends accept. `boolean` is legacy — prefer `toggle`. */
|
|
8
|
+
export type CustomFieldType = 'text' | 'textarea' | 'email' | 'phone' | 'number' | 'date' | 'time' | 'dropdown' | 'radio' | 'checkbox' | 'multiSelect' | 'toggle' | 'boolean' | 'image' | 'file' | 'docsWithExpiry';
|
|
9
|
+
/** An uploaded object, stored verbatim by the backend as an opaque `value`. */
|
|
10
|
+
export interface UploadedFileValue {
|
|
11
|
+
/** S3 key returned by the presigned-URL flow. */
|
|
12
|
+
key: string;
|
|
13
|
+
name: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
}
|
|
18
|
+
/** `docsWithExpiry` pairs one upload with an expiry date. */
|
|
19
|
+
export interface DocsWithExpiryValue {
|
|
20
|
+
file?: UploadedFileValue | null;
|
|
21
|
+
expiryDate?: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Any single value a custom field can hold. Callers with extra cases compose
|
|
25
|
+
* on top — manufacturing's `StageValue` adds its certificate array.
|
|
26
|
+
*/
|
|
27
|
+
export type FieldValue = string | number | boolean | string[] | UploadedFileValue | DocsWithExpiryValue | null;
|
|
28
|
+
//# sourceMappingURL=CustomField.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomField.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/CustomField.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,UAAU,GACV,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,OAAO,GACP,UAAU,GACV,aAAa,GACb,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,gBAAgB,CAAC;AAErB,+EAA+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,EAAE,GACR,iBAAiB,GACjB,mBAAmB,GACnB,IAAI,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FieldValue } from './CustomField.types';
|
|
3
|
+
/** Upload variants, which the caller renders via `renderUpload`. */
|
|
4
|
+
export type CustomFieldUploadVariant = 'image' | 'file' | 'docsWithExpiry';
|
|
5
|
+
export interface CustomFieldDescriptor {
|
|
6
|
+
/** DOM id / form key for the rendered control. */
|
|
7
|
+
id: string;
|
|
8
|
+
type: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
options?: string[];
|
|
12
|
+
/** Latest date the picker allows. */
|
|
13
|
+
maxDate?: Date;
|
|
14
|
+
expiryDateLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CustomFieldInputProps {
|
|
17
|
+
field: CustomFieldDescriptor;
|
|
18
|
+
value: FieldValue;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
invalid?: boolean;
|
|
21
|
+
onChange: (value: FieldValue) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Upload control, supplied by the caller. Uploading needs an API client, so
|
|
24
|
+
* it is injected rather than imported — that is what keeps this component
|
|
25
|
+
* free of app dependencies.
|
|
26
|
+
*/
|
|
27
|
+
renderUpload?: (args: {
|
|
28
|
+
id: string;
|
|
29
|
+
variant: CustomFieldUploadVariant;
|
|
30
|
+
value: FieldValue;
|
|
31
|
+
expiryDateLabel?: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onChange: (value: FieldValue) => void;
|
|
34
|
+
}) => ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Renders one control for a field described by `type` and its option metadata.
|
|
38
|
+
*
|
|
39
|
+
* Covers the field types shared by every custom-field surface. Types specific
|
|
40
|
+
* to one feature stay with that feature, which handles them before delegating.
|
|
41
|
+
*/
|
|
42
|
+
export declare function CustomFieldInput({ field, value, disabled, invalid, onChange, renderUpload, }: CustomFieldInputProps): ReactNode;
|
|
43
|
+
//# sourceMappingURL=CustomFieldInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomFieldInput.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/CustomFieldInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAWrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,oEAAoE;AACpE,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,GAAG,gBAAgB,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qCAAqC;IACrC,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,wBAAwB,CAAC;QAClC,KAAK,EAAE,UAAU,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;KACvC,KAAK,SAAS,CAAC;CACjB;AAOD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,GACb,EAAE,qBAAqB,GAAG,SAAS,CA6LnC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FieldValue } from './CustomField.types';
|
|
3
|
+
/** Muted dash, so an uncaptured field reads as blank rather than as a value. */
|
|
4
|
+
export declare const EmptyValue: () => ReactElement;
|
|
5
|
+
export interface CustomFieldValueProps {
|
|
6
|
+
type: string;
|
|
7
|
+
value: FieldValue;
|
|
8
|
+
/** Appended after a numeric value, e.g. `ct`. */
|
|
9
|
+
unit?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A captured value rendered for reading rather than editing. Edit forms use
|
|
13
|
+
* real inputs; a disabled input full of placeholders is much harder to scan
|
|
14
|
+
* than plain text, and reads as broken rather than empty.
|
|
15
|
+
*/
|
|
16
|
+
export declare function CustomFieldValue({ type, value, unit, }: CustomFieldValueProps): ReactElement;
|
|
17
|
+
//# sourceMappingURL=CustomFieldValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomFieldValue.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/CustomFieldValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAEV,UAAU,EAEX,MAAM,qBAAqB,CAAC;AAmC7B,gFAAgF;AAChF,eAAO,MAAM,UAAU,QAAO,YAE7B,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,KAAK,EACL,IAAI,GACL,EAAE,qBAAqB,GAAG,YAAY,CAgDtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldTypeIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/fieldTypeIcon.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAqBtB,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEtD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FieldValue } from './CustomField.types';
|
|
2
|
+
/** Shown in a read-only control whose value was never filled in. */
|
|
3
|
+
export declare const NOT_CAPTURED = "Not captured";
|
|
4
|
+
export declare const asText: (value: FieldValue) => string;
|
|
5
|
+
export declare const asList: (value: FieldValue) => string[];
|
|
6
|
+
/** Blank for display purposes — a number `0` is a real value, not blank. */
|
|
7
|
+
export declare const isBlank: (value: FieldValue) => boolean;
|
|
8
|
+
/** Treats blank strings, empty arrays and empty upload objects as uncaptured. */
|
|
9
|
+
export declare function isValueEmpty(value: FieldValue | undefined): boolean;
|
|
10
|
+
//# sourceMappingURL=fieldValueHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldValueHelpers.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/fieldValueHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,oEAAoE;AACpE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,MAAM,GAAI,OAAO,UAAU,KAAG,MACH,CAAC;AAEzC,eAAO,MAAM,MAAM,GAAI,OAAO,UAAU,KAAG,MAAM,EAGzC,CAAC;AAET,4EAA4E;AAC5E,eAAO,MAAM,OAAO,GAAI,OAAO,UAAU,KAAG,OAC0B,CAAC;AAEvE,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAOnE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CustomFieldInput } from './CustomFieldInput';
|
|
2
|
+
export { CustomFieldValue, EmptyValue } from './CustomFieldValue';
|
|
3
|
+
export { fieldTypeIcon } from './fieldTypeIcon';
|
|
4
|
+
export { asList, asText, isBlank, isValueEmpty, NOT_CAPTURED, } from './fieldValueHelpers';
|
|
5
|
+
export type { CustomFieldDescriptor, CustomFieldInputProps, CustomFieldUploadVariant, } from './CustomFieldInput';
|
|
6
|
+
export type { CustomFieldValueProps } from './CustomFieldValue';
|
|
7
|
+
export type { CustomFieldType, DocsWithExpiryValue, FieldValue, UploadedFileValue, } from './CustomField.types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/CustomField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|