@gem-sdk/system 2.0.0-dev.305 → 2.0.0-dev.371

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.
@@ -5,29 +5,7 @@ const createAttr = (obj)=>{
5
5
  console.error('Expected an object as input.');
6
6
  return;
7
7
  }
8
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
9
- if (isDevOrStaging) {
10
- for(const key in obj){
11
- const value = obj[key];
12
- // 1. Check if the key starts with "data-gp-"
13
- if (!key.startsWith('data-gp-')) {
14
- console.error(`Invalid attribute key: "${key}". Must start with "data-gp-".`);
15
- }
16
- // 2. Check if the key contains uppercase letters
17
- if (key !== key.toLowerCase()) {
18
- console.error(`Invalid attribute key: "${key}". Must not contain uppercase letters.`);
19
- }
20
- // 3. Check if the value is an object (nested object check)
21
- if (typeof value === 'object' && value !== null) {
22
- console.error(`Invalid nested attribute for key "${key}". Nested objects are not supported.`);
23
- }
24
- // 4. Check if the value is a valid type (string or number)
25
- const isValidType = typeof value === 'string' || typeof value === 'number';
26
- if (!isValidType) {
27
- console.error(`Invalid attribute value for key "${key}": ${value}. Must be a string or number.`);
28
- }
29
- }
30
- }
8
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
31
9
  return obj;
32
10
  };
33
11
 
@@ -17,21 +17,7 @@ const createClass = (obj)=>{
17
17
  console.error('Expected an object as input.');
18
18
  return '';
19
19
  }
20
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
21
- if (isDevOrStaging) {
22
- // Validate each class name length
23
- for(const className in obj){
24
- if (className.length > 30) {
25
- console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
26
- }
27
- if (className.includes(' ')) {
28
- console.error(`Class name "${className}" should not contain spaces.`);
29
- }
30
- if (className !== className.toLowerCase()) {
31
- console.error(`Class name "${className}" should be in lowercase.`);
32
- }
33
- }
34
- }
20
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
35
21
  return cls(obj);
36
22
  };
37
23
 
@@ -1,54 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const createStateOrContext = (obj)=>{
4
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
5
- const isValid = (value)=>{
6
- // Ensure value is neither undefined, null, empty string, nor false (except 0)
7
- return value !== undefined && value !== null && value !== '' && value !== false;
8
- };
9
- const validateKey = (key)=>{
10
- // Check key length
11
- if (key.length > 20) {
12
- console.error(`Invalid key "${key}": Key length must not exceed 20 characters.`);
13
- return false;
14
- }
15
- // Ensure no special characters or numbers
16
- const validKeyRegex = /^[a-zA-Z]+$/;
17
- if (!validKeyRegex.test(key)) {
18
- console.error(`Invalid key "${key}": Key must contain only alphabetic characters (no numbers or special characters).`);
19
- return false;
20
- }
21
- // Check camelCase format (should start with lowercase)
22
- const camelCaseRegex = /^[a-z][a-zA-Z]*$/;
23
- if (!camelCaseRegex.test(key)) {
24
- console.error(`Invalid key "${key}": Key must be in camelCase format.`);
25
- return false;
26
- }
27
- return true;
28
- };
29
- const validateObject = (data, depth)=>{
30
- if (depth > 3) {
31
- console.error('Invalid structure: Data must not be nested deeper than 3 levels.');
32
- return false;
33
- }
34
- for(const key in data){
35
- const value = data[key];
36
- // Key validation
37
- if (!validateKey(key)) continue;
38
- // Value validation
39
- if (!isValid(value)) {
40
- console.error(`Invalid value for key "${key}": Value must not be undefined, null, blank, or false.`);
41
- continue;
42
- }
43
- // Recursive check if the value is an object
44
- if (typeof value === 'object' && !Array.isArray(value)) {
45
- validateObject(value, depth + 1);
46
- }
47
- }
48
- };
49
- if (isDevOrStaging) {
50
- validateObject(obj, 1);
51
- }
4
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
52
5
  return obj;
53
6
  };
54
7
 
@@ -2,35 +2,16 @@
2
2
 
3
3
  var toCamelCaseKeys = require('./utils/toCamelCaseKeys.js');
4
4
 
