From 5ecde925ef087c005e73eb778581e0d07d7730bc Mon Sep 17 00:00:00 2001 From: Lukas Lieb Date: Thu, 12 Dec 2024 15:33:21 +0100 Subject: [PATCH] Add @vanilla-extract/recipes --- package-lock.json | 101 ++++++++++++++++++ packages/dataclass-editor/package.json | 1 + .../field/entity/FieldEntityAssociation.tsx | 13 ++- .../src/master/AddFieldDialog.tsx | 8 +- .../src/master/useValidation.ts | 4 +- 5 files changed, 120 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c1130f5..dd50dccf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -514,6 +514,14 @@ "tslib": "^2.4.0" } }, + "node_modules/@emotion/hash": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz", + "integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -4782,6 +4790,46 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, + "node_modules/@vanilla-extract/css": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/@vanilla-extract/css/-/css-1.16.1.tgz", + "integrity": "sha512-3jKxH5ty/ZjmGoLAx8liY7e87FRCIJfnuufX/K9fQklu0YHP3ClrNisU++LkZuD+GZleqMSAQMF0r8Otln+OPQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@emotion/hash": "^0.9.0", + "@vanilla-extract/private": "^1.0.6", + "css-what": "^6.1.0", + "cssesc": "^3.0.0", + "csstype": "^3.0.7", + "dedent": "^1.5.3", + "deep-object-diff": "^1.1.9", + "deepmerge": "^4.2.2", + "lru-cache": "^10.4.3", + "media-query-parser": "^2.0.2", + "modern-ahocorasick": "^1.0.0", + "picocolors": "^1.0.0" + } + }, + "node_modules/@vanilla-extract/private": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@vanilla-extract/private/-/private-1.0.6.tgz", + "integrity": "sha512-ytsG/JLweEjw7DBuZ/0JCN4WAQgM9erfSTdS1NQY778hFQSZ6cfCDEZZ0sgVm4k54uNz6ImKB33AYvSR//fjxw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@vanilla-extract/recipes": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@vanilla-extract/recipes/-/recipes-0.5.5.tgz", + "integrity": "sha512-VadU7+IFUwLNLMgks29AHav/K5h7DOEfTU91RItn5vwdPfzduodNg317YbgWCcpm7FSXkuR3B3X8ZOi95UOozA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@vanilla-extract/css": "^1.0.0" + } + }, "node_modules/@vitejs/plugin-react": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.4.tgz", @@ -6484,6 +6532,20 @@ "node": ">= 8" } }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "license": "BSD-2-Clause", + "peer": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -6747,6 +6809,25 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/deep-object-diff": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/deep-object-diff/-/deep-object-diff-1.1.9.tgz", + "integrity": "sha512-Rn+RuwkmkDwCi2/oXOFS9Gsr5lJZu/yTGpK7wAaAIE75CC+LCGEZHpY6VQJa/RoJcrmaA/docWJZvYohlNkWPA==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -10848,6 +10929,17 @@ "node": ">= 0.4" } }, + "node_modules/media-query-parser": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/media-query-parser/-/media-query-parser-2.0.2.tgz", + "integrity": "sha512-1N4qp+jE0pL5Xv4uEcwVUhIkwdUO3S/9gML90nqKA7v7FcOS5vUtatfzok9S9U1EJU8dHWlcv95WLnKmmxZI9w==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.12.5" + } + }, "node_modules/memoizee": { "version": "0.4.17", "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.17.tgz", @@ -11367,6 +11459,14 @@ "ufo": "^1.5.3" } }, + "node_modules/modern-ahocorasick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/modern-ahocorasick/-/modern-ahocorasick-1.1.0.tgz", + "integrity": "sha512-sEKPVl2rM+MNVkGQt3ChdmD8YsigmXdn5NifZn6jiwn9LRJpWm8F3guhaqrJT/JOat6pwpbXEk6kv+b9DMIjsQ==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -15686,6 +15786,7 @@ "devDependencies": { "@testing-library/react": "^16.1.0", "@types/react": "^18.3.3", + "@vanilla-extract/recipes": "^0.5.5", "@vitejs/plugin-react": "^4.3.4", "eslint-plugin-testing-library": "^7.1.1", "jsdom": "^25.0.1", diff --git a/packages/dataclass-editor/package.json b/packages/dataclass-editor/package.json index e32ae92c..a28ac170 100644 --- a/packages/dataclass-editor/package.json +++ b/packages/dataclass-editor/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@testing-library/react": "^16.1.0", "@types/react": "^18.3.3", + "@vanilla-extract/recipes": "^0.5.5", "@vitejs/plugin-react": "^4.3.4", "eslint-plugin-testing-library": "^7.1.1", "jsdom": "^25.0.1", diff --git a/packages/dataclass-editor/src/detail/field/entity/FieldEntityAssociation.tsx b/packages/dataclass-editor/src/detail/field/entity/FieldEntityAssociation.tsx index 2b77b6ae..88c50a88 100644 --- a/packages/dataclass-editor/src/detail/field/entity/FieldEntityAssociation.tsx +++ b/packages/dataclass-editor/src/detail/field/entity/FieldEntityAssociation.tsx @@ -1,5 +1,14 @@ import type { Association } from '@axonivy/dataclass-editor-protocol'; -import { BasicCheckbox, BasicField, BasicSelect, Collapsible, CollapsibleContent, CollapsibleTrigger, Flex } from '@axonivy/ui-components'; +import { + BasicCheckbox, + BasicField, + BasicSelect, + Collapsible, + CollapsibleContent, + CollapsibleTrigger, + Flex, + type MessageData +} from '@axonivy/ui-components'; import { useAppContext } from '../../../context/AppContext'; import { useEntityField } from '../../../context/FieldContext'; import { useMeta } from '../../../context/useMeta'; @@ -36,7 +45,7 @@ const cardinalityItems: Array<{ value: Association; label: string }> = [ { value: 'MANY_TO_ONE', label: 'Many-to-One' } ] as const; -export const cardinalityMessage = (cardinality?: Association) => { +export const cardinalityMessage = (cardinality?: Association): MessageData | undefined => { if (cardinality === 'ONE_TO_MANY') { return { message: 'A One-to-Many association comes with a significant performance impact. Only use it if it is absolutely necessary.', diff --git a/packages/dataclass-editor/src/master/AddFieldDialog.tsx b/packages/dataclass-editor/src/master/AddFieldDialog.tsx index 399c6311..8ab58c10 100644 --- a/packages/dataclass-editor/src/master/AddFieldDialog.tsx +++ b/packages/dataclass-editor/src/master/AddFieldDialog.tsx @@ -27,22 +27,24 @@ import type { DataClass, Field } from '@axonivy/dataclass-editor-protocol'; import { isEntity } from '../data/dataclass-utils'; import { InputFieldWithTypeBrowser } from '../detail/field/InputFieldWithTypeBrowser'; -export const validateFieldName = (name: string, dataClass: DataClass): MessageData => { +export const validateFieldName = (name: string, dataClass: DataClass) => { if (name.trim() === '') { return toErrorMessage('Name cannot be empty.'); } if (dataClass.fields.some(field => field.name === name)) { return toErrorMessage('Name is already taken.'); } + return; }; -export const validateFieldType = (type: string): MessageData => { +export const validateFieldType = (type: string) => { if (type.trim() === '') { return toErrorMessage('Type cannot be empty.'); } + return; }; -const toErrorMessage = (message: string) => { +const toErrorMessage = (message: string): MessageData => { return { message: message, variant: 'error' }; }; diff --git a/packages/dataclass-editor/src/master/useValidation.ts b/packages/dataclass-editor/src/master/useValidation.ts index 57d7f6fe..7841d161 100644 --- a/packages/dataclass-editor/src/master/useValidation.ts +++ b/packages/dataclass-editor/src/master/useValidation.ts @@ -1,10 +1,10 @@ import type { MessageData } from '@axonivy/ui-components'; import { useAppContext } from '../context/AppContext'; -import type { Field } from '@axonivy/dataclass-editor-protocol'; +import type { Field, Severity } from '@axonivy/dataclass-editor-protocol'; export const useValidation = (field?: Field): Array => { const { validationMessages } = useAppContext(); return validationMessages .filter(message => message.path === field?.name) - .map(message => ({ message: message.message, variant: message.severity.toLowerCase() })); + .map(message => ({ message: message.message, variant: message.severity.toLowerCase() as Lowercase })); };