@wp-typia/project-tools 0.16.2 → 0.16.5

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 (80) hide show
  1. package/README.md +13 -0
  2. package/dist/runtime/block-generator-service.d.ts +102 -0
  3. package/dist/runtime/block-generator-service.js +268 -0
  4. package/dist/runtime/built-in-block-artifacts.d.ts +37 -0
  5. package/dist/runtime/built-in-block-artifacts.js +1203 -0
  6. package/dist/runtime/built-in-block-code-artifacts.d.ts +31 -0
  7. package/dist/runtime/built-in-block-code-artifacts.js +137 -0
  8. package/dist/runtime/built-in-block-non-ts-artifacts.d.ts +18 -0
  9. package/dist/runtime/built-in-block-non-ts-artifacts.js +563 -0
  10. package/dist/runtime/cli-doctor.js +10 -5
  11. package/dist/runtime/index.d.ts +2 -0
  12. package/dist/runtime/index.js +1 -0
  13. package/dist/runtime/scaffold-apply-utils.d.ts +47 -0
  14. package/dist/runtime/scaffold-apply-utils.js +405 -0
  15. package/dist/runtime/scaffold-identifiers.d.ts +34 -0
  16. package/dist/runtime/scaffold-identifiers.js +82 -0
  17. package/dist/runtime/scaffold.js +33 -0
  18. package/dist/runtime/starter-manifests.d.ts +3 -2
  19. package/dist/runtime/starter-manifests.js +15 -365
  20. package/dist/runtime/template-builtins.d.ts +9 -0
  21. package/dist/runtime/template-builtins.js +31 -1
  22. package/dist/runtime/template-render.d.ts +5 -0
  23. package/dist/runtime/template-render.js +13 -3
  24. package/dist/runtime/template-source.js +9 -3
  25. package/package.json +2 -2
  26. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +4 -4
  27. package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +4 -4
  28. package/templates/_shared/base/src/hooks.ts.mustache +0 -19
  29. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -52
  30. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -123
  31. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
  32. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +0 -305
  33. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/render.php.mustache +0 -152
  34. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -3
  35. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -61
  36. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -43
  37. package/templates/_shared/persistence/core/src/index.tsx.mustache +0 -25
  38. package/templates/_shared/persistence/core/src/interactivity.ts.mustache +0 -308
  39. package/templates/_shared/persistence/core/src/save.tsx.mustache +0 -5
  40. package/templates/_shared/persistence/core/src/validators.ts.mustache +0 -43
  41. package/templates/basic/src/block.json.mustache +0 -51
  42. package/templates/basic/src/edit.tsx.mustache +0 -128
  43. package/templates/basic/src/editor.scss.mustache +0 -8
  44. package/templates/basic/src/hooks.ts.mustache +0 -18
  45. package/templates/basic/src/index.tsx.mustache +0 -45
  46. package/templates/basic/src/render.php.mustache +0 -19
  47. package/templates/basic/src/save.tsx.mustache +0 -30
  48. package/templates/basic/src/style.scss.mustache +0 -40
  49. package/templates/basic/src/types.ts.mustache +0 -56
  50. package/templates/basic/src/validators.ts.mustache +0 -37
  51. package/templates/compound/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -37
  52. package/templates/compound/src/blocks/{{slugKebabCase}}/children.ts.mustache +0 -25
  53. package/templates/compound/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -93
  54. package/templates/compound/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
  55. package/templates/compound/src/blocks/{{slugKebabCase}}/index.tsx.mustache +0 -25
  56. package/templates/compound/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -32
  57. package/templates/compound/src/blocks/{{slugKebabCase}}/style.scss.mustache +0 -31
  58. package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -18
  59. package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -35
  60. package/templates/compound/src/blocks/{{slugKebabCase}}-item/block.json.mustache +0 -35
  61. package/templates/compound/src/blocks/{{slugKebabCase}}-item/edit.tsx.mustache +0 -50
  62. package/templates/compound/src/blocks/{{slugKebabCase}}-item/hooks.ts.mustache +0 -11
  63. package/templates/compound/src/blocks/{{slugKebabCase}}-item/index.tsx.mustache +0 -25
  64. package/templates/compound/src/blocks/{{slugKebabCase}}-item/save.tsx.mustache +0 -24
  65. package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +0 -17
  66. package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +0 -35
  67. package/templates/interactivity/src/block.json.mustache +0 -74
  68. package/templates/interactivity/src/edit.tsx.mustache +0 -270
  69. package/templates/interactivity/src/editor.scss.mustache +0 -8
  70. package/templates/interactivity/src/index.tsx.mustache +0 -33
  71. package/templates/interactivity/src/interactivity.ts.mustache +0 -152
  72. package/templates/interactivity/src/save.tsx.mustache +0 -101
  73. package/templates/interactivity/src/style.scss.mustache +0 -60
  74. package/templates/interactivity/src/types.ts.mustache +0 -32
  75. package/templates/interactivity/src/validators.ts.mustache +0 -47
  76. package/templates/persistence/src/block.json.mustache +0 -52
  77. package/templates/persistence/src/edit.tsx.mustache +0 -165
  78. package/templates/persistence/src/render.php.mustache +0 -120
  79. package/templates/persistence/src/style.scss.mustache +0 -46
  80. package/templates/persistence/src/types.ts.mustache +0 -59