5
- /**
6
- * Properties to ignore with explanations for each
7
- */ const ignoredProperties = {
8
- ignore: 'This property is not supported in the current styling setup.'
5
+ const clearUndefineValue = (obj)=>{
6
+ for(const key in obj){
7
+ if (!obj[key]) delete obj[key];
8
+ }
9
9
  };
10
10
  const createStyle = (obj)=>{
11
11
  const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
12
12
  if (isDevOrStaging) {
13
- for(const key in obj){
14
- const value = obj[key];
15
- // Check if the property is in the ignored list and log the explanation
16
- if (Object.prototype.hasOwnProperty.call(ignoredProperties, key)) {
17
- console.error(`Ignored property detected: "${key}". ${ignoredProperties[key]}`);
18
- }
19
- // Check for uppercase letters, numbers, and special characters (only allow lowercase letters and "-"
20
- const isValidKey = /^[a-z-]+$/.test(key);
21
- if (!isValidKey) {
22
- console.error(`Invalid key "${key}": Keys must be lowercase letters and may only contain "-".`);
23
- }
24
- // Check for nested objects (only support single-level properties)
25
- if (typeof value === 'object' && value !== null) {
26
- console.error(`Invalid nested object for property "${key}". Nested objects are not supported.`);
27
- }
28
- // Check if the value is a valid type
29
- const isValidType = typeof value === 'string' || typeof value === 'number';
30
- if (!isValidType) {
31
- console.error(`Invalid style value for "${key}": ${value}. Must be a string or number.`);
32
- }
33
- }
13
+ clearUndefineValue(obj);
14
+ // validateStyle(obj);
34
15
  }
35
16
  return obj;
36
17
  };
@@ -3,29 +3,7 @@ const createAttr = (obj)=>{
3
3
  console.error('Expected an object as input.');
4
4
  return;
5
5
  }
6
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
7
- if (isDevOrStaging) {
8
- for(const key in obj){
9
- const value = obj[key];
10
- // 1. Check if the key starts with "data-gp-"
11
- if (!key.startsWith('data-gp-')) {
12
- console.error(`Invalid attribute key: "${key}". Must start with "data-gp-".`);
13
- }
14
- // 2. Check if the key contains uppercase letters
15
- if (key !== key.toLowerCase()) {
16
- console.error(`Invalid attribute key: "${key}". Must not contain uppercase letters.`);
17
- }
18
- // 3. Check if the value is an object (nested object check)
19
- if (typeof value === 'object' && value !== null) {
20
- console.error(`Invalid nested attribute for key "${key}". Nested objects are not supported.`);
21
- }
22
- // 4. Check if the value is a valid type (string or number)
23
- const isValidType = typeof value === 'string' || typeof value === 'number';
24
- if (!isValidType) {
25
- console.error(`Invalid attribute value for key "${key}": ${value}. Must be a string or number.`);
26
- }
27
- }
28
- }
6
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
29
7
  return obj;
30
8
  };
31
9
 
@@ -15,21 +15,7 @@ const createClass = (obj)=>{
15
15
  console.error('Expected an object as input.');
16
16
  return '';
17
17
  }
18
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
19
- if (isDevOrStaging) {
20
- // Validate each class name length
21
- for(const className in obj){
22
- if (className.length > 30) {
23
- console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
24
- }
25
- if (className.includes(' ')) {
26
- console.error(`Class name "${className}" should not contain spaces.`);
27
- }
28
- if (className !== className.toLowerCase()) {
29
- console.error(`Class name "${className}" should be in lowercase.`);
30
- }
31
- }
32
- }
18
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
33
19
  return cls(obj);
34
20
  };
35
21
 
