@mapples/inlang 1.0.1 → 1.1.0
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 +98 -406
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -1
- package/dist/dims.d.ts +9 -0
- package/dist/dims.d.ts.map +1 -1
- package/dist/dims.js +8 -2
- package/dist/dims.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/state/conditions.d.ts +3 -0
- package/dist/state/conditions.d.ts.map +1 -1
- package/dist/state/conditions.js +3 -0
- package/dist/state/conditions.js.map +1 -1
- package/dist/state/regexp.d.ts +5 -0
- package/dist/state/regexp.d.ts.map +1 -1
- package/dist/state/regexp.js +5 -0
- package/dist/state/regexp.js.map +1 -1
- package/dist/state/utils.d.ts +19 -0
- package/dist/state/utils.d.ts.map +1 -1
- package/dist/state/utils.js +19 -0
- package/dist/state/utils.js.map +1 -1
- package/dist/this.d.ts +28 -0
- package/dist/this.d.ts.map +1 -1
- package/dist/this.js +24 -0
- package/dist/this.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,454 +1,146 @@
|
|
|
1
|
-
# @mapples/
|
|
1
|
+
# @mapples/inlang
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Internal language utilities for the Mapples Open Kit. This package provides parsing and evaluation helpers for "this" references, dimension strings, and condition strings used across the Mapples ecosystem (e.g. data bindings, visibility conditions, layout).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **This references** – Parse and detect `"this"` and `"this::n"` style action/context references
|
|
8
|
+
- **Data this** – Parse `(this)` and dot-separated paths for data binding
|
|
9
|
+
- **Dimensions** – Parse dimension strings (e.g. `"w::50"`, `"height::100"`) for width/height
|
|
10
|
+
- **Conditions** – Parse and evaluate condition strings (`dataProp::condition::value`) for visibility and logic
|
|
11
|
+
- **TypeScript** – Full type definitions and TSDoc
|
|
4
12
|
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
npm install @mapples/
|
|
16
|
+
npm install @mapples/inlang
|
|
9
17
|
# or
|
|
10
|
-
yarn add @mapples/
|
|
18
|
+
yarn add @mapples/inlang
|
|
11
19
|
```
|
|
12
20
|
|
|
13
21
|
## Overview
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Core Types
|
|
18
|
-
|
|
19
|
-
### Action Types
|
|
20
|
-
|
|
21
|
-
#### `Action`
|
|
22
|
-
|
|
23
|
-
Represents a user action that occurred in the application. Actions are used for tracking user interactions, analytics, and state management.
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
interface Action {
|
|
27
|
-
time: number; // Timestamp when the action occurred (in milliseconds since epoch)
|
|
28
|
-
type?: string; // Optional string identifier for the type of action
|
|
29
|
-
payload?: ActionPayload; // Optional payload containing additional data about the action
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
#### `ActionPayload`
|
|
34
|
-
|
|
35
|
-
Represents the payload data that can be attached to an action.
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
interface ActionPayload {
|
|
39
|
-
originalEventData?: any[]; // Original event data from the source event
|
|
40
|
-
data?: any; // Custom data payload specific to the action
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Example:**
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { Action, ActionPayload } from '@mapples/types';
|
|
48
|
-
|
|
49
|
-
const userAction: Action = {
|
|
50
|
-
time: Date.now(),
|
|
51
|
-
type: 'BUTTON_PRESSED',
|
|
52
|
-
payload: {
|
|
53
|
-
data: { buttonId: 'submit', userId: '123' },
|
|
54
|
-
originalEventData: ['button', 'press', { x: 100, y: 200 }],
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Mapplet Types
|
|
60
|
-
|
|
61
|
-
#### `MappletType<State>`
|
|
62
|
-
|
|
63
|
-
Represents the configuration interface for a Mapplet application. A Mapplet is a self-contained application that can be embedded or run standalone.
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
interface MappletType<State extends object = object> {
|
|
67
|
-
state?: State; // Optional initial state object for the Mapplet
|
|
68
|
-
onAction?: (action: Action) => void; // Optional callback function to handle actions
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Example:**
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
import { MappletType, Action } from '@mapples/types';
|
|
76
|
-
|
|
77
|
-
interface MyAppState {
|
|
78
|
-
user: { name: string; email: string };
|
|
79
|
-
settings: { theme: string };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const myMapplet: MappletType<MyAppState> = {
|
|
83
|
-
state: {
|
|
84
|
-
user: { name: 'John', email: 'john@example.com' },
|
|
85
|
-
settings: { theme: 'dark' },
|
|
86
|
-
},
|
|
87
|
-
onAction: (action: Action) => {
|
|
88
|
-
console.log('Mapplet action:', action);
|
|
89
|
-
// Handle analytics, logging, etc.
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Asset Types
|
|
95
|
-
|
|
96
|
-
#### `AssetType`
|
|
97
|
-
|
|
98
|
-
Represents the different types of assets that can be used in the Mapples system.
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
type AssetType = 'image' | 'video' | 'icon' | 'font' | 'json';
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**Example:**
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import { AssetType } from '@mapples/types';
|
|
108
|
-
|
|
109
|
-
const imageAsset: AssetType = 'image';
|
|
110
|
-
const videoAsset: AssetType = 'video';
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Component Types
|
|
114
|
-
|
|
115
|
-
#### `RegisteredComponent<T>`
|
|
116
|
-
|
|
117
|
-
Defines the structure for registering components in the Mapples component system. This interface contains all the metadata needed to make a component available in the visual editor.
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
interface RegisteredComponent<T extends object = object> {
|
|
121
|
-
type: string; // Unique component identifier
|
|
122
|
-
groupId: string; // Group this component belongs to
|
|
123
|
-
label: string; // Display name
|
|
124
|
-
Component: ComponentType<PropsWithChildren<T>>; // React component
|
|
125
|
-
Icon: ComponentType<SvgProps>; // Icon for component palette
|
|
126
|
-
initialProps: T; // Default props
|
|
127
|
-
styleKeys: StyleKey[]; // Available style properties
|
|
128
|
-
props: PropsFormField[]; // Property form fields
|
|
129
|
-
actionProps: string[]; // Action-triggering properties
|
|
130
|
-
hidden?: boolean; // Hide from palette
|
|
131
|
-
hasChildren?: boolean; // Can contain children
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Example:**
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
import { RegisteredComponent } from '@mapples/types';
|
|
139
|
-
|
|
140
|
-
interface ButtonProps {
|
|
141
|
-
text: string;
|
|
142
|
-
disabled?: boolean;
|
|
143
|
-
onPress?: () => void;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const buttonComponent: RegisteredComponent<ButtonProps> = {
|
|
147
|
-
type: 'Button',
|
|
148
|
-
groupId: 'inputs',
|
|
149
|
-
label: 'Button',
|
|
150
|
-
Component: Button,
|
|
151
|
-
Icon: ButtonIcon,
|
|
152
|
-
initialProps: { text: 'Click me' },
|
|
153
|
-
styleKeys: [backgroundColorStyle, textColorStyle],
|
|
154
|
-
props: [textField, disabledField],
|
|
155
|
-
actionProps: ['onPress'],
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
#### `RegisteredComponentsGroup`
|
|
23
|
+
`@mapples/inlang` is used by other Mapples packages (e.g. render, form, ui) to interpret configuration strings. It does not depend on React or React Native.
|
|
160
24
|
|
|
161
|
-
|
|
25
|
+
## API Reference
|
|
162
26
|
|
|
163
|
-
|
|
164
|
-
interface RegisteredComponentsGroup {
|
|
165
|
-
id: string; // Unique group identifier
|
|
166
|
-
label: string; // Display name
|
|
167
|
-
Icon: ComponentType<SvgProps>; // Group icon
|
|
168
|
-
}
|
|
169
|
-
```
|
|
27
|
+
### Constants
|
|
170
28
|
|
|
171
|
-
|
|
29
|
+
- **`FN_SEPARATOR`** – `'::'` – Separator used in "this", dim, and condition strings
|
|
30
|
+
- **`DATA_THIS`** – `'(this)'` – Prefix for data-context reference (entire state)
|
|
31
|
+
- **`DOT_SEPARATOR`** – `'.'` – Separator for object paths (e.g. `user.name`)
|
|
172
32
|
|
|
173
|
-
|
|
33
|
+
### This (action/context references)
|
|
174
34
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
35
|
+
- **`This`** – Type: `['this', string?]`
|
|
36
|
+
- **`isThis(value?)`** – Returns whether the string matches `"this"` or `"this::n"`
|
|
37
|
+
- **`isDataThis(value?)`** – Returns whether the string starts with `(this)`
|
|
38
|
+
- **`parseDataThis(value)`** – Strips `(this)` and splits by dot (path segments)
|
|
39
|
+
- **`parseThis(value?)`** – Parses to `['this', n?]` (e.g. `"this::2"` → `['this', '2']`)
|
|
178
40
|
|
|
179
|
-
|
|
41
|
+
### Dims (dimension strings)
|
|
180
42
|
|
|
181
|
-
|
|
43
|
+
- **`DimType`** – `'width' | 'height'`
|
|
44
|
+
- **`Dims`** – `[DimType, number]` (e.g. `['width', 0.5]` for 50%)
|
|
45
|
+
- **`DimsString`** – `'w' | 'h' | 'width' | 'height'`
|
|
46
|
+
- **`parseDims(dim)`** – Parses strings like `"w::50"` or `"height::100"` to `[type, 0..1]` or `null`
|
|
182
47
|
|
|
183
|
-
|
|
184
|
-
interface StyleKey {
|
|
185
|
-
label: string; // Human-readable label
|
|
186
|
-
value: string; // CSS property name
|
|
187
|
-
forms: StyleFormType[]; // Applicable form types
|
|
188
|
-
}
|
|
189
|
-
```
|
|
48
|
+
### State (conditions)
|
|
190
49
|
|
|
191
|
-
|
|
50
|
+
#### Types
|
|
192
51
|
|
|
193
|
-
|
|
52
|
+
- **`Conditions`** – Enum: `equals` (`'eq'`), `notEquals` (`'neq'`)
|
|
53
|
+
- **`SimpleCondition`** – `${string}::${Conditions}::${string}`
|
|
54
|
+
- **`BoolCondition`** – Condition string with `'true'` or `'false'` as value
|
|
55
|
+
- **`ConditionFunc`** – `(a, b) => boolean`
|
|
56
|
+
- **`ValueType`** – `'string' | 'number' | 'boolean' | 'dataProp'`
|
|
57
|
+
- **`ParseConditionResult`** – `{ dataProp, condition, valueProp, valueType }`
|
|
194
58
|
|
|
195
|
-
|
|
59
|
+
#### Regexp
|
|
196
60
|
|
|
197
|
-
|
|
198
|
-
enum StyleFormType {
|
|
199
|
-
Dimension = 'Dimension', // Width, height, min/max dimensions
|
|
200
|
-
Image = 'Image', // Background images, object fit
|
|
201
|
-
Text = 'Text', // Text color, alignment
|
|
202
|
-
Typography = 'Typography', // Font family, size, weight
|
|
203
|
-
Position = 'Position', // Top, left, right, bottom
|
|
204
|
-
Surface = 'Surface', // Background color, opacity
|
|
205
|
-
ScrollSurface = 'ScrollSurface', // Scrollable surface properties
|
|
206
|
-
Borders = 'Borders', // Border width, color, radius
|
|
207
|
-
Shadow = 'Shadow', // Box shadow, elevation
|
|
208
|
-
Spacing = 'Spacing', // Margin, padding
|
|
209
|
-
Svg = 'Svg', // SVG-related properties
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
#### `PropsFormType`
|
|
61
|
+
- **`ConditionStringRegExp`** – Regex used to split condition strings on `::` (respecting quoted segments)
|
|
214
62
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
enum PropsFormType {
|
|
219
|
-
Text = 'Text', // Text input field
|
|
220
|
-
Select = 'Select', // Single selection dropdown
|
|
221
|
-
Switch = 'Switch', // Boolean toggle
|
|
222
|
-
MultiSelect = 'MultiSelect', // Multiple selection dropdown
|
|
223
|
-
}
|
|
224
|
-
```
|
|
63
|
+
#### Utils
|
|
225
64
|
|
|
226
|
-
|
|
65
|
+
- **`toConditionString(...values)`** – Joins values with `FN_SEPARATOR`
|
|
66
|
+
- **`parseConditionString(value)`** – Splits a condition string into parts (valueType default `'string'`)
|
|
67
|
+
- **`parseCondition(value)`** – Parses `SimpleCondition | BoolCondition` into `ParseConditionResult` (handles booleans and quoted types)
|
|
68
|
+
- **`isCondition(value)`** – Type guard for valid condition strings
|
|
69
|
+
- **`toBool(value)`** – Converts string/boolean to boolean (`"true"` → true)
|
|
70
|
+
- **`toNumber(value)`** – Converts string/boolean to number (booleans → 0/1)
|
|
71
|
+
- **`parseJoin(key?)`** – Splits key by `;` and removes newlines (for multi-key data props)
|
|
227
72
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
interface PropsFormField {
|
|
232
|
-
propsKey: string; // Property key in component props
|
|
233
|
-
label: string; // Form field label
|
|
234
|
-
options?: PropsFormFieldOptions; // Options for select fields
|
|
235
|
-
type: PropsFormType; // Form field type
|
|
236
|
-
dataProp?: boolean; // Can be bound to data sources
|
|
237
|
-
}
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
**Example:**
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
import { PropsFormField, PropsFormType } from '@mapples/types';
|
|
244
|
-
|
|
245
|
-
const textField: PropsFormField = {
|
|
246
|
-
propsKey: 'text',
|
|
247
|
-
label: 'Button Text',
|
|
248
|
-
type: PropsFormType.Text,
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const sizeField: PropsFormField = {
|
|
252
|
-
propsKey: 'size',
|
|
253
|
-
label: 'Size',
|
|
254
|
-
type: PropsFormType.Select,
|
|
255
|
-
options: [
|
|
256
|
-
{ label: 'Small', value: 'sm' },
|
|
257
|
-
{ label: 'Medium', value: 'md' },
|
|
258
|
-
{ label: 'Large', value: 'lg' },
|
|
259
|
-
],
|
|
260
|
-
};
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
#### `PropsFormFieldOption`
|
|
264
|
-
|
|
265
|
-
Represents an option in select/multi-select fields.
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
interface PropsFormFieldOption {
|
|
269
|
-
label: string; // Display text
|
|
270
|
-
value: string; // Stored value
|
|
271
|
-
}
|
|
272
|
-
```
|
|
73
|
+
#### Conditions (evaluators)
|
|
273
74
|
|
|
274
|
-
|
|
75
|
+
- **`eq`** – `(a, b) => a === b`
|
|
76
|
+
- **`notEq`** – `(a, b) => a !== b`
|
|
77
|
+
- **`conditionMap`** – `Record<Conditions, ConditionFunc>` mapping enum to functions
|
|
275
78
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
```typescript
|
|
279
|
-
type PropsFormFieldOptions =
|
|
280
|
-
| PropsFormFieldOption[] // Array of options
|
|
281
|
-
| 'typography' // Special typography type
|
|
282
|
-
| AssetType; // Asset type for asset selection
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
#### `ActionFormProps`
|
|
286
|
-
|
|
287
|
-
Configuration for action properties.
|
|
288
|
-
|
|
289
|
-
```typescript
|
|
290
|
-
interface ActionFormProps {
|
|
291
|
-
propsKey: string; // Action property key
|
|
292
|
-
label: string; // Form field label
|
|
293
|
-
}
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
#### `PropsFieldConfig`
|
|
297
|
-
|
|
298
|
-
Mapping of form types to their React components.
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
type PropsFieldConfig = Record<PropsFormType, ComponentType<PropsFormField>>;
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Usage Examples
|
|
305
|
-
|
|
306
|
-
### Registering a Component
|
|
79
|
+
## Usage examples
|
|
307
80
|
|
|
308
81
|
```typescript
|
|
309
82
|
import {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
interface MyButtonProps {
|
|
319
|
-
text: string;
|
|
320
|
-
variant: 'primary' | 'secondary';
|
|
321
|
-
disabled?: boolean;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Create style keys
|
|
325
|
-
const backgroundColorStyle: StyleKey = {
|
|
326
|
-
label: 'Background Color',
|
|
327
|
-
value: 'backgroundColor',
|
|
328
|
-
forms: [StyleFormType.Surface],
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
// Create form fields
|
|
332
|
-
const textField: PropsFormField = {
|
|
333
|
-
propsKey: 'text',
|
|
334
|
-
label: 'Button Text',
|
|
335
|
-
type: PropsFormType.Text,
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const variantField: PropsFormField = {
|
|
339
|
-
propsKey: 'variant',
|
|
340
|
-
label: 'Variant',
|
|
341
|
-
type: PropsFormType.Select,
|
|
342
|
-
options: [
|
|
343
|
-
{ label: 'Primary', value: 'primary' },
|
|
344
|
-
{ label: 'Secondary', value: 'secondary' },
|
|
345
|
-
],
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
// Register the component
|
|
349
|
-
const myButtonComponent: RegisteredComponent<MyButtonProps> = {
|
|
350
|
-
type: 'MyButton',
|
|
351
|
-
groupId: 'custom',
|
|
352
|
-
label: 'My Button',
|
|
353
|
-
Component: MyButton,
|
|
354
|
-
Icon: MyButtonIcon,
|
|
355
|
-
initialProps: {
|
|
356
|
-
text: 'Click me',
|
|
357
|
-
variant: 'primary',
|
|
358
|
-
},
|
|
359
|
-
styleKeys: [backgroundColorStyle],
|
|
360
|
-
props: [textField, variantField],
|
|
361
|
-
actionProps: ['onPress'],
|
|
362
|
-
};
|
|
363
|
-
```
|
|
83
|
+
isThis,
|
|
84
|
+
isDataThis,
|
|
85
|
+
parseDataThis,
|
|
86
|
+
parseThis,
|
|
87
|
+
parseDims,
|
|
88
|
+
DATA_THIS,
|
|
89
|
+
FN_SEPARATOR,
|
|
90
|
+
} from '@mapples/inlang';
|
|
364
91
|
|
|
365
|
-
|
|
92
|
+
// This
|
|
93
|
+
isThis('"this"'); // true
|
|
94
|
+
isThis('"this::1"'); // true
|
|
95
|
+
parseThis('"this::2"'); // ['this', '2']
|
|
366
96
|
|
|
367
|
-
|
|
368
|
-
|
|
97
|
+
// Data this
|
|
98
|
+
isDataThis('(this)'); // true
|
|
99
|
+
isDataThis('(this).user.name'); // true
|
|
100
|
+
parseDataThis('(this).user.name'); // ['user', 'name']
|
|
369
101
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
};
|
|
102
|
+
// Dims
|
|
103
|
+
parseDims('"w::50"'); // ['width', 0.5]
|
|
104
|
+
parseDims('"h::100"'); // ['height', 1]
|
|
105
|
+
parseDims('"width"'); // ['width', 1]
|
|
375
106
|
```
|
|
376
107
|
|
|
377
|
-
### Working with Form Fields
|
|
378
|
-
|
|
379
108
|
```typescript
|
|
380
109
|
import {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
propsKey: 'name',
|
|
389
|
-
label: 'Name',
|
|
390
|
-
type: PropsFormType.Text,
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// Select field with options
|
|
394
|
-
const statusField: PropsFormField = {
|
|
395
|
-
propsKey: 'status',
|
|
396
|
-
label: 'Status',
|
|
397
|
-
type: PropsFormType.Select,
|
|
398
|
-
options: [
|
|
399
|
-
{ label: 'Active', value: 'active' },
|
|
400
|
-
{ label: 'Inactive', value: 'inactive' },
|
|
401
|
-
{ label: 'Pending', value: 'pending' },
|
|
402
|
-
],
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
// Asset selection field
|
|
406
|
-
const imageField: PropsFormField = {
|
|
407
|
-
propsKey: 'image',
|
|
408
|
-
label: 'Image',
|
|
409
|
-
type: PropsFormType.Select,
|
|
410
|
-
options: 'image', // AssetType
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
// Typography field
|
|
414
|
-
const fontField: PropsFormField = {
|
|
415
|
-
propsKey: 'font',
|
|
416
|
-
label: 'Font',
|
|
417
|
-
type: PropsFormType.Select,
|
|
418
|
-
options: 'typography',
|
|
419
|
-
};
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
## Integration with Other Packages
|
|
423
|
-
|
|
424
|
-
This types package is used throughout the Mapples ecosystem:
|
|
110
|
+
parseCondition,
|
|
111
|
+
isCondition,
|
|
112
|
+
toBool,
|
|
113
|
+
toNumber,
|
|
114
|
+
Conditions,
|
|
115
|
+
conditionMap,
|
|
116
|
+
} from '@mapples/inlang';
|
|
425
117
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
- **@mapples/ui**: Uses `RegisteredComponent` and related types for component registration
|
|
429
|
-
- **@mapples/form**: Uses `PropsFormField` and form-related types for property editing
|
|
430
|
-
- **@mapples/style**: Uses `StyleKey` and `StyleFormType` for styling configuration
|
|
431
|
-
- **@mapples/render**: Uses component types for rendering components
|
|
118
|
+
const r = parseCondition('user.age::eq::18' as any);
|
|
119
|
+
// r.dataProp === 'user.age', r.condition === Conditions.equals, r.valueProp === '18'
|
|
432
120
|
|
|
433
|
-
|
|
121
|
+
const br = parseCondition('user.active::eq::true' as any);
|
|
122
|
+
// br.valueProp === true, br.valueType === 'boolean'
|
|
434
123
|
|
|
435
|
-
|
|
124
|
+
isCondition('user.role::eq::admin'); // true
|
|
125
|
+
toBool('true'); // true
|
|
126
|
+
toNumber('42'); // 42
|
|
436
127
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
- IntelliSense for style properties
|
|
128
|
+
const fn = conditionMap[Conditions.equals];
|
|
129
|
+
fn(1, 1); // true
|
|
130
|
+
```
|
|
441
131
|
|
|
442
|
-
##
|
|
132
|
+
## Integration
|
|
443
133
|
|
|
444
|
-
|
|
134
|
+
Used by:
|
|
445
135
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
4. Update this README with new types
|
|
450
|
-
5. Ensure all types are exported from the main index file
|
|
136
|
+
- **@mapples/render** – Data props and condition-based visibility
|
|
137
|
+
- **@mapples/form** – Field bindings and conditional logic
|
|
138
|
+
- **@mapples/ui** – Component props and layout hints
|
|
451
139
|
|
|
452
140
|
## License
|
|
453
141
|
|
|
454
142
|
MIT
|
|
143
|
+
|
|
144
|
+
## Author
|
|
145
|
+
|
|
146
|
+
Oleksandr Soloviov – [mapples.org](https://mapples.org/people/olek_soloviov)
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** Separator used in "this", dim, and condition strings. @public */
|
|
1
2
|
export declare const FN_SEPARATOR = "::";
|
|
3
|
+
/** Prefix for data-context reference (entire state). @public */
|
|
2
4
|
export declare const DATA_THIS = "(this)";
|
|
5
|
+
/** Separator for object paths (e.g. user.name). @public */
|
|
3
6
|
export declare const DOT_SEPARATOR = ".";
|
|
4
7
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,gEAAgE;AAChE,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,2DAA2D;AAC3D,eAAO,MAAM,aAAa,MAAM,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** Separator used in "this", dim, and condition strings. @public */
|
|
1
2
|
export const FN_SEPARATOR = '::';
|
|
3
|
+
/** Prefix for data-context reference (entire state). @public */
|
|
2
4
|
export const DATA_THIS = '(this)';
|
|
5
|
+
/** Separator for object paths (e.g. user.name). @public */
|
|
3
6
|
export const DOT_SEPARATOR = '.';
|
|
4
7
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAElC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
|
package/dist/dims.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/** Dimension axis: width or height. @public */
|
|
1
2
|
export type DimType = 'width' | 'height';
|
|
3
|
+
/** Parsed dimension: [axis, multiplier 0..1]. @public */
|
|
2
4
|
export type Dims = [DimType, number];
|
|
5
|
+
/** Allowed dimension string keys. @public */
|
|
3
6
|
export type DimsString = 'w' | 'h' | 'width' | 'height';
|
|
7
|
+
/**
|
|
8
|
+
* Parses a dimension string like `"w::50"` or `"height::100"` into [type, 0..1].
|
|
9
|
+
* @param dim - Quoted string e.g. `"w::50"` (50% width), `"height"` (100% height)
|
|
10
|
+
* @returns Tuple [DimType, number] or null if format is invalid
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
4
13
|
export declare const parseDims: (dim: string) => Dims | null;
|
|
5
14
|
//# sourceMappingURL=dims.d.ts.map
|
package/dist/dims.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA,+CAA+C;AAC/C,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEzC,yDAAyD;AACzD,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAErC,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC;AASxD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,IAS9C,CAAC"}
|
package/dist/dims.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { FN_SEPARATOR } from './constants';
|
|
2
|
-
const dimRegExp = new RegExp(`^
|
|
2
|
+
const dimRegExp = new RegExp(`^(w|h|width|height)(${FN_SEPARATOR}\\d+)?$`);
|
|
3
3
|
const mapDimsType = {
|
|
4
4
|
w: 'width',
|
|
5
5
|
h: 'height',
|
|
6
6
|
width: 'width',
|
|
7
7
|
height: 'height',
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Parses a dimension string like `"w::50"` or `"height::100"` into [type, 0..1].
|
|
11
|
+
* @param dim - Quoted string e.g. `"w::50"` (50% width), `"height"` (100% height)
|
|
12
|
+
* @returns Tuple [DimType, number] or null if format is invalid
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
9
15
|
export const parseDims = (dim) => {
|
|
10
16
|
if (dimRegExp.test(dim)) {
|
|
11
|
-
const [type, percent] = dim.
|
|
17
|
+
const [type, percent] = dim.split(FN_SEPARATOR);
|
|
12
18
|
const value = parseInt(percent || '', 10);
|
|
13
19
|
return [mapDimsType[type], !isNaN(value) ? value / 100 : 1];
|
|
14
20
|
}
|
package/dist/dims.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dims.js","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"dims.js","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,uBAAuB,YAAY,SAAS,CAAC,CAAC;AAW3E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,QAAQ;IACX,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAe,EAAE;IACpD,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAE1C,OAAO,CAAC,WAAW,CAAC,IAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module @mapples/inlang
|
|
4
|
+
*
|
|
5
|
+
* Internal language utilities for the Mapples Open Kit: parsing and evaluation
|
|
6
|
+
* of "this" references, dimension strings, and condition strings used across
|
|
7
|
+
* data bindings, visibility conditions, and layout.
|
|
8
|
+
*/
|
|
1
9
|
export * from './this';
|
|
2
10
|
export * from './state';
|
|
3
11
|
export * from './dims';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module @mapples/inlang
|
|
4
|
+
*
|
|
5
|
+
* Internal language utilities for the Mapples Open Kit: parsing and evaluation
|
|
6
|
+
* of "this" references, dimension strings, and condition strings used across
|
|
7
|
+
* data bindings, visibility conditions, and layout.
|
|
8
|
+
*/
|
|
1
9
|
export * from './this';
|
|
2
10
|
export * from './state';
|
|
3
11
|
export * from './dims';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ConditionFunc, Conditions } from './types';
|
|
2
|
+
/** Equality condition: (a, b) => a === b. @public */
|
|
2
3
|
export declare const eq: ConditionFunc;
|
|
4
|
+
/** Not-equals condition: (a, b) => a !== b. @public */
|
|
3
5
|
export declare const notEq: ConditionFunc;
|
|
6
|
+
/** Map from Conditions enum to evaluator functions. @public */
|
|
4
7
|
export declare const conditionMap: Record<Conditions, ConditionFunc>;
|
|
5
8
|
//# sourceMappingURL=conditions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,EAAE,EAAE,aAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,qDAAqD;AACrD,eAAO,MAAM,EAAE,EAAE,aAAiC,CAAC;AAEnD,uDAAuD;AACvD,eAAO,MAAM,KAAK,EAAE,aAAiC,CAAC;AAEtD,+DAA+D;AAC/D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAG1D,CAAC"}
|
package/dist/state/conditions.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Conditions } from './types';
|
|
2
|
+
/** Equality condition: (a, b) => a === b. @public */
|
|
2
3
|
export const eq = (a, b) => a === b;
|
|
4
|
+
/** Not-equals condition: (a, b) => a !== b. @public */
|
|
3
5
|
export const notEq = (a, b) => a !== b;
|
|
6
|
+
/** Map from Conditions enum to evaluator functions. @public */
|
|
4
7
|
export const conditionMap = {
|
|
5
8
|
[Conditions.equals]: eq,
|
|
6
9
|
[Conditions.notEquals]: notEq,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,CAAC,MAAM,EAAE,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,qDAAqD;AACrD,MAAM,CAAC,MAAM,EAAE,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,KAAK,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEtD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAsC;IAC7D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE;IACvB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK;CAC9B,CAAC"}
|
package/dist/state/regexp.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,QAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAkC,CAAC"}
|
package/dist/state/regexp.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex to split condition strings on `::` while respecting quoted segments.
|
|
3
|
+
* Used so values like `"a::b"` are not split on the inner `::`.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
1
6
|
export const ConditionStringRegExp = /::(?=(?:[^"]*"[^"]*")*[^"]*$)/;
|
|
2
7
|
//# sourceMappingURL=regexp.js.map
|
package/dist/state/regexp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC"}
|
package/dist/state/utils.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { BoolCondition, ParseConditionResult, SimpleCondition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Joins values with FN_SEPARATOR to build a condition string.
|
|
4
|
+
* @param values - Parts to join (e.g. dataProp, condition, value)
|
|
5
|
+
* @returns Single string with `::` between parts
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
2
8
|
export declare const toConditionString: (...values: string[]) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Splits a condition string into parts; valueType is defaulted to 'string'.
|
|
11
|
+
* For full parsing (booleans, quoted types, dataProp) use parseCondition.
|
|
12
|
+
* @param value - Raw condition string
|
|
13
|
+
* @returns ParseConditionResult with valueType 'string'
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
3
16
|
export declare const parseConditionString: (value: string) => ParseConditionResult;
|
|
4
17
|
/**
|
|
5
18
|
* Parses a condition string into its component parts.
|
|
@@ -89,5 +102,11 @@ export declare const toBool: (value: string | boolean) => boolean;
|
|
|
89
102
|
* @public
|
|
90
103
|
*/
|
|
91
104
|
export declare const toNumber: (value: string | boolean) => number;
|
|
105
|
+
/**
|
|
106
|
+
* Splits a multi-key string by `;` and strips newlines. Used for data-prop keys that join multiple paths.
|
|
107
|
+
* @param key - Optional string (e.g. "user.name;user.email; ")
|
|
108
|
+
* @returns Array of segments, or undefined if key is undefined
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
92
111
|
export declare const parseJoin: (key?: string) => string[] | undefined;
|
|
93
112
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAEb,oBAAoB,EACpB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAWjB,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,MAAM,EAAE,WAEpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,oBAWpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,eAAe,GAAG,aAAa,KACrC,oBAgCF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,GAAG,OAAO,YAI7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,OAAO,WAU/C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,yBAErC,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAEb,oBAAoB,EACpB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAWjB;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,MAAM,EAAE,WAEpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,oBAWpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,eAAe,GAAG,aAAa,KACrC,oBAgCF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,GAAG,OAAO,YAI7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,OAAO,WAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,yBAErC,CAAC"}
|
package/dist/state/utils.js
CHANGED
|
@@ -8,9 +8,22 @@ const mapTypes = {
|
|
|
8
8
|
number: 'number',
|
|
9
9
|
boolean: 'boolean',
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Joins values with FN_SEPARATOR to build a condition string.
|
|
13
|
+
* @param values - Parts to join (e.g. dataProp, condition, value)
|
|
14
|
+
* @returns Single string with `::` between parts
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
11
17
|
export const toConditionString = (...values) => {
|
|
12
18
|
return values.join(FN_SEPARATOR);
|
|
13
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Splits a condition string into parts; valueType is defaulted to 'string'.
|
|
22
|
+
* For full parsing (booleans, quoted types, dataProp) use parseCondition.
|
|
23
|
+
* @param value - Raw condition string
|
|
24
|
+
* @returns ParseConditionResult with valueType 'string'
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
14
27
|
export const parseConditionString = (value) => {
|
|
15
28
|
const [dataProp, condition, valueProp] = value
|
|
16
29
|
.trim()
|
|
@@ -152,6 +165,12 @@ export const toNumber = (value) => {
|
|
|
152
165
|
return 0;
|
|
153
166
|
return numValue;
|
|
154
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Splits a multi-key string by `;` and strips newlines. Used for data-prop keys that join multiple paths.
|
|
170
|
+
* @param key - Optional string (e.g. "user.name;user.email; ")
|
|
171
|
+
* @returns Array of segments, or undefined if key is undefined
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
155
174
|
export const parseJoin = (key) => {
|
|
156
175
|
return key?.replace(/\n/g, '').split(';');
|
|
157
176
|
};
|
package/dist/state/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AASjD,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,MAAgB,EAAE,EAAE;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAwB,EAAE;IAC1E,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,KAAK;SAC3C,IAAI,EAAE;SACN,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEhC,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,SAAuB;QAClC,SAAS,EAAE,SAAS;QACpB,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AAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAA4B,EAAE;IACtE,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,2DAA2D,CAAC,IAAI,CAAC,KAAK,CAAC,CACxE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAuB,EAAE,EAAE;IAChD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAuB,EAAE,EAAE;IAClD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,IAAI,KAAK,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAY,EAAE,EAAE;IACxC,OAAO,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC"}
|
package/dist/this.d.ts
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tuple for parsed action/context "this" reference: `['this', optionalIndex]`.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
1
5
|
export type This = ['this', string?];
|
|
6
|
+
/**
|
|
7
|
+
* Returns whether the string matches an action "this" reference: `"this"` or `"this::n"`.
|
|
8
|
+
* @param value - String to test (e.g. from config)
|
|
9
|
+
* @returns True if the value is a quoted "this" or "this::n" reference
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
2
12
|
export declare const isThis: (value?: string) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Returns whether the string is a data-context reference starting with `(this)`.
|
|
15
|
+
* @param value - String to test
|
|
16
|
+
* @returns True if the value starts with DATA_THIS
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
3
19
|
export declare const isDataThis: (value?: string) => boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Strips the `(this)` prefix and splits the rest by dot into path segments.
|
|
22
|
+
* @param value - Full data-this string (e.g. `(this).user.name`)
|
|
23
|
+
* @returns Array of path segments
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
4
26
|
export declare const parseDataThis: (value: string) => string[];
|
|
27
|
+
/**
|
|
28
|
+
* Parses a quoted "this" or "this::n" string into a This tuple.
|
|
29
|
+
* @param value - Quoted string (e.g. `"this"` or `"this::2"`)
|
|
30
|
+
* @returns `['this']` or `['this', n]`; if value is falsy returns `['this']`
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
5
33
|
export declare const parseThis: (value?: string) => This;
|
|
6
34
|
//# sourceMappingURL=this.d.ts.map
|
package/dist/this.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,YAEpC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,wBAExC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,aAE1C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,YAEpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,wBAExC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,aAE1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC"}
|
package/dist/this.js
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import { DATA_THIS, DOT_SEPARATOR, FN_SEPARATOR } from './constants';
|
|
2
2
|
const actionThisRegExp = new RegExp(`^"this(${FN_SEPARATOR}\\d+)?"$`);
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the string matches an action "this" reference: `"this"` or `"this::n"`.
|
|
5
|
+
* @param value - String to test (e.g. from config)
|
|
6
|
+
* @returns True if the value is a quoted "this" or "this::n" reference
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
3
9
|
export const isThis = (value) => {
|
|
4
10
|
return actionThisRegExp.test(value || '');
|
|
5
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns whether the string is a data-context reference starting with `(this)`.
|
|
14
|
+
* @param value - String to test
|
|
15
|
+
* @returns True if the value starts with DATA_THIS
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
6
18
|
export const isDataThis = (value) => {
|
|
7
19
|
return value?.startsWith(DATA_THIS);
|
|
8
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Strips the `(this)` prefix and splits the rest by dot into path segments.
|
|
23
|
+
* @param value - Full data-this string (e.g. `(this).user.name`)
|
|
24
|
+
* @returns Array of path segments
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
9
27
|
export const parseDataThis = (value) => {
|
|
10
28
|
return value.replace(DATA_THIS, '').split(DOT_SEPARATOR);
|
|
11
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Parses a quoted "this" or "this::n" string into a This tuple.
|
|
32
|
+
* @param value - Quoted string (e.g. `"this"` or `"this::2"`)
|
|
33
|
+
* @returns `['this']` or `['this', n]`; if value is falsy returns `['this']`
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
12
36
|
export const parseThis = (value) => {
|
|
13
37
|
return value ? value.slice(1, -1).split(FN_SEPARATOR) : ['this'];
|
|
14
38
|
};
|
package/dist/this.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"this.js","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,UAAU,YAAY,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"this.js","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,UAAU,YAAY,UAAU,CAAC,CAAC;AAQtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE;IACvC,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE;IAC3C,OAAO,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAQ,EAAE;IAChD,OAAO,KAAK,CAAC,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC,CAAC"}
|