@instructure/platform-block-content-editor 0.3.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.
- package/dist/components/MediaPlaceholder/MediaPlaceholder.d.ts +25 -0
- package/dist/components/MediaPlaceholder/MediaPlaceholder.d.ts.map +1 -0
- package/dist/components/MediaPlaceholder/index.d.ts +3 -0
- package/dist/components/MediaPlaceholder/index.d.ts.map +1 -0
- package/dist/components/blocks/Accordion/Accordion.d.ts +4 -0
- package/dist/components/blocks/Accordion/Accordion.d.ts.map +1 -0
- package/dist/components/blocks/Accordion/accordionPropsSchema.d.ts +109 -0
- package/dist/components/blocks/Accordion/accordionPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/Accordion/getAccordionViewProps.d.ts +66 -0
- package/dist/components/blocks/Accordion/getAccordionViewProps.d.ts.map +1 -0
- package/dist/components/blocks/Accordion/index.d.ts +4 -0
- package/dist/components/blocks/Accordion/index.d.ts.map +1 -0
- package/dist/components/blocks/Banner/Banner.d.ts +4 -0
- package/dist/components/blocks/Banner/Banner.d.ts.map +1 -0
- package/dist/components/blocks/Banner/bannerPropsSchema.d.ts +36 -0
- package/dist/components/blocks/Banner/bannerPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/Banner/getBannerViewProps.d.ts +5 -0
- package/dist/components/blocks/Banner/getBannerViewProps.d.ts.map +1 -0
- package/dist/components/blocks/Banner/index.d.ts +3 -0
- package/dist/components/blocks/Banner/index.d.ts.map +1 -0
- package/dist/components/blocks/CodeBlock/CodeBlock.d.ts +4 -0
- package/dist/components/blocks/CodeBlock/CodeBlock.d.ts.map +1 -0
- package/dist/components/blocks/CodeBlock/codeBlockPropsSchema.d.ts +28 -0
- package/dist/components/blocks/CodeBlock/codeBlockPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/CodeBlock/getCodeBlockViewProps.d.ts +13 -0
- package/dist/components/blocks/CodeBlock/getCodeBlockViewProps.d.ts.map +1 -0
- package/dist/components/blocks/CodeBlock/index.d.ts +3 -0
- package/dist/components/blocks/CodeBlock/index.d.ts.map +1 -0
- package/dist/components/blocks/ImageBlock/ImageBlock.d.ts +4 -0
- package/dist/components/blocks/ImageBlock/ImageBlock.d.ts.map +1 -0
- package/dist/components/blocks/ImageBlock/getImageBlockViewProps.d.ts +7 -0
- package/dist/components/blocks/ImageBlock/getImageBlockViewProps.d.ts.map +1 -0
- package/dist/components/blocks/ImageBlock/imageBlockPropsSchema.d.ts +40 -0
- package/dist/components/blocks/ImageBlock/imageBlockPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/ImageBlock/index.d.ts +3 -0
- package/dist/components/blocks/ImageBlock/index.d.ts.map +1 -0
- package/dist/components/blocks/Quote/Quote.d.ts +4 -0
- package/dist/components/blocks/Quote/Quote.d.ts.map +1 -0
- package/dist/components/blocks/Quote/getQuoteViewProps.d.ts +5 -0
- package/dist/components/blocks/Quote/getQuoteViewProps.d.ts.map +1 -0
- package/dist/components/blocks/Quote/index.d.ts +3 -0
- package/dist/components/blocks/Quote/index.d.ts.map +1 -0
- package/dist/components/blocks/Quote/quotePropsSchema.d.ts +28 -0
- package/dist/components/blocks/Quote/quotePropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/Text/Text.d.ts +4 -0
- package/dist/components/blocks/Text/Text.d.ts.map +1 -0
- package/dist/components/blocks/Text/getTextViewProps.d.ts +5 -0
- package/dist/components/blocks/Text/getTextViewProps.d.ts.map +1 -0
- package/dist/components/blocks/Text/index.d.ts +3 -0
- package/dist/components/blocks/Text/index.d.ts.map +1 -0
- package/dist/components/blocks/Text/textPropsSchema.d.ts +28 -0
- package/dist/components/blocks/Text/textPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/VideoBlock/VideoBlock.d.ts +16 -0
- package/dist/components/blocks/VideoBlock/VideoBlock.d.ts.map +1 -0
- package/dist/components/blocks/VideoBlock/getVideoBlockViewProps.d.ts +5 -0
- package/dist/components/blocks/VideoBlock/getVideoBlockViewProps.d.ts.map +1 -0
- package/dist/components/blocks/VideoBlock/index.d.ts +3 -0
- package/dist/components/blocks/VideoBlock/index.d.ts.map +1 -0
- package/dist/components/blocks/VideoBlock/videoBlockPropsSchema.d.ts +40 -0
- package/dist/components/blocks/VideoBlock/videoBlockPropsSchema.d.ts.map +1 -0
- package/dist/components/blocks/brandTheming.d.ts +87 -0
- package/dist/components/blocks/brandTheming.d.ts.map +1 -0
- package/dist/components/blocks/commonSchemas.d.ts +17 -0
- package/dist/components/blocks/commonSchemas.d.ts.map +1 -0
- package/dist/components/blocks/commonViewProps.d.ts +19 -0
- package/dist/components/blocks/commonViewProps.d.ts.map +1 -0
- package/dist/contexts/BlockEditorApiContext.d.ts +63 -0
- package/dist/contexts/BlockEditorApiContext.d.ts.map +1 -0
- package/dist/contexts/BrandColorContext.d.ts +10 -0
- package/dist/contexts/BrandColorContext.d.ts.map +1 -0
- package/dist/contexts/DesignerModeContext.d.ts +8 -0
- package/dist/contexts/DesignerModeContext.d.ts.map +1 -0
- package/dist/contexts/TranslationsContext.d.ts +70 -0
- package/dist/contexts/TranslationsContext.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1385 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/registeredSchema.d.ts +47 -0
- package/dist/schema/registeredSchema.d.ts.map +1 -0
- package/dist/schema/schemaValidator.d.ts +40 -0
- package/dist/schema/schemaValidator.d.ts.map +1 -0
- package/dist/schema/zodExtensions.d.ts +137 -0
- package/dist/schema/zodExtensions.d.ts.map +1 -0
- package/dist/schema/zodUtils.d.ts +90 -0
- package/dist/schema/zodUtils.d.ts.map +1 -0
- package/dist/schema/zodUtils.test.d.ts +2 -0
- package/dist/schema/zodUtils.test.d.ts.map +1 -0
- package/dist/utils/colorVariants/brandColorVariants.d.ts +25 -0
- package/dist/utils/colorVariants/brandColorVariants.d.ts.map +1 -0
- package/dist/utils/colorVariants/brandColorVariants.test.d.ts +2 -0
- package/dist/utils/colorVariants/brandColorVariants.test.d.ts.map +1 -0
- package/dist/utils/colorVariants/color.d.ts +21 -0
- package/dist/utils/colorVariants/color.d.ts.map +1 -0
- package/dist/utils/colorVariants/color.test.d.ts +2 -0
- package/dist/utils/colorVariants/color.test.d.ts.map +1 -0
- package/dist/utils/colorVariants/deriveColorVariants.d.ts +41 -0
- package/dist/utils/colorVariants/deriveColorVariants.d.ts.map +1 -0
- package/dist/utils/colorVariants/deriveColorVariants.test.d.ts +2 -0
- package/dist/utils/colorVariants/deriveColorVariants.test.d.ts.map +1 -0
- package/dist/utils/colorVariants/index.d.ts +3 -0
- package/dist/utils/colorVariants/index.d.ts.map +1 -0
- package/dist/utils/colorVariants/types.d.ts +21 -0
- package/dist/utils/colorVariants/types.d.ts.map +1 -0
- package/dist/utils/colorVariants/wcag.d.ts +10 -0
- package/dist/utils/colorVariants/wcag.d.ts.map +1 -0
- package/dist/utils/safeMediaUrl.d.ts +10 -0
- package/dist/utils/safeMediaUrl.d.ts.map +1 -0
- package/dist/utils/safeMediaUrl.test.d.ts +2 -0
- package/dist/utils/safeMediaUrl.test.d.ts.map +1 -0
- package/dist/utils/wordWrap.d.ts +16 -0
- package/dist/utils/wordWrap.d.ts.map +1 -0
- package/locales/en.json +21 -0
- package/package.json +73 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { parseDescription, type ZodFormMetadata, type ZodRangeConfig, type ZodHiddenWhenConfig, type ZodDisabledWhenConfig, } from './zodExtensions';
|
|
2
|
+
export { validateComponentSchema, type ValidationError, type ValidationIssue, type ValidationResult, } from './schemaValidator';
|
|
3
|
+
export { registerComponentSchema, type RegisteredComponentSchema, } from './registeredSchema';
|
|
4
|
+
export { FormFieldType, type FormFieldMetadata, unwrapZodType, deriveFieldType, extractValidationRules, extractFieldMetadata, extractFormMetadata, } from './zodUtils';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAmBA,OAAO,iBAAiB,CAAA;AAExB,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EACL,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Brand symbol to mark validated component schemas
|
|
4
|
+
* This symbol is never instantiated - it only exists in the type system
|
|
5
|
+
*/
|
|
6
|
+
declare const __registeredComponentSchema: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* A Zod schema that has been validated for component registration
|
|
9
|
+
*
|
|
10
|
+
* This branded type can only be created via registerComponentSchema(),
|
|
11
|
+
* which validates that the schema meets all requirements:
|
|
12
|
+
* - All visible fields have .zodLabel()
|
|
13
|
+
* - Hidden fields (with .zodHidden()) are exempt
|
|
14
|
+
* - No z.any() / z.unknown() / z.custom() without .zodHidden()
|
|
15
|
+
*
|
|
16
|
+
* @template T - The inferred TypeScript type from the Zod schema
|
|
17
|
+
*/
|
|
18
|
+
export type RegisteredComponentSchema<T> = z.ZodType<T> & {
|
|
19
|
+
readonly [__registeredComponentSchema]: true;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates a RegisteredComponentSchema from a Zod schema
|
|
23
|
+
*
|
|
24
|
+
* Validates the schema meets all requirements for form generation and brands it
|
|
25
|
+
* as a RegisteredComponentSchema. Throws TypeError if validation fails.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The inferred TypeScript type from the Zod schema
|
|
28
|
+
* @param schema - The Zod object schema to validate and register
|
|
29
|
+
* @param componentName - Name of the component (for error messages)
|
|
30
|
+
* @returns The validated and branded schema
|
|
31
|
+
* @throws {TypeError} If the schema doesn't meet registration requirements
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const TextPropsSchema = z.object({
|
|
36
|
+
* content: z.string().zodLabel('Content'),
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* export const RegisteredTextPropsSchema = registerComponentSchema(
|
|
40
|
+
* TextPropsSchema,
|
|
41
|
+
* 'Text'
|
|
42
|
+
* )
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function registerComponentSchema<T extends z.ZodRawShape>(schema: z.ZodObject<T>, componentName: string): RegisteredComponentSchema<z.infer<z.ZodObject<T>>>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=registeredSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registeredSchema.d.ts","sourceRoot":"","sources":["../../src/schema/registeredSchema.ts"],"names":[],"mappings":"AAkBA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B;;;GAGG;AACH,OAAO,CAAC,MAAM,2BAA2B,EAAE,OAAO,MAAM,CAAA;AAExD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;IACxD,QAAQ,CAAC,CAAC,2BAA2B,CAAC,EAAE,IAAI,CAAA;CAC7C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAC7D,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,aAAa,EAAE,MAAM,GACpB,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAgBpD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Types of validation issues
|
|
4
|
+
*/
|
|
5
|
+
export type ValidationIssue = 'missing-label' | 'invalid-type' | 'missing-metadata';
|
|
6
|
+
/**
|
|
7
|
+
* A single validation error for a field
|
|
8
|
+
*/
|
|
9
|
+
export interface ValidationError {
|
|
10
|
+
/** Field name (or nested path like "theme.primary") */
|
|
11
|
+
field: string;
|
|
12
|
+
/** Type of issue */
|
|
13
|
+
issue: ValidationIssue;
|
|
14
|
+
/** Human-readable error message */
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result of schema validation
|
|
19
|
+
*/
|
|
20
|
+
export interface ValidationResult {
|
|
21
|
+
/** Whether the schema passed all validation checks */
|
|
22
|
+
valid: boolean;
|
|
23
|
+
/** List of validation errors (empty if valid) */
|
|
24
|
+
errors: ValidationError[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates that a component schema meets registration requirements
|
|
28
|
+
*
|
|
29
|
+
* Requirements:
|
|
30
|
+
* - Schema must be a ZodObject (z.object({...}))
|
|
31
|
+
* - All visible fields must have .zodLabel()
|
|
32
|
+
* - Hidden fields (with .zodHidden()) are exempt
|
|
33
|
+
* - No z.any() / z.unknown() / z.custom() without .zodHidden()
|
|
34
|
+
*
|
|
35
|
+
* @param schema - The Zod schema to validate
|
|
36
|
+
* @param componentName - Name of the component (for error messages)
|
|
37
|
+
* @returns Validation result with any errors found
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateComponentSchema<T>(schema: z.ZodType<T>, componentName: string): ValidationResult;
|
|
40
|
+
//# sourceMappingURL=schemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/schema/schemaValidator.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAEnF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,oBAAoB;IACpB,KAAK,EAAE,eAAe,CAAA;IACtB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAA;IACd,iDAAiD;IACjD,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AA2FD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,aAAa,EAAE,MAAM,GACpB,gBAAgB,CAyBlB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata stored in Zod schema descriptions for form generation
|
|
4
|
+
*/
|
|
5
|
+
export interface ZodRangeConfig {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
formatValue?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ZodHiddenWhenConfig {
|
|
12
|
+
field: string;
|
|
13
|
+
values: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ZodDisabledWhenConfig {
|
|
16
|
+
field: string;
|
|
17
|
+
value: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ZodFormMetadata {
|
|
20
|
+
label?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
help?: string;
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
hiddenWhen?: ZodHiddenWhenConfig | ZodHiddenWhenConfig[];
|
|
25
|
+
disabledWhen?: ZodDisabledWhenConfig | ZodDisabledWhenConfig[];
|
|
26
|
+
textarea?: boolean;
|
|
27
|
+
richtext?: boolean;
|
|
28
|
+
range?: ZodRangeConfig;
|
|
29
|
+
codeeditor?: boolean;
|
|
30
|
+
image?: boolean;
|
|
31
|
+
video?: boolean;
|
|
32
|
+
description?: string;
|
|
33
|
+
itemLabel?: string;
|
|
34
|
+
itemName?: string;
|
|
35
|
+
manageLayer?: string;
|
|
36
|
+
answers?: boolean;
|
|
37
|
+
altText?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse metadata from a Zod schema description
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseDescription(description?: string): ZodFormMetadata;
|
|
43
|
+
/**
|
|
44
|
+
* Extend Zod with custom methods for form UI hints
|
|
45
|
+
*/
|
|
46
|
+
declare module 'zod' {
|
|
47
|
+
interface ZodType<Output = any, Def extends z.ZodTypeDef = z.ZodTypeDef, Input = Output> {
|
|
48
|
+
/**
|
|
49
|
+
* Add a human-readable label for form field generation
|
|
50
|
+
* @example z.string().zodLabel('Email Address')
|
|
51
|
+
*/
|
|
52
|
+
zodLabel(label: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Add placeholder text for input fields
|
|
55
|
+
* @example z.string().zodPlaceholder('Enter your email')
|
|
56
|
+
*/
|
|
57
|
+
zodPlaceholder(placeholder: string): this;
|
|
58
|
+
/**
|
|
59
|
+
* Add help text or tooltip content
|
|
60
|
+
* @example z.string().zodHelp('We will never share your email')
|
|
61
|
+
*/
|
|
62
|
+
zodHelp(help: string): this;
|
|
63
|
+
/**
|
|
64
|
+
* Mark field as hidden from auto-generated forms
|
|
65
|
+
* Useful for fields managed by custom components (like gcpUploadKey)
|
|
66
|
+
* @example z.string().optional().zodHidden()
|
|
67
|
+
*/
|
|
68
|
+
zodHidden(hidden?: boolean): this;
|
|
69
|
+
/**
|
|
70
|
+
* Mark string field as a multi-line textarea input.
|
|
71
|
+
* @example z.string().zodTextarea().zodLabel('Description')
|
|
72
|
+
*/
|
|
73
|
+
zodTextarea(textarea?: boolean): this;
|
|
74
|
+
/**
|
|
75
|
+
* Mark string field as rich text (HTML) for rendering with RCE editor
|
|
76
|
+
* @example z.string().zodRichText().zodLabel('Content')
|
|
77
|
+
*/
|
|
78
|
+
zodRichText(richtext?: boolean): this;
|
|
79
|
+
/**
|
|
80
|
+
* Mark number field as a range slider input
|
|
81
|
+
* @example z.number().zodRange({ min: 0, max: 100, step: 25, formatValue: '%' }).zodLabel('Size')
|
|
82
|
+
*/
|
|
83
|
+
zodRange(config: ZodRangeConfig): this;
|
|
84
|
+
/**
|
|
85
|
+
* Mark string field as a code editor with syntax highlighting
|
|
86
|
+
* @example z.string().zodCodeEditor().zodLabel('Code')
|
|
87
|
+
*/
|
|
88
|
+
zodCodeEditor(codeeditor?: boolean): this;
|
|
89
|
+
/**
|
|
90
|
+
* Mark string field as an image upload field
|
|
91
|
+
* @example z.string().zodImage().zodLabel('Image')
|
|
92
|
+
*/
|
|
93
|
+
zodImage(image?: boolean): this;
|
|
94
|
+
/**
|
|
95
|
+
* Mark string field as a video upload field
|
|
96
|
+
* @example z.string().zodVideo().zodLabel('Video')
|
|
97
|
+
*/
|
|
98
|
+
zodVideo(video?: boolean): this;
|
|
99
|
+
/**
|
|
100
|
+
* Conditionally hide this field when another field has one of the specified values
|
|
101
|
+
* @example z.string().zodHiddenWhen({ field: 'style', values: ['folder'] })
|
|
102
|
+
*/
|
|
103
|
+
zodHiddenWhen(config: ZodHiddenWhenConfig): this;
|
|
104
|
+
/**
|
|
105
|
+
* Conditionally disable this field when another boolean field equals the given value
|
|
106
|
+
* @example z.string().zodDisabledWhen({ field: 'isDecorative', value: true })
|
|
107
|
+
*/
|
|
108
|
+
zodDisabledWhen(config: ZodDisabledWhenConfig): this;
|
|
109
|
+
/**
|
|
110
|
+
* Specify which field in array object items to use as the display label
|
|
111
|
+
* @example z.array(z.object({ title: z.string(), content: z.string() })).zodItemLabel('title')
|
|
112
|
+
*/
|
|
113
|
+
zodItemLabel(fieldName: string): this;
|
|
114
|
+
/**
|
|
115
|
+
* Specify custom text for the "Add" button in arrays of objects
|
|
116
|
+
* @example z.array(itemSchema).zodItemName('question').zodLabel('Questions')
|
|
117
|
+
*/
|
|
118
|
+
zodItemName(name: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* Opt an array-of-objects field into the host's manage-layer collapse behavior,
|
|
121
|
+
* labelled with the given plural noun
|
|
122
|
+
* @example z.array(itemSchema).zodManageLayer('Accordions').zodLabel('Accordions (up to 10)')
|
|
123
|
+
*/
|
|
124
|
+
zodManageLayer(pluralLabel: string): this;
|
|
125
|
+
/**
|
|
126
|
+
* Mark array field as answer options that require special inline editing with position labels and correct/incorrect toggles
|
|
127
|
+
* @example z.array(answerSchema).zodAnswers().zodLabel('Answer options')
|
|
128
|
+
*/
|
|
129
|
+
zodAnswers(answers?: boolean): this;
|
|
130
|
+
/**
|
|
131
|
+
* Mark string field as an alt text input with AI generation support
|
|
132
|
+
* @example z.string().zodAltText().zodLabel('Alt Text')
|
|
133
|
+
*/
|
|
134
|
+
zodAltText(altText?: boolean): this;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=zodExtensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodExtensions.d.ts","sourceRoot":"","sources":["../../src/schema/zodExtensions.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAA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KACpC;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ZodFormMetadata } from './zodExtensions';
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps ZodOptional, ZodDefault, ZodNullable wrappers to get the inner type
|
|
5
|
+
*
|
|
6
|
+
* This is useful for validation and form generation to access the actual field type
|
|
7
|
+
* without being confused by wrapper types.
|
|
8
|
+
*
|
|
9
|
+
* @param zodType - The Zod type to unwrap
|
|
10
|
+
* @returns The unwrapped inner type
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const optionalString = z.string().optional()
|
|
15
|
+
* const unwrapped = unwrapZodType(optionalString)
|
|
16
|
+
* // unwrapped is z.string()
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function unwrapZodType(zodType: z.ZodTypeAny): z.ZodTypeAny;
|
|
20
|
+
/**
|
|
21
|
+
* Form field types that can be generated from Zod schemas
|
|
22
|
+
*/
|
|
23
|
+
export declare enum FormFieldType {
|
|
24
|
+
TEXT = "text",
|
|
25
|
+
TEXTAREA = "textarea",
|
|
26
|
+
NUMBER = "number",
|
|
27
|
+
RANGE = "range",
|
|
28
|
+
BOOLEAN = "boolean",
|
|
29
|
+
SELECT = "select",
|
|
30
|
+
RICHTEXT = "richtext",
|
|
31
|
+
IMAGE = "image",
|
|
32
|
+
VIDEO = "video",
|
|
33
|
+
ALTTEXT = "alttext",
|
|
34
|
+
ASSET = "asset",
|
|
35
|
+
ARRAY = "array",
|
|
36
|
+
CODEEDITOR = "codeeditor",
|
|
37
|
+
OBJECT = "object",
|
|
38
|
+
ANSWERS = "answers",
|
|
39
|
+
UNKNOWN = "unknown"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Form field metadata extracted from Zod schema
|
|
43
|
+
*/
|
|
44
|
+
export interface FormFieldMetadata extends ZodFormMetadata {
|
|
45
|
+
name: string;
|
|
46
|
+
type: FormFieldType;
|
|
47
|
+
required: boolean;
|
|
48
|
+
defaultValue?: unknown;
|
|
49
|
+
options?: Array<{
|
|
50
|
+
value: string | number;
|
|
51
|
+
label: string;
|
|
52
|
+
}>;
|
|
53
|
+
validation?: {
|
|
54
|
+
min?: number;
|
|
55
|
+
max?: number;
|
|
56
|
+
/** Characters for a string field, items for an array field — read it with `type`. */
|
|
57
|
+
minLength?: number;
|
|
58
|
+
/** Characters for a string field, items for an array field — read it with `type`. */
|
|
59
|
+
maxLength?: number;
|
|
60
|
+
pattern?: string;
|
|
61
|
+
email?: boolean;
|
|
62
|
+
url?: boolean;
|
|
63
|
+
};
|
|
64
|
+
/** For array types - the raw Zod schema of array items */
|
|
65
|
+
itemSchema?: z.ZodTypeAny;
|
|
66
|
+
/** For array types with object items - extracted form metadata for each item property */
|
|
67
|
+
itemProperties?: Record<string, FormFieldMetadata>;
|
|
68
|
+
/** For object types */
|
|
69
|
+
properties?: Record<string, FormFieldMetadata>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Derive form field type from Zod type
|
|
73
|
+
*/
|
|
74
|
+
export declare function deriveFieldType(zodType: z.ZodTypeAny): FormFieldType;
|
|
75
|
+
/**
|
|
76
|
+
* Extract validation rules from Zod schema
|
|
77
|
+
*/
|
|
78
|
+
export declare function extractValidationRules(zodType: z.ZodTypeAny): FormFieldMetadata['validation'];
|
|
79
|
+
/**
|
|
80
|
+
* Extract form metadata from a single Zod field
|
|
81
|
+
*/
|
|
82
|
+
export declare function extractFieldMetadata(name: string, zodType: z.ZodTypeAny): FormFieldMetadata;
|
|
83
|
+
/**
|
|
84
|
+
* Extract form metadata from Zod object schema
|
|
85
|
+
*
|
|
86
|
+
* This is the main function for generating forms from Zod schemas.
|
|
87
|
+
* It returns metadata for each field that can be used to render form inputs.
|
|
88
|
+
*/
|
|
89
|
+
export declare function extractFormMetadata(schema: z.ZodObject<z.ZodRawShape>): Record<string, FormFieldMetadata>;
|
|
90
|
+
//# sourceMapp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A;QAChB,KAAK,CAAC,EAAE,OAAO,CAAA;QACf,GAAG,CAAC,EAAE,OAAO,CAAA;KACd,CAAA;IACD,0DAA0D;IAC1D,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAA;IACzB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAClD,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CAC/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,GAAG,aAAa,CAyEpE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAsD7F;AA+FD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,GAAG,iBAAiB,CAmD3F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GACjC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CASnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodUtils.test.d.ts","sourceRoot":"","sources":["../../src/schema/zodUtils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ColorVariants } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Dark-variant anchor lightness for brand colors — the lightest the dark variant
|
|
4
|
+
* may be, so a brand fill reads as a genuinely dark surface regardless of the
|
|
5
|
+
* input's own lightness (the search still darkens further for bright hues that
|
|
6
|
+
* need it for AA). Tune this to make brand dark variants lighter/darker.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BRAND_DARK_LIGHTNESS = 0.3;
|
|
9
|
+
/**
|
|
10
|
+
* Text color placed on the light brand variant — InstUI's `grey125125`
|
|
11
|
+
* (`#273540`), the canvas primary dark font color — so a light brand fill reads
|
|
12
|
+
* with the same body text color as the rest of the UI rather than pure black.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BRAND_DARK_TEXT = "#273540";
|
|
15
|
+
/**
|
|
16
|
+
* Derives accessible light and dark variants of a brand color at the WCAG
|
|
17
|
+
* thresholds: AA (4.5:1) for text on each variant, and non-text (3:1) between
|
|
18
|
+
* the two variants so they stay distinguishable when rendered adjacent. The dark
|
|
19
|
+
* variant is anchored dark ([[BRAND_DARK_LIGHTNESS]]) for a consistent surface,
|
|
20
|
+
* and the light variant carries the InstUI primary font color ([[BRAND_DARK_TEXT]]).
|
|
21
|
+
*
|
|
22
|
+
* @param brandColor - Brand color as hex or rgb()/rgba().
|
|
23
|
+
*/
|
|
24
|
+
export declare function deriveBrandColorVariants(brandColor: string): ColorVariants;
|
|
25
|
+
//# sourceMappingURL=brandColorVariants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brandColorVariants.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/brandColorVariants.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,eAAe,YAAY,CAAA;AAExC;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAO1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brandColorVariants.test.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/brandColorVariants.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Rgb } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a `#rgb`, `#rrggbb`, `rgb(r, g, b)`, or `rgba(r, g, b, a)` string into
|
|
4
|
+
* RGB channels. Throws on any other format.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseColor(input: string): Rgb;
|
|
7
|
+
/** Serializes RGB channels to a `#rrggbb` hex string. */
|
|
8
|
+
export declare function rgbToHex({ r, g, b }: Rgb): string;
|
|
9
|
+
/** Converts RGB (0–255) to HSL with each component in the 0–1 range. */
|
|
10
|
+
export declare function rgbToHsl({ r, g, b }: Rgb): {
|
|
11
|
+
h: number;
|
|
12
|
+
s: number;
|
|
13
|
+
l: number;
|
|
14
|
+
};
|
|
15
|
+
/** Converts HSL (each component 0–1) to RGB (0–255). */
|
|
16
|
+
export declare function hslToRgb(h: number, s: number, l: number): Rgb;
|
|
17
|
+
/** WCAG relative luminance of an RGB color. */
|
|
18
|
+
export declare function relativeLuminance({ r, g, b }: Rgb): number;
|
|
19
|
+
/** WCAG contrast ratio (1–21) between two colors. */
|
|
20
|
+
export declare function contrastRatio(a: Rgb, b: Rgb): number;
|
|
21
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/color.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAMlC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAsB7C;AAOD,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAEjD;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CA0B9E;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAuB7D;AAED,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAM1D;AAED,qDAAqD;AACrD,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAMpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.test.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/color.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ColorVariants } from './types';
|
|
2
|
+
export interface ColorVariantThresholds {
|
|
3
|
+
/** Minimum contrast each variant must reach against its own text color. */
|
|
4
|
+
minTextContrast: number;
|
|
5
|
+
/**
|
|
6
|
+
* Minimum contrast required between the light and dark colors. Omit to skip
|
|
7
|
+
* this check (relevant only when the two variants are rendered adjacent).
|
|
8
|
+
*/
|
|
9
|
+
minVariantContrast?: number;
|
|
10
|
+
/** Text color placed on the light variant. Defaults to black. */
|
|
11
|
+
darkText?: string;
|
|
12
|
+
/** Text color placed on the dark variant. Defaults to white. */
|
|
13
|
+
lightText?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Anchor lightness (0–1) for the light variant — the lightest it may be. The
|
|
16
|
+
* search only lightens further if the text contrast target isn't met. Defaults
|
|
17
|
+
* to a pale tint.
|
|
18
|
+
*/
|
|
19
|
+
lightLightness?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Anchor lightness (0–1) for the dark variant — the lightest it may be. The
|
|
22
|
+
* search only darkens further if a contrast target isn't met. Lower this for a
|
|
23
|
+
* consistently darker surface. Defaults to mid-dark.
|
|
24
|
+
*/
|
|
25
|
+
darkLightness?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derives a light and a dark variant of a color, both kept on its hue, by
|
|
29
|
+
* moving lightness along that hue until the given contrast thresholds are met.
|
|
30
|
+
*
|
|
31
|
+
* The light variant is lightened until the dark text reaches `minTextContrast`.
|
|
32
|
+
* The dark variant is darkened until the light text reaches `minTextContrast`
|
|
33
|
+
* and, when `minVariantContrast` is set, the two variants are that far apart
|
|
34
|
+
* from each other. Each search stops at its lightness clamp if a threshold is
|
|
35
|
+
* unreachable; the achieved ratios are reported so callers can detect that.
|
|
36
|
+
*
|
|
37
|
+
* @param baseColor - Source color as hex or rgb()/rgba().
|
|
38
|
+
* @param thresholds - Contrast targets and the text colors each variant carries.
|
|
39
|
+
*/
|
|
40
|
+
export declare function deriveColorVariants(baseColor: string, thresholds: ColorVariantThresholds): ColorVariants;
|
|
41
|
+
//# sourceMappingURL=deriveColorVariants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveColorVariants.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/deriveColorVariants.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAiB5C,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,sBAAsB,GACjC,aAAa,CAgDf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveColorVariants.test.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/deriveColorVariants.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** RGB channels, each 0–255. */
|
|
2
|
+
export interface Rgb {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ColorVariant {
|
|
8
|
+
/** Derived color as a `#rrggbb` hex string. */
|
|
9
|
+
color: string;
|
|
10
|
+
/** Text color this variant is designed to carry, as hex. */
|
|
11
|
+
textColor: string;
|
|
12
|
+
/** WCAG contrast ratio of `textColor` on `color`, rounded to 2dp. */
|
|
13
|
+
contrast: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ColorVariants {
|
|
16
|
+
light: ColorVariant;
|
|
17
|
+
dark: ColorVariant;
|
|
18
|
+
/** WCAG contrast ratio between the light and dark colors, rounded to 2dp. */
|
|
19
|
+
variantContrast: number;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/types.ts"],"names":[],"mappings":"AAkBA,gCAAgC;AAChC,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAA;IACnB,IAAI,EAAE,YAAY,CAAA;IAClB,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAA;CACxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Minimum WCAG 2.1 contrast ratios. */
|
|
2
|
+
export declare const WCAG_CONTRAST: {
|
|
3
|
+
/** AA, normal-size text (below 18pt, or 14pt bold). */
|
|
4
|
+
readonly AA_NORMAL_TEXT: 4.5;
|
|
5
|
+
/** AA, large text (18pt+, or 14pt+ bold). */
|
|
6
|
+
readonly AA_LARGE_TEXT: 3;
|
|
7
|
+
/** 1.4.11, UI components and graphical objects against adjacent colors. */
|
|
8
|
+
readonly NON_TEXT: 3;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=wcag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wcag.d.ts","sourceRoot":"","sources":["../../../src/utils/colorVariants/wcag.ts"],"names":[],"mappings":"AAkBA,wCAAwC;AACxC,eAAO,MAAM,aAAa;IACxB,uDAAuD;;IAEvD,6CAA6C;;IAE7C,2EAA2E;;CAEnE,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard a URL for use as the `src` of an `<img>` / `<iframe>` media element.
|
|
3
|
+
* Allowed: absolute http(s) URLs and same-origin relative paths (`/...`).
|
|
4
|
+
* Everything else — `javascript:`, `data:`, `blob:`, `file:`, other schemes,
|
|
5
|
+
* protocol-relative (`//host`) and backslash-escaped (`/\host`) URLs — is
|
|
6
|
+
* rejected. Intentionally stricter than a general URL sanitizer (no
|
|
7
|
+
* `mailto:`/`tel:`), which is the posture a media embed needs.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSafeMediaUrl(url: string | undefined | null): url is string;
|
|
10
|
+
//# sourceMappingURL=safeMediaUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeMediaUrl.d.ts","sourceRoot":"","sources":["../../src/utils/safeMediaUrl.ts"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,GAAG,IAAI,MAAM,CAmB5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeMediaUrl.test.d.ts","sourceRoot":"","sources":["../../src/utils/safeMediaUrl.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps text a block doesn't control — a pasted URL, a long title, a host translation —
|
|
4
|
+
* from escaping the block: under CSS's initial `overflow-wrap: normal` a word wider than
|
|
5
|
+
* its container overflows, and a block never knows how narrow a host renders it.
|
|
6
|
+
*
|
|
7
|
+
* Goes on a plain element wrapping the content, because InstUI's `passthroughProps` drops
|
|
8
|
+
* `style` from `View`; the property inherits from there to every descendant. `break-word`
|
|
9
|
+
* rather than `anywhere` stays out of min-content sizing, and anything declaring its own
|
|
10
|
+
* `white-space` (CodeBlock's `pre`) is left to scroll instead.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately not a `white-space` reset: text refusing to wrap at spaces means a host
|
|
13
|
+
* stylesheet is leaking `nowrap` in, which is the host's to fix.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BLOCK_WORD_WRAP: CSSProperties;
|
|
16
|
+
//# sourceMappingURL=wordWrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordWrap.d.ts","sourceRoot":"","sources":["../../src/utils/wordWrap.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,aAA8C,CAAA"}
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"placeholderContent": "Your content here...",
|
|
3
|
+
"bannerPlaceholderTitle": "Your banner",
|
|
4
|
+
"bannerPlaceholderSubtitle": "Your optional eyebrow text",
|
|
5
|
+
"quotePlaceholderContent": "Your quote here",
|
|
6
|
+
"quotePlaceholderAuthor": "Author",
|
|
7
|
+
"codeBlockPlaceholder": "// Your code here",
|
|
8
|
+
"imageBlockPlaceholder": "Add image...",
|
|
9
|
+
"imageBlockLoading": "Loading image...",
|
|
10
|
+
"imageBlockError": "Failed to load image",
|
|
11
|
+
"videoBlockPlaceholder": "Add video...",
|
|
12
|
+
"videoBlockLoading": "Loading video...",
|
|
13
|
+
"videoBlockError": "Failed to load video",
|
|
14
|
+
"videoBlockUnsupportedProvider": "Unsupported video provider",
|
|
15
|
+
"videoBlockProcessing": "Video is processing",
|
|
16
|
+
"videoBlockProcessingSubtitle": "Once video is done processing, block will update. This could take a few minutes.",
|
|
17
|
+
"videoBlockTitle": "Video",
|
|
18
|
+
"accordionPlaceholder": "Add accordion...",
|
|
19
|
+
"accordionItemPlaceholderTitle": "Accordion %{index}",
|
|
20
|
+
"accordionItemPlaceholderContent": "Your content here..."
|
|
21
|
+
}
|