@@ -1,52 +1,5 @@
1
1
  const createStateOrContext = (obj)=>{
2
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
3
- const isValid = (value)=>{
4
- // Ensure value is neither undefined, null, empty string, nor false (except 0)
5
- return value !== undefined && value !== null && value !== '' && value !== false;
6
- };
7
- const validateKey = (key)=>{
8
- // Check key length
9
- if (key.length > 20) {
10
- console.error(`Invalid key "${key}": Key length must not exceed 20 characters.`);
11
- return false;
12
- }
13
- // Ensure no special characters or numbers
14
- const validKeyRegex = /^[a-zA-Z]+$/;
15
- if (!validKeyRegex.test(key)) {
16
- console.error(`Invalid key "${key}": Key must contain only alphabetic characters (no numbers or special characters).`);
17
- return false;
18
- }
19
- // Check camelCase format (should start with lowercase)
20
- const camelCaseRegex = /^[a-z][a-zA-Z]*$/;
21
- if (!camelCaseRegex.test(key)) {
22
- console.error(`Invalid key "${key}": Key must be in camelCase format.`);
23
- return false;
24
- }
25
- return true;
26
- };
27
- const validateObject = (data, depth)=>{
28
- if (depth > 3) {
29
- console.error('Invalid structure: Data must not be nested deeper than 3 levels.');
30
- return false;
31
- }
32
- for(const key in data){
33
- const value = data[key];
34
- // Key validation
35
- if (!validateKey(key)) continue;
36
- // Value validation
37
- if (!isValid(value)) {
38
- console.error(`Invalid value for key "${key}": Value must not be undefined, null, blank, or false.`);
39
- continue;
40
- }
41
- // Recursive check if the value is an object
42
- if (typeof value === 'object' && !Array.isArray(value)) {
43
- validateObject(value, depth + 1);
44
- }
45
- }
46
- };
47
- if (isDevOrStaging) {
48
- validateObject(obj, 1);
49
- }
2
+ !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
50
3
  return obj;
51
4
  };
52
5
 
@@ -1,34 +1,15 @@
1
1
  import { toCamelCaseKeys } from './utils/toCamelCaseKeys.js';
2
2
 
3
- /**
4
- * Properties to ignore with explanations for each
5
- */ const ignoredProperties = {
6
- ignore: 'This property is not supported in the current styling setup.'
3
+ const clearUndefineValue = (obj)=>{
4
+ for(const key in obj){
5
+ if (!obj[key]) delete obj[key];
6
+ }
7
7
  };
8
8
  const createStyle = (obj)=>{
9
9
  const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
10
10
  if (isDevOrStaging) {
11
- for(const key in obj){
12
- const value = obj[key];
13
- // Check if the property is in the ignored list and log the explanation
14
- if (Object.prototype.hasOwnProperty.call(ignoredProperties, key)) {
15
- console.error(`Ignored property detected: "${key}". ${ignoredProperties[key]}`);
16
- }
17
- // Check for uppercase letters, numbers, and special characters (only allow lowercase letters and "-"
18
- const isValidKey = /^[a-z-]+$/.test(key);
19
- if (!isValidKey) {
20
- console.error(`Invalid key "${key}": Keys must be lowercase letters and may only contain "-".`);
21
- }
22
- // Check for nested objects (only support single-level properties)
23
- if (typeof value === 'object' && value !== null) {
24
- console.error(`Invalid nested object for property "${key}". Nested objects are not supported.`);
25
- }
26
- // Check if the value is a valid type
27
- const isValidType = typeof value === 'string' || typeof value === 'number';
28
- if (!isValidType) {
29
- console.error(`Invalid style value for "${key}": ${value}. Must be a string or number.`);
30
- }
31
- }
11
+ clearUndefineValue(obj);
12
+ // validateStyle(obj);
32
13
  }
33
14
  return obj;
34
15
  };
@@ -5,12 +5,12 @@ declare const createAttr: (obj: {
5
5
  } | undefined;
6
6
 
7
7
  declare const createStyle: (obj: {
8
- [key: string]: string | number;
8
+ [key: string]: string | number | undefined;
9
9
  }) => {
10
- [key: string]: string | number;
10
+ [key: string]: string | number | undefined;
11
11
  };
12
12
  declare const createStyleReact: (obj: {
13
- [key: string]: string | number;
13
+ [key: string]: string | number | undefined;
14
14
  }) => {
15
15
  [key: string]: any;
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/system",
3
- "version": "2.0.0-dev.305",
3
+ "version": "2.0.0-dev.371",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {},
23
23
  "devDependencies": {
24
- "@gem-sdk/core": "2.0.0-dev.305"
24
+ "@gem-sdk/core": "2.0.0-dev.371"
25
25
  },
26
26
  "module": "dist/esm/index.js",
27
27
  "types": "dist/types/index.d.ts",