@@ -1,40 +0,0 @@
1
- /**
2
- * {{title}} Block Styles
3
- */
4
-
5
- .{{cssClassName}} {
6
- padding: 20px;
7
- border: 1px solid #ddd;
8
- border-radius: 4px;
9
- background-color: #fff;
10
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
11
-
12
- &.is-hidden {
13
- display: none;
14
- }
15
-
16
- &__content {
17
- font-size: 16px;
18
- line-height: 1.6;
19
- color: #333;
20
-
21
- // Alignment styles
22
- &[data-align="center"] {
23
- text-align: center;
24
- }
25
-
26
- &[data-align="right"] {
27
- text-align: right;
28
- }
29
-
30
- &[data-align="justify"] {
31
- text-align: justify;
32
- }
33
- }
34
-
35
- // Hover state
36
- &:hover {
37
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
38
- transition: box-shadow 0.2s ease;
39
- }
40
- }
@@ -1,56 +0,0 @@
1
- import type { TextAlignment } from "@wp-typia/block-types/block-editor/alignment";
2
- import type {
3
- TypiaValidationError,
4
- ValidationResult,
5
- } from "@wp-typia/block-runtime/validation";
6
- import { tags } from "typia";
7
-
8
- export type { TypiaValidationError, ValidationResult } from "@wp-typia/block-runtime/validation";
9
-
10
- /**
11
- * Block attributes interface
12
- * Typia tags define runtime validation rules
13
- */
14
- export interface {{pascalCase}}Attributes {
15
- /**
16
- * Main block content
17
- */
18
- content: string &
19
- tags.MinLength<1> &
20
- tags.MaxLength<1000> &
21
- tags.Default<"">;
22
-
23
- /**
24
- * Alignment
25
- */
26
- alignment?: TextAlignment &
27
- tags.Default<"left">;
28
-
29
- /**
30
- * Visibility toggle
31
- */
32
- isVisible?: boolean &
33
- tags.Default<true>;
34
-
35
- /**
36
- * Custom CSS class
37
- */
38
- className?: string &
39
- tags.MaxLength<100> &
40
- tags.Default<"">;
41
-
42
- /**
43
- * Generated runtime ID
44
- */
45
- id?: string &
46
- tags.Format<"uuid">;
47
-
48
- /**
49
- * Block version for migrations
50
- */
51
- schemaVersion?: number &
52
- tags.Type<"uint32"> &
53
- tags.Default<1>;
54
- }
55
-
56
- export type {{pascalCase}}ValidationResult = ValidationResult<{{pascalCase}}Attributes>;
@@ -1,37 +0,0 @@
1
- import typia from 'typia';
2
- import currentManifest from "./typia.manifest.json";
3
- import { {{pascalCase}}Attributes, {{pascalCase}}ValidationResult } from "./types";
4
- import { generateBlockId } from "@wp-typia/block-runtime/identifiers";
5
- import { createTemplateValidatorToolkit } from "./validator-toolkit";
6
-
7
- const scaffoldValidators = createTemplateValidatorToolkit<{{pascalCase}}Attributes>({
8
- assert: typia.createAssert<{{pascalCase}}Attributes>(),
9
- clone: typia.misc.createClone<{{pascalCase}}Attributes>() as (
10
- value: {{pascalCase}}Attributes,
11
- ) => {{pascalCase}}Attributes,
12
- is: typia.createIs<{{pascalCase}}Attributes>(),
13
- manifest: currentManifest,
14
- prune: typia.misc.createPrune<{{pascalCase}}Attributes>(),
15
- random: typia.createRandom<{{pascalCase}}Attributes>() as (
16
- ...args: unknown[]
17
- ) => {{pascalCase}}Attributes,
18
- finalize: (normalized) => ({
19
- ...normalized,
20
- id: normalized.id && normalized.id.length > 0 ? normalized.id : generateBlockId(),
21
- }),
22
- validate: typia.createValidate<{{pascalCase}}Attributes>(),
23
- });
24
-
25
- export const validate{{pascalCase}}Attributes =
26
- scaffoldValidators.validateAttributes as (
27
- attributes: unknown,
28
- ) => {{pascalCase}}ValidationResult;
29
-
30
- export const validators = scaffoldValidators.validators;
31
-
32
- export const sanitize{{pascalCase}}Attributes =
33
- scaffoldValidators.sanitizeAttributes as (
34
- attributes: Partial<{{pascalCase}}Attributes>,
35
- ) => {{pascalCase}}Attributes;
36
-
37
- export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;
@@ -1,37 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 3,
4
- "name": "{{namespace}}/{{slugKebabCase}}",
5
- "version": "{{blockMetadataVersion}}",
6
- "title": {{titleJson}},
7
- "category": "{{category}}",
8
- "icon": "{{icon}}",
9
- "description": "{{description}}",
10
- "example": {},
11
- "supports": {
12
- "html": false,
13
- "anchor": true,
14
- "className": true
15
- },
16
- "attributes": {
17
- "heading": {
18
- "type": "string",
19
- "source": "html",
20
- "selector": ".{{cssClassName}}__heading",
21
- "default": {{titleJson}}
22
- },
23
- "intro": {
24
- "type": "string",
25
- "source": "html",
26
- "selector": ".{{cssClassName}}__intro",
27
- "default": "Add and reorder internal items inside this compound block."
28
- },
29
- "showDividers": {
30
- "type": "boolean",
31
- "default": true
32
- }
33
- },
34
- "textdomain": "{{textDomain}}",
35
- "editorScript": "file:./index.js",
36
- "style": "file:./style-index.css"
37
- }
@@ -1,25 +0,0 @@
1
- import type { Template } from '@wordpress/blocks';
2
-
3
- export const DEFAULT_CHILD_BLOCK_NAME = '{{namespace}}/{{slugKebabCase}}-item';
4
-
5
- export const ALLOWED_CHILD_BLOCKS = [
6
- DEFAULT_CHILD_BLOCK_NAME,
7
- // add-child: insert new allowed child block names here
8
- ];
9
-
10
- export const DEFAULT_CHILD_TEMPLATE: Template[] = [
11
- [
12
- DEFAULT_CHILD_BLOCK_NAME,
13
- {
14
- body: 'Add supporting details for the first internal item.',
15
- title: 'First Item',
16
- },
17
- ],
18
- [
19
- DEFAULT_CHILD_BLOCK_NAME,
20
- {
21
- body: 'Add supporting details for the second internal item.',
22
- title: 'Second Item',
23
- },
24
- ],
25
- ];
@@ -1,93 +0,0 @@
1
- import { __ } from '@wordpress/i18n';
2
- import {
3
- InspectorControls,
4
- InnerBlocks,
5
- RichText,
6
- useBlockProps,
7
- } from '@wordpress/block-editor';
8
- import { Notice, PanelBody, ToggleControl } from '@wordpress/components';
9
-
10
- import {
11
- ALLOWED_CHILD_BLOCKS,
12
- DEFAULT_CHILD_TEMPLATE,
13
- } from './children';
14
- import { useTypiaValidation } from './hooks';
15
- import type { {{pascalCase}}Attributes } from './types';
16
- import {
17
- createAttributeUpdater,
18
- validate{{pascalCase}}Attributes,
19
- } from './validators';
20
-
21
- export default function Edit( {
22
- attributes,
23
- setAttributes,
24
- }: {
25
- attributes: {{pascalCase}}Attributes;
26
- setAttributes: ( attrs: Partial< {{pascalCase}}Attributes > ) => void;
27
- } ) {
28
- const { errorMessages, isValid } = useTypiaValidation(
29
- attributes,
30
- validate{{pascalCase}}Attributes
31
- );
32
- const updateAttribute = createAttributeUpdater( attributes, setAttributes );
33
- const blockProps = useBlockProps( {
34
- className: '{{cssClassName}}',
35
- } );
36
-
37
- return (
38
- <>
39
- <InspectorControls>
40
- <PanelBody title={ __( 'Compound Settings', '{{textDomain}}' ) }>
41
- <ToggleControl
42
- label={ __( 'Show dividers between items', '{{textDomain}}' ) }
43
- checked={ attributes.showDividers ?? true }
44
- onChange={ ( value ) => updateAttribute( 'showDividers', value ) }
45
- />
46
- </PanelBody>
47
- { ! isValid && (
48
- <PanelBody title={ __( 'Validation Errors', '{{textDomain}}' ) } initialOpen>
49
- { errorMessages.map( ( error, index ) => (
50
- <Notice key={ index } status="error" isDismissible={ false }>
51
- { error }
52
- </Notice>
53
- ) ) }
54
- </PanelBody>
55
- ) }
56
- </InspectorControls>
57
- <div { ...blockProps }>
58
- <RichText
59
- tagName="h3"
60
- className="{{cssClassName}}__heading"
61
- value={ attributes.heading }
62
- onChange={ ( heading ) => updateAttribute( 'heading', heading ) }
63
- placeholder={ __( {{titleJson}}, '{{textDomain}}' ) }
64
- />
65
- <RichText
66
- tagName="p"
67
- className="{{cssClassName}}__intro"
68
- value={ attributes.intro ?? '' }
69
- onChange={ ( intro ) => updateAttribute( 'intro', intro ) }
70
- placeholder={ __(
71
- 'Add and reorder internal items inside this compound block.',
72
- '{{textDomain}}'
73
- ) }
74
- />
75
- { ! isValid && (
76
- <Notice status="error" isDismissible={ false }>
77
- <ul>
78
- { errorMessages.map( ( error, index ) => <li key={ index }>{ error }</li> ) }
79
- </ul>
80
- </Notice>
81
- ) }
82
- <div className="{{cssClassName}}__items">
83
- <InnerBlocks
84
- allowedBlocks={ ALLOWED_CHILD_BLOCKS }
85
- renderAppender={ InnerBlocks.ButtonBlockAppender }
86
- template={ DEFAULT_CHILD_TEMPLATE }
87
- templateLock={ false }
88
- />
89
- </div>
90
- </div>
91
- </>
92
- );
93
- }
@@ -1,11 +0,0 @@
1
- export {
2
- formatValidationError,
3
- formatValidationErrors,
4
- useTypiaValidation,
5
- } from '../../hooks';
6
-
7
- export type {
8
- TypiaValidationError,
9
- ValidationResult,
10
- ValidationState,
11
- } from '../../hooks';
@@ -1,25 +0,0 @@
1
- import { registerBlockType } from '@wordpress/blocks';
2
- import type { BlockConfiguration } from '@wordpress/blocks';
3
- import {
4
- buildScaffoldBlockRegistration,
5
- type ScaffoldBlockMetadata,
6
- } from '@wp-typia/block-runtime/blocks';
7
-
8
- import Edit from './edit';
9
- import Save from './save';
10
- import metadata from './block.json';
11
- import './style.scss';
12
-
13
- import type { {{pascalCase}}Attributes } from './types';
14
-
15
- const registration = buildScaffoldBlockRegistration<
16
- BlockConfiguration< {{pascalCase}}Attributes >
17
- >( metadata as ScaffoldBlockMetadata, {
18
- edit: Edit,
19
- save: Save,
20
- } );
21
-
22
- registerBlockType< {{pascalCase}}Attributes >(
23
- registration.name,
24
- registration.settings
25
- );
@@ -1,32 +0,0 @@
1
- import { InnerBlocks, RichText, useBlockProps } from '@wordpress/block-editor';
2
-
3
- import type { {{pascalCase}}Attributes } from './types';
4
-
5
- export default function Save( {
6
- attributes,
7
- }: {
8
- attributes: {{pascalCase}}Attributes;
9
- } ) {
10
- return (
11
- <div
12
- { ...useBlockProps.save( {
13
- className: '{{cssClassName}}',
14
- 'data-show-dividers': ( attributes.showDividers ?? true ) ? 'true' : 'false',
15
- } ) }
16
- >
17
- <RichText.Content
18
- tagName="h3"
19
- className="{{cssClassName}}__heading"
20
- value={ attributes.heading }
21
- />
22
- <RichText.Content
23
- tagName="p"
24
- className="{{cssClassName}}__intro"
25
- value={ attributes.intro ?? '' }
26
- />
27
- <div className="{{cssClassName}}__items">
28
- <InnerBlocks.Content />
29
- </div>
30
- </div>
31
- );
32
- }
@@ -1,31 +0,0 @@
1
- .{{cssClassName}} {
2
- border: 1px solid #dcdcde;
3
- border-radius: 12px;
4
- padding: 1.25rem;
5
- background: #fff;
6
- }
7
-
8
- .{{cssClassName}}__heading {
9
- margin: 0 0 0.5rem;
10
- font-size: 1.2rem;
11
- }
12
-
13
- .{{cssClassName}}__intro {
14
- margin: 0 0 1rem;
15
- color: #50575e;
16
- }
17
-
18
- .{{cssClassName}}__items {
19
- display: grid;
20
- gap: 0.75rem;
21
- }
22
-
23
- .{{cssClassName}}[data-show-dividers='true'] .{{compoundChildCssClassName}} {
24
- border-top: 1px solid #dcdcde;
25
- padding-top: 0.75rem;
26
- }
27
-
28
- .{{cssClassName}}[data-show-dividers='true'] .{{compoundChildCssClassName}}:first-child {
29
- border-top: 0;
30
- padding-top: 0;
31
- }
@@ -1,18 +0,0 @@
1
- import type { ValidationResult } from '@wp-typia/block-runtime/validation';
2
- import { tags } from 'typia';
3
-
4
- export type { ValidationResult } from '@wp-typia/block-runtime/validation';
5
-
6
- export interface {{pascalCase}}Attributes {
7
- heading: string &
8
- tags.MinLength< 1 > &
9
- tags.MaxLength< 80 > &
10
- tags.Default< {{titleJson}} >;
11
- intro?: string &
12
- tags.MinLength< 1 > &
13
- tags.MaxLength< 180 > &
14
- tags.Default< 'Add and reorder internal items inside this compound block.' >;
15
- showDividers?: boolean & tags.Default< true >;
16
- }
17
-
18
- export type {{pascalCase}}ValidationResult = ValidationResult< {{pascalCase}}Attributes >;
@@ -1,35 +0,0 @@
1
- import typia from 'typia';
2
- import currentManifest from './typia.manifest.json';
3
- import type {
4
- {{pascalCase}}Attributes,
5
- {{pascalCase}}ValidationResult,
6
- } from './types';
7
- import { createTemplateValidatorToolkit } from '../../validator-toolkit';
8
-
9
- const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}Attributes >( {
10
- assert: typia.createAssert< {{pascalCase}}Attributes >(),
11
- clone: typia.misc.createClone< {{pascalCase}}Attributes >() as (
12
- value: {{pascalCase}}Attributes,
13
- ) => {{pascalCase}}Attributes,
14
- is: typia.createIs< {{pascalCase}}Attributes >(),
15
- manifest: currentManifest,
16
- prune: typia.misc.createPrune< {{pascalCase}}Attributes >(),
17
- random: typia.createRandom< {{pascalCase}}Attributes >() as (
18
- ...args: unknown[]
19
- ) => {{pascalCase}}Attributes,
20
- validate: typia.createValidate< {{pascalCase}}Attributes >(),
21
- } );
22
-
23
- export const validate{{pascalCase}}Attributes =
24
- scaffoldValidators.validateAttributes as (
25
- attributes: unknown
26
- ) => {{pascalCase}}ValidationResult;
27
-
28
- export const validators = scaffoldValidators.validators;
29
-
30
- export const sanitize{{pascalCase}}Attributes =
31
- scaffoldValidators.sanitizeAttributes as (
32
- attributes: Partial< {{pascalCase}}Attributes >
33
- ) => {{pascalCase}}Attributes;
34
-
35
- export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;
@@ -1,35 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 3,
4
- "name": "{{namespace}}/{{slugKebabCase}}-item",
5
- "version": "{{blockMetadataVersion}}",
6
- "title": {{compoundChildTitleJson}},
7
- "category": "{{compoundChildCategory}}",
8
- "icon": "{{compoundChildIcon}}",
9
- "description": "Internal item block used by {{title}}.",
10
- "parent": [
11
- "{{namespace}}/{{slugKebabCase}}"
12
- ],
13
- "example": {},
14
- "supports": {
15
- "html": false,
16
- "inserter": false,
17
- "reusable": false
18
- },
19
- "attributes": {
20
- "title": {
21
- "type": "string",
22
- "source": "html",
23
- "selector": ".{{compoundChildCssClassName}}__title",
24
- "default": {{compoundChildTitleJson}}
25
- },
26
- "body": {
27
- "type": "string",
28
- "source": "html",
29
- "selector": ".{{compoundChildCssClassName}}__body",
30
- "default": "Add supporting details for this internal item."
31
- }
32
- },
33
- "textdomain": "{{textDomain}}",
34
- "editorScript": "file:./index.js"
35
- }
@@ -1,50 +0,0 @@
1
- import { RichText, useBlockProps } from '@wordpress/block-editor';
2
- import { Notice } from '@wordpress/components';
3
- import { __ } from '@wordpress/i18n';
4
-
5
- import { useTypiaValidation } from './hooks';
6
- import type { {{pascalCase}}ItemAttributes } from './types';
7
- import {
8
- createAttributeUpdater,
9
- validate{{pascalCase}}ItemAttributes,
10
- } from './validators';
11
-
12
- export default function Edit( {
13
- attributes,
14
- setAttributes,
15
- }: {
16
- attributes: {{pascalCase}}ItemAttributes;
17
- setAttributes: ( attrs: Partial< {{pascalCase}}ItemAttributes > ) => void;
18
- } ) {
19
- const updateAttribute = createAttributeUpdater( attributes, setAttributes );
20
- const { errorMessages, isValid } = useTypiaValidation(
21
- attributes,
22
- validate{{pascalCase}}ItemAttributes
23
- );
24
-
25
- return (
26
- <div { ...useBlockProps( { className: '{{compoundChildCssClassName}}' } ) }>
27
- <RichText
28
- tagName="h4"
29
- className="{{compoundChildCssClassName}}__title"
30
- value={ attributes.title ?? '' }
31
- onChange={ ( title ) => updateAttribute( 'title', title ) }
32
- placeholder={ __( {{compoundChildTitleJson}}, '{{textDomain}}' ) }
33
- />
34
- <RichText
35
- tagName="p"
36
- className="{{compoundChildCssClassName}}__body"
37
- value={ attributes.body ?? '' }
38
- onChange={ ( body ) => updateAttribute( 'body', body ) }
39
- placeholder={ __( 'Add supporting details for this internal item.', '{{textDomain}}' ) }
40
- />
41
- { ! isValid && (
42
- <Notice status="error" isDismissible={ false }>
43
- <ul>
44
- { errorMessages.map( ( error, index ) => <li key={ index }>{ error }</li> ) }
45
- </ul>
46
- </Notice>
47
- ) }
48
- </div>
49
- );
50
- }
@@ -1,11 +0,0 @@
1
- export {
2
- formatValidationError,
3
- formatValidationErrors,
4
- useTypiaValidation,
5
- } from '../../hooks';
6
-
7
- export type {
8
- TypiaValidationError,
9
- ValidationResult,
10
- ValidationState,
11
- } from '../../hooks';
@@ -1,25 +0,0 @@
1
- import { registerBlockType } from '@wordpress/blocks';
2
- import type { BlockConfiguration } from '@wordpress/blocks';
3
- import {
4
- buildScaffoldBlockRegistration,
5
- type ScaffoldBlockMetadata,
6
- } from '@wp-typia/block-runtime/blocks';
7
-
8
- import Edit from './edit';
9
- import Save from './save';
10
- import metadata from './block.json';
11
- import '../{{slugKebabCase}}/style.scss';
12
-
13
- import type { {{pascalCase}}ItemAttributes } from './types';
14
-
15
- const registration = buildScaffoldBlockRegistration<
16
- BlockConfiguration< {{pascalCase}}ItemAttributes >
17
- >( metadata as ScaffoldBlockMetadata, {
18
- edit: Edit,
19
- save: Save,
20
- } );
21
-
22
- registerBlockType< {{pascalCase}}ItemAttributes >(
23
- registration.name,
24
- registration.settings
25
- );
@@ -1,24 +0,0 @@
1
- import { RichText, useBlockProps } from '@wordpress/block-editor';
2
-
3
- import type { {{pascalCase}}ItemAttributes } from './types';
4
-
5
- export default function Save( {
6
- attributes,
7
- }: {
8
- attributes: {{pascalCase}}ItemAttributes;
9
- } ) {
10
- return (
11
- <div { ...useBlockProps.save( { className: '{{compoundChildCssClassName}}' } ) }>
12
- <RichText.Content
13
- tagName="h4"
14
- className="{{compoundChildCssClassName}}__title"
15
- value={ attributes.title }
16
- />
17
- <RichText.Content
18
- tagName="p"
19
- className="{{compoundChildCssClassName}}__body"
20
- value={ attributes.body }
21
- />
22
- </div>
23
- );
24
- }
@@ -1,17 +0,0 @@
1
- import type { ValidationResult } from '@wp-typia/block-runtime/validation';
2
- import { tags } from 'typia';
3
-
4
- export type { ValidationResult } from '@wp-typia/block-runtime/validation';
5
-
6
- export interface {{pascalCase}}ItemAttributes {
7
- title: string &
8
- tags.MinLength< 1 > &
9
- tags.MaxLength< 80 > &
10
- tags.Default< {{compoundChildTitleJson}} >;
11
- body: string &
12
- tags.MinLength< 1 > &
13
- tags.MaxLength< 280 > &
14
- tags.Default< 'Add supporting details for this internal item.' >;
15
- }
16
-
17
- export type {{pascalCase}}ItemValidationResult = ValidationResult< {{pascalCase}}ItemAttributes >;
@@ -1,35 +0,0 @@
1
- import typia from 'typia';
2
- import currentManifest from './typia.manifest.json';
3
- import type {
4
- {{pascalCase}}ItemAttributes,
5
- {{pascalCase}}ItemValidationResult,
6
- } from './types';
7
- import { createTemplateValidatorToolkit } from '../../validator-toolkit';
8
-
9
- const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}ItemAttributes >( {
10
- assert: typia.createAssert< {{pascalCase}}ItemAttributes >(),
11
- clone: typia.misc.createClone< {{pascalCase}}ItemAttributes >() as (
12
- value: {{pascalCase}}ItemAttributes,
13
- ) => {{pascalCase}}ItemAttributes,
14
- is: typia.createIs< {{pascalCase}}ItemAttributes >(),
15
- manifest: currentManifest,
16
- prune: typia.misc.createPrune< {{pascalCase}}ItemAttributes >(),
17
- random: typia.createRandom< {{pascalCase}}ItemAttributes >() as (
18
- ...args: unknown[]
19
- ) => {{pascalCase}}ItemAttributes,
20
- validate: typia.createValidate< {{pascalCase}}ItemAttributes >(),
21
- } );
22
-
23
- export const validate{{pascalCase}}ItemAttributes =
24
- scaffoldValidators.validateAttributes as (
25
- attributes: unknown
26
- ) => {{pascalCase}}ItemValidationResult;
27
-
28
- export const validators = scaffoldValidators.validators;
29
-
30
- export const sanitize{{pascalCase}}ItemAttributes =
31
- scaffoldValidators.sanitizeAttributes as (
32
- attributes: Partial< {{pascalCase}}ItemAttributes >
33
- ) => {{pascalCase}}ItemAttributes;
34
-
35
- export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;