@1urso/generic-editor 0.1.18 → 0.1.19

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 CHANGED
@@ -81,6 +81,22 @@ The editor offers an experience similar to design tools like Canva or Figma:
81
81
  - _Radius_: From 0px (square) to 50% (circle/oval).
82
82
  - _Thickness_: Adds a solid border from 1px to 4px.
83
83
 
84
+ #### Advanced Settings (Formatting and Conditions)
85
+
86
+ **Right-click** and select **Advanced Settings** to access powerful data formatting and conditional styling options.
87
+
88
+ - **Data Formatting**:
89
+
90
+ - _Type_: Choose between Text (Default), Boolean (True/False), Date, or Number/Currency.
91
+ - _Boolean_: Define custom labels for true/false values (e.g., "Active" / "Inactive").
92
+ - _Date_: Custom date patterns (e.g., "DD/MM/YYYY HH:mm").
93
+ - _Number_: Format as Decimal, Currency (with symbol), or Percentage.
94
+
95
+ - **Conditional Formatting**:
96
+ - Define rules to change the element's style based on data values.
97
+ - _Example_: If `price` is greater than `100`, set text color to `red`.
98
+ - Supports multiple rules with operators like Equals, Not Equals, Contains, Greater Than, Less Than, Truthy, and Falsy.
99
+
84
100
  ### Settings and Test Data
85
101
 
86
102
  At the top of the left sidebar, the **Settings** button (gear icon) allows you to simulate how the layout will look with real data.
@@ -204,7 +220,23 @@ The output of `onSave` is a JSON ready to be stored.
204
220
  "fontFamily": "Roboto",
205
221
  "textAlign": "center"
206
222
  },
207
- "dataBinding": "nome" // Optional, used for direct binding
223
+ "dataBinding": "nome", // Optional, used for direct binding
224
+ "formatting": {
225
+ "type": "text" // 'text' | 'boolean' | 'date' | 'number'
226
+ // Extra fields based on type:
227
+ // trueLabel, falseLabel (boolean)
228
+ // dateFormat (date)
229
+ // numberFormat, currencySymbol, decimalPlaces (number)
230
+ },
231
+ "conditions": [
232
+ {
233
+ "id": "rule-1",
234
+ "property": "price",
235
+ "operator": "greaterThan",
236
+ "value": "100",
237
+ "style": { "color": "red", "fontWeight": "bold" }
238
+ }
239
+ ]
208
240
  }
209
241
  ],
210
242
  "listSettings": {
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ interface ElementAdvancedSettingsProps {
3
+ elementId: string;
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ }
7
+ export declare const ElementAdvancedSettings: React.FC<ElementAdvancedSettingsProps>;
8
+ export {};
@@ -1,4 +1,21 @@
1
1
  import { default as React, ReactNode } from 'react';
2
+ export interface IElementCondition {
3
+ id: string;
4
+ property: string;
5
+ operator: 'equals' | 'notEquals' | 'contains' | 'greaterThan' | 'lessThan' | 'truthy' | 'falsy';
6
+ value: string;
7
+ style: React.CSSProperties;
8
+ }
9
+ export interface IElementFormatting {
10
+ type: 'text' | 'number' | 'date' | 'boolean' | 'map';
11
+ dateFormat?: string;
12
+ numberFormat?: 'decimal' | 'currency' | 'percent';
13
+ currencySymbol?: string;
14
+ decimalPlaces?: number;
15
+ trueLabel?: string;
16
+ falseLabel?: string;
17
+ mapping?: Record<string, string>;
18
+ }
2
19
  export interface IElement {
3
20
  id: string;
4
21
  type: 'text' | 'image' | 'box';
@@ -10,6 +27,8 @@ export interface IElement {
10
27
  rotation?: number;
11
28
  style?: React.CSSProperties;
12
29
  dataBinding?: string;
30
+ formatting?: IElementFormatting;
31
+ conditions?: IElementCondition[];
13
32
  }
14
33
  export interface IListSettings {
15
34
  sortProp?: string;