@mapples/inlang 1.1.0 → 1.1.2
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 +406 -98
- package/dist/constants.d.ts +3 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/dims.d.ts +34 -6
- package/dist/dims.d.ts.map +1 -1
- package/dist/dims.js +21 -3
- package/dist/dims.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/state/conditions.d.ts +17 -3
- package/dist/state/conditions.d.ts.map +1 -1
- package/dist/state/conditions.js +17 -3
- package/dist/state/conditions.js.map +1 -1
- package/dist/state/regexp.d.ts +5 -3
- package/dist/state/regexp.d.ts.map +1 -1
- package/dist/state/regexp.js +5 -3
- package/dist/state/regexp.js.map +1 -1
- package/dist/state/types.d.ts +4 -4
- package/dist/state/utils.d.ts +47 -10
- package/dist/state/utils.d.ts.map +1 -1
- package/dist/state/utils.js +48 -11
- package/dist/state/utils.js.map +1 -1
- package/dist/this.d.ts +59 -14
- package/dist/this.d.ts.map +1 -1
- package/dist/this.js +54 -12
- package/dist/this.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,146 +1,454 @@
|
|
|
1
|
-
# @mapples/
|
|
1
|
+
# @mapples/types
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
3
|
+
TypeScript type definitions for the Mapples Open Kit. This package provides all the core type definitions used across the Mapples ecosystem, including component registration, form configurations, and asset management.
|
|
12
4
|
|
|
13
5
|
## Installation
|
|
14
6
|
|
|
15
7
|
```bash
|
|
16
|
-
npm install @mapples/
|
|
8
|
+
npm install @mapples/types
|
|
17
9
|
# or
|
|
18
|
-
yarn add @mapples/
|
|
10
|
+
yarn add @mapples/types
|
|
19
11
|
```
|
|
20
12
|
|
|
21
13
|
## Overview
|
|
22
14
|
|
|
23
|
-
`@mapples/
|
|
15
|
+
The `@mapples/types` package contains essential TypeScript interfaces and types that define the structure and behavior of components, forms, and assets in the Mapples system. These types ensure type safety and provide clear contracts for developers working with the Mapples Open Kit.
|
|
24
16
|
|
|
25
|
-
##
|
|
17
|
+
## Core Types
|
|
26
18
|
|
|
27
|
-
###
|
|
19
|
+
### Action Types
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
- **`DATA_THIS`** – `'(this)'` – Prefix for data-context reference (entire state)
|
|
31
|
-
- **`DOT_SEPARATOR`** – `'.'` – Separator for object paths (e.g. `user.name`)
|
|
21
|
+
#### `Action`
|
|
32
22
|
|
|
33
|
-
|
|
23
|
+
Represents a user action that occurred in the application. Actions are used for tracking user interactions, analytics, and state management.
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
```
|
|
40
32
|
|
|
41
|
-
|
|
33
|
+
#### `ActionPayload`
|
|
42
34
|
|
|
43
|
-
|
|
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`
|
|
35
|
+
Represents the payload data that can be attached to an action.
|
|
47
36
|
|
|
48
|
-
|
|
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
|
+
```
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
**Example:**
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
58
60
|
|
|
59
|
-
####
|
|
61
|
+
#### `MappletType<State>`
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
Represents the configuration interface for a Mapplet application. A Mapplet is a self-contained application that can be embedded or run standalone.
|
|
62
64
|
|
|
63
|
-
|
|
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
|
+
```
|
|
64
71
|
|
|
65
|
-
|
|
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)
|
|
72
|
+
**Example:**
|
|
72
73
|
|
|
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
|
+
```
|
|
74
93
|
|
|
75
|
-
|
|
76
|
-
- **`notEq`** – `(a, b) => a !== b`
|
|
77
|
-
- **`conditionMap`** – `Record<Conditions, ConditionFunc>` mapping enum to functions
|
|
94
|
+
### Asset Types
|
|
78
95
|
|
|
79
|
-
|
|
96
|
+
#### `AssetType`
|
|
97
|
+
|
|
98
|
+
Represents the different types of assets that can be used in the Mapples system.
|
|
80
99
|
|
|
81
100
|
```typescript
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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`
|
|
160
|
+
|
|
161
|
+
Represents a group of components in the component palette.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
interface RegisteredComponentsGroup {
|
|
165
|
+
id: string; // Unique group identifier
|
|
166
|
+
label: string; // Display name
|
|
167
|
+
Icon: ComponentType<SvgProps>; // Group icon
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### `RegisteredComponents`
|
|
172
|
+
|
|
173
|
+
A registry mapping component types to their definitions.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
type RegisteredComponents = Record<string, RegisteredComponent>;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### `StyleKey`
|
|
180
|
+
|
|
181
|
+
Defines a style property configuration.
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
interface StyleKey {
|
|
185
|
+
label: string; // Human-readable label
|
|
186
|
+
value: string; // CSS property name
|
|
187
|
+
forms: StyleFormType[]; // Applicable form types
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Form Types
|
|
192
|
+
|
|
193
|
+
#### `StyleFormType`
|
|
194
|
+
|
|
195
|
+
Enum representing different categories of style forms.
|
|
91
196
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
197
|
+
```typescript
|
|
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`
|
|
214
|
+
|
|
215
|
+
Enum for property form field types.
|
|
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
|
+
```
|
|
96
225
|
|
|
97
|
-
|
|
98
|
-
isDataThis('(this)'); // true
|
|
99
|
-
isDataThis('(this).user.name'); // true
|
|
100
|
-
parseDataThis('(this).user.name'); // ['user', 'name']
|
|
226
|
+
#### `PropsFormField`
|
|
101
227
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
228
|
+
Configuration for component property form fields.
|
|
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
|
+
};
|
|
106
261
|
```
|
|
107
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
|
+
```
|
|
273
|
+
|
|
274
|
+
#### `PropsFormFieldOptions`
|
|
275
|
+
|
|
276
|
+
Union type for form field options.
|
|
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
|
|
307
|
+
|
|
108
308
|
```typescript
|
|
109
309
|
import {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
310
|
+
RegisteredComponent,
|
|
311
|
+
PropsFormField,
|
|
312
|
+
PropsFormType,
|
|
313
|
+
StyleFormType,
|
|
314
|
+
StyleKey,
|
|
315
|
+
} from '@mapples/types';
|
|
316
|
+
|
|
317
|
+
// Define component props
|
|
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
|
+
```
|
|
364
|
+
|
|
365
|
+
### Creating a Component Group
|
|
117
366
|
|
|
118
|
-
|
|
119
|
-
|
|
367
|
+
```typescript
|
|
368
|
+
import { RegisteredComponentsGroup } from '@mapples/types';
|
|
120
369
|
|
|
121
|
-
const
|
|
122
|
-
|
|
370
|
+
const customGroup: RegisteredComponentsGroup = {
|
|
371
|
+
id: 'custom',
|
|
372
|
+
label: 'Custom Components',
|
|
373
|
+
Icon: CustomIcon,
|
|
374
|
+
};
|
|
375
|
+
```
|
|
123
376
|
|
|
124
|
-
|
|
125
|
-
toBool('true'); // true
|
|
126
|
-
toNumber('42'); // 42
|
|
377
|
+
### Working with Form Fields
|
|
127
378
|
|
|
128
|
-
|
|
129
|
-
|
|
379
|
+
```typescript
|
|
380
|
+
import {
|
|
381
|
+
PropsFormField,
|
|
382
|
+
PropsFormType,
|
|
383
|
+
PropsFormFieldOptions,
|
|
384
|
+
} from '@mapples/types';
|
|
385
|
+
|
|
386
|
+
// Text field
|
|
387
|
+
const nameField: PropsFormField = {
|
|
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
|
+
};
|
|
130
420
|
```
|
|
131
421
|
|
|
132
|
-
## Integration
|
|
422
|
+
## Integration with Other Packages
|
|
133
423
|
|
|
134
|
-
|
|
424
|
+
This types package is used throughout the Mapples ecosystem:
|
|
135
425
|
|
|
136
|
-
- **@mapples/
|
|
137
|
-
- **@mapples/
|
|
138
|
-
- **@mapples/ui
|
|
426
|
+
- **@mapples/action**: Uses `Action` and `ActionPayload` types for action management
|
|
427
|
+
- **@mapples/state**: Uses state-related types for state management
|
|
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
|
|
139
432
|
|
|
140
|
-
##
|
|
433
|
+
## Type Safety
|
|
141
434
|
|
|
142
|
-
|
|
435
|
+
All types in this package are designed to provide maximum type safety and IntelliSense support. When working with Mapples components, you'll get:
|
|
143
436
|
|
|
144
|
-
|
|
437
|
+
- Autocomplete for all properties
|
|
438
|
+
- Type checking for component props
|
|
439
|
+
- Validation for form field configurations
|
|
440
|
+
- IntelliSense for style properties
|
|
145
441
|
|
|
146
|
-
|
|
442
|
+
## Contributing
|
|
443
|
+
|
|
444
|
+
When adding new types to this package:
|
|
445
|
+
|
|
446
|
+
1. Follow the existing naming conventions
|
|
447
|
+
2. Add comprehensive TSDoc comments
|
|
448
|
+
3. Include usage examples
|
|
449
|
+
4. Update this README with new types
|
|
450
|
+
5. Ensure all types are exported from the main index file
|
|
451
|
+
|
|
452
|
+
## License
|
|
453
|
+
|
|
454
|
+
MIT
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Separator used
|
|
1
|
+
/** Separator used between parts of function-call and condition strings (e.g. `"key::value"`). */
|
|
2
2
|
export declare const FN_SEPARATOR = "::";
|
|
3
|
-
/** Prefix
|
|
3
|
+
/** Prefix token that identifies a `(this)` data reference in inline-lang expressions. */
|
|
4
4
|
export declare const DATA_THIS = "(this)";
|
|
5
|
-
/** Separator
|
|
5
|
+
/** Separator used when splitting dot-notation property paths. */
|
|
6
6
|
export declare const DOT_SEPARATOR = ".";
|
|
7
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,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,yFAAyF;AACzF,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,iEAAiE;AACjE,eAAO,MAAM,aAAa,MAAM,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Separator used
|
|
1
|
+
/** Separator used between parts of function-call and condition strings (e.g. `"key::value"`). */
|
|
2
2
|
export const FN_SEPARATOR = '::';
|
|
3
|
-
/** Prefix
|
|
3
|
+
/** Prefix token that identifies a `(this)` data reference in inline-lang expressions. */
|
|
4
4
|
export const DATA_THIS = '(this)';
|
|
5
|
-
/** Separator
|
|
5
|
+
/** Separator used when splitting dot-notation property paths. */
|
|
6
6
|
export const DOT_SEPARATOR = '.';
|
|
7
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,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,yFAAyF;AACzF,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAElC,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
|
package/dist/dims.d.ts
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The canonical dimension axis: either `'width'` or `'height'`. */
|
|
2
2
|
export type DimType = 'width' | 'height';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A parsed dimension tuple: `[axis, fraction]`.
|
|
5
|
+
*
|
|
6
|
+
* `fraction` is a value in the range `[0, 1]` representing the percentage of
|
|
7
|
+
* the parent container's corresponding axis, or `1` when no percentage is
|
|
8
|
+
* specified.
|
|
9
|
+
*/
|
|
4
10
|
export type Dims = [DimType, number];
|
|
5
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The string tokens recognised as dimension axis shorthands in inline-lang
|
|
13
|
+
* expressions (`'w'` and `'h'` are short forms; `'width'`/`'height'` are the
|
|
14
|
+
* long forms).
|
|
15
|
+
*/
|
|
6
16
|
export type DimsString = 'w' | 'h' | 'width' | 'height';
|
|
7
17
|
/**
|
|
8
|
-
* Parses a dimension string
|
|
9
|
-
*
|
|
10
|
-
*
|
|
18
|
+
* Parses a dimension string into a `Dims` tuple.
|
|
19
|
+
*
|
|
20
|
+
* Dimension strings follow the pattern `<axis>[::percentage]`, where `axis` is
|
|
21
|
+
* one of `w`, `h`, `width`, or `height`, and the optional `percentage` suffix
|
|
22
|
+
* (separated by `::`) is an integer representing a percentage (e.g. `"w::50"`
|
|
23
|
+
* yields `['width', 0.5]`). When no percentage is provided the fraction
|
|
24
|
+
* defaults to `1`.
|
|
25
|
+
*
|
|
26
|
+
* Returns `null` for any string that does not match the expected pattern.
|
|
27
|
+
*
|
|
28
|
+
* @param dim - The dimension string to parse (e.g. `"w"`, `"height::75"`).
|
|
29
|
+
* @returns A `[DimType, fraction]` tuple, or `null` if the string is invalid.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* parseDims('w'); // ['width', 1]
|
|
34
|
+
* parseDims('h::50'); // ['height', 0.5]
|
|
35
|
+
* parseDims('width::100'); // ['width', 1]
|
|
36
|
+
* parseDims('invalid'); // null
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
11
39
|
* @public
|
|
12
40
|
*/
|
|
13
41
|
export declare const parseDims: (dim: string) => Dims | null;
|
package/dist/dims.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"dims.d.ts","sourceRoot":"","sources":["../src/dims.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,IAS9C,CAAC"}
|
package/dist/dims.js
CHANGED
|
@@ -7,9 +7,27 @@ const mapDimsType = {
|
|
|
7
7
|
height: 'height',
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* Parses a dimension string
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Parses a dimension string into a `Dims` tuple.
|
|
11
|
+
*
|
|
12
|
+
* Dimension strings follow the pattern `<axis>[::percentage]`, where `axis` is
|
|
13
|
+
* one of `w`, `h`, `width`, or `height`, and the optional `percentage` suffix
|
|
14
|
+
* (separated by `::`) is an integer representing a percentage (e.g. `"w::50"`
|
|
15
|
+
* yields `['width', 0.5]`). When no percentage is provided the fraction
|
|
16
|
+
* defaults to `1`.
|
|
17
|
+
*
|
|
18
|
+
* Returns `null` for any string that does not match the expected pattern.
|
|
19
|
+
*
|
|
20
|
+
* @param dim - The dimension string to parse (e.g. `"w"`, `"height::75"`).
|
|
21
|
+
* @returns A `[DimType, fraction]` tuple, or `null` if the string is invalid.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* parseDims('w'); // ['width', 1]
|
|
26
|
+
* parseDims('h::50'); // ['height', 0.5]
|
|
27
|
+
* parseDims('width::100'); // ['width', 1]
|
|
28
|
+
* parseDims('invalid'); // null
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
13
31
|
* @public
|
|
14
32
|
*/
|
|
15
33
|
export const parseDims = (dim) => {
|
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,uBAAuB,YAAY,SAAS,CAAC,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;AAqB3E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,QAAQ;IACX,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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,11 +1,3 @@
|
|
|
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
|
-
*/
|
|
9
1
|
export * from './this';
|
|
10
2
|
export * from './state';
|
|
11
3
|
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
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
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
|
-
*/
|
|
9
1
|
export * from './this';
|
|
10
2
|
export * from './state';
|
|
11
3
|
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
|
|
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,8 +1,22 @@
|
|
|
1
1
|
import { ConditionFunc, Conditions } from './types';
|
|
2
|
-
/**
|
|
2
|
+
/** Strict-equality condition: returns `true` when `a === b`. */
|
|
3
3
|
export declare const eq: ConditionFunc;
|
|
4
|
-
/**
|
|
4
|
+
/** Strict-inequality condition: returns `true` when `a !== b`. */
|
|
5
5
|
export declare const notEq: ConditionFunc;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Lookup map from each {@link Conditions} operator to its corresponding
|
|
8
|
+
* {@link ConditionFunc} implementation.
|
|
9
|
+
*
|
|
10
|
+
* Use this map to resolve a condition operator string to an executable function
|
|
11
|
+
* at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const fn = conditionMap[Conditions.equals];
|
|
16
|
+
* fn('foo', 'foo'); // true
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
7
21
|
export declare const conditionMap: Record<Conditions, ConditionFunc>;
|
|
8
22
|
//# 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,
|
|
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,gEAAgE;AAChE,eAAO,MAAM,EAAE,EAAE,aAAiC,CAAC;AAEnD,kEAAkE;AAClE,eAAO,MAAM,KAAK,EAAE,aAAiC,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAG1D,CAAC"}
|
package/dist/state/conditions.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { Conditions } from './types';
|
|
2
|
-
/**
|
|
2
|
+
/** Strict-equality condition: returns `true` when `a === b`. */
|
|
3
3
|
export const eq = (a, b) => a === b;
|
|
4
|
-
/**
|
|
4
|
+
/** Strict-inequality condition: returns `true` when `a !== b`. */
|
|
5
5
|
export const notEq = (a, b) => a !== b;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Lookup map from each {@link Conditions} operator to its corresponding
|
|
8
|
+
* {@link ConditionFunc} implementation.
|
|
9
|
+
*
|
|
10
|
+
* Use this map to resolve a condition operator string to an executable function
|
|
11
|
+
* at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const fn = conditionMap[Conditions.equals];
|
|
16
|
+
* fn('foo', 'foo'); // true
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
7
21
|
export const conditionMap = {
|
|
8
22
|
[Conditions.equals]: eq,
|
|
9
23
|
[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,
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/state/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,gEAAgE;AAChE,MAAM,CAAC,MAAM,EAAE,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnD,kEAAkE;AAClE,MAAM,CAAC,MAAM,KAAK,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,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,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Regular expression used to split a condition string on the `::` separator,
|
|
3
|
+
* ignoring any `::` sequences that appear inside double-quoted substrings.
|
|
4
|
+
*
|
|
5
|
+
* This lookahead-based pattern ensures that quoted values (e.g. `"foo::bar"`)
|
|
6
|
+
* are treated as atomic tokens rather than split mid-value.
|
|
5
7
|
*/
|
|
6
8
|
export declare const ConditionStringRegExp: RegExp;
|
|
7
9
|
//# sourceMappingURL=regexp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAkC,CAAC"}
|
package/dist/state/regexp.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Regular expression used to split a condition string on the `::` separator,
|
|
3
|
+
* ignoring any `::` sequences that appear inside double-quoted substrings.
|
|
4
|
+
*
|
|
5
|
+
* This lookahead-based pattern ensures that quoted values (e.g. `"foo::bar"`)
|
|
6
|
+
* are treated as atomic tokens rather than split mid-value.
|
|
5
7
|
*/
|
|
6
8
|
export const ConditionStringRegExp = /::(?=(?:[^"]*"[^"]*")*[^"]*$)/;
|
|
7
9
|
//# 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
|
|
1
|
+
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../src/state/regexp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC"}
|
package/dist/state/types.d.ts
CHANGED
|
@@ -59,10 +59,10 @@ export type ValueType = 'string' | 'number' | 'boolean' | 'dataProp';
|
|
|
59
59
|
* the condition operator, the value to compare against, and the type of that value.
|
|
60
60
|
*
|
|
61
61
|
* @interface ParseConditionResult
|
|
62
|
-
* @property
|
|
63
|
-
* @property
|
|
64
|
-
* @property
|
|
65
|
-
* @property
|
|
62
|
+
* @property dataProp - The data property path to evaluate
|
|
63
|
+
* @property condition - The condition operator to use
|
|
64
|
+
* @property valueProp - The value to compare against
|
|
65
|
+
* @property valueType - The type of the value (string, number, boolean, or dataProp)
|
|
66
66
|
* @public
|
|
67
67
|
*/
|
|
68
68
|
export interface ParseConditionResult {
|
package/dist/state/utils.d.ts
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import { BoolCondition, ParseConditionResult, SimpleCondition } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Joins
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Joins one or more string parts into a single `::` -separated condition
|
|
4
|
+
* string.
|
|
5
|
+
*
|
|
6
|
+
* @param values - The parts to join (e.g. a data-prop, condition operator, and
|
|
7
|
+
* comparison value).
|
|
8
|
+
* @returns A `::` -delimited string (e.g. `"user.age::eq::18"`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* toConditionString('user.age', 'eq', '18'); // 'user.age::eq::18'
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
6
15
|
* @public
|
|
7
16
|
*/
|
|
8
17
|
export declare const toConditionString: (...values: string[]) => string;
|
|
9
18
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
19
|
+
* Parses a raw condition string into its component parts without type coercion
|
|
20
|
+
* of the value.
|
|
21
|
+
*
|
|
22
|
+
* Unlike {@link parseCondition}, this function does not attempt to convert the
|
|
23
|
+
* value to a boolean or detect quoted/typed literals — it returns the raw
|
|
24
|
+
* string fragments and always sets `valueType` to `'string'`. Prefer
|
|
25
|
+
* {@link parseCondition} when the full type-aware parsing is needed.
|
|
26
|
+
*
|
|
27
|
+
* @param value - The raw condition string to parse (e.g. `"user.age::eq::18"`).
|
|
28
|
+
* @returns A {@link ParseConditionResult} with `valueType` always set to
|
|
29
|
+
* `'string'`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* parseConditionString('user.age::eq::18');
|
|
34
|
+
* // { dataProp: 'user.age', condition: 'eq', valueProp: '18', valueType: 'string' }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
14
37
|
* @public
|
|
15
38
|
*/
|
|
16
39
|
export declare const parseConditionString: (value: string) => ParseConditionResult;
|
|
@@ -103,9 +126,23 @@ export declare const toBool: (value: string | boolean) => boolean;
|
|
|
103
126
|
*/
|
|
104
127
|
export declare const toNumber: (value: string | boolean) => number;
|
|
105
128
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
129
|
+
* Strips newline characters from `key` and splits it on semicolons, returning
|
|
130
|
+
* an array of the resulting segments.
|
|
131
|
+
*
|
|
132
|
+
* Returns `undefined` when `key` is `undefined`.
|
|
133
|
+
*
|
|
134
|
+
* @param key - An optional semicolon-delimited string, possibly containing
|
|
135
|
+
* newline characters.
|
|
136
|
+
* @returns An array of string segments, or `undefined` if `key` is not
|
|
137
|
+
* provided.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* parseJoin('a;b;c'); // ['a', 'b', 'c']
|
|
142
|
+
* parseJoin('a;\nb'); // ['a', 'b']
|
|
143
|
+
* parseJoin(undefined); // undefined
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
109
146
|
* @public
|
|
110
147
|
*/
|
|
111
148
|
export declare const parseJoin: (key?: string) => string[] | undefined;
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,MAAM,EAAE,WAEpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,yBAErC,CAAC"}
|
package/dist/state/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FN_SEPARATOR } from '
|
|
1
|
+
import { FN_SEPARATOR } from '../constants';
|
|
2
2
|
import { ConditionStringRegExp } from './regexp';
|
|
3
3
|
const mapTypes = {
|
|
4
4
|
str: 'string',
|
|
@@ -9,19 +9,42 @@ const mapTypes = {
|
|
|
9
9
|
boolean: 'boolean',
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Joins
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Joins one or more string parts into a single `::` -separated condition
|
|
13
|
+
* string.
|
|
14
|
+
*
|
|
15
|
+
* @param values - The parts to join (e.g. a data-prop, condition operator, and
|
|
16
|
+
* comparison value).
|
|
17
|
+
* @returns A `::` -delimited string (e.g. `"user.age::eq::18"`).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* toConditionString('user.age', 'eq', '18'); // 'user.age::eq::18'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
15
24
|
* @public
|
|
16
25
|
*/
|
|
17
26
|
export const toConditionString = (...values) => {
|
|
18
27
|
return values.join(FN_SEPARATOR);
|
|
19
28
|
};
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
30
|
+
* Parses a raw condition string into its component parts without type coercion
|
|
31
|
+
* of the value.
|
|
32
|
+
*
|
|
33
|
+
* Unlike {@link parseCondition}, this function does not attempt to convert the
|
|
34
|
+
* value to a boolean or detect quoted/typed literals — it returns the raw
|
|
35
|
+
* string fragments and always sets `valueType` to `'string'`. Prefer
|
|
36
|
+
* {@link parseCondition} when the full type-aware parsing is needed.
|
|
37
|
+
*
|
|
38
|
+
* @param value - The raw condition string to parse (e.g. `"user.age::eq::18"`).
|
|
39
|
+
* @returns A {@link ParseConditionResult} with `valueType` always set to
|
|
40
|
+
* `'string'`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* parseConditionString('user.age::eq::18');
|
|
45
|
+
* // { dataProp: 'user.age', condition: 'eq', valueProp: '18', valueType: 'string' }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
25
48
|
* @public
|
|
26
49
|
*/
|
|
27
50
|
export const parseConditionString = (value) => {
|
|
@@ -166,9 +189,23 @@ export const toNumber = (value) => {
|
|
|
166
189
|
return numValue;
|
|
167
190
|
};
|
|
168
191
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
192
|
+
* Strips newline characters from `key` and splits it on semicolons, returning
|
|
193
|
+
* an array of the resulting segments.
|
|
194
|
+
*
|
|
195
|
+
* Returns `undefined` when `key` is `undefined`.
|
|
196
|
+
*
|
|
197
|
+
* @param key - An optional semicolon-delimited string, possibly containing
|
|
198
|
+
* newline characters.
|
|
199
|
+
* @returns An array of string segments, or `undefined` if `key` is not
|
|
200
|
+
* provided.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* parseJoin('a;b;c'); // ['a', 'b', 'c']
|
|
205
|
+
* parseJoin('a;\nb'); // ['a', 'b']
|
|
206
|
+
* parseJoin(undefined); // undefined
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
172
209
|
* @public
|
|
173
210
|
*/
|
|
174
211
|
export const parseJoin = (key) => {
|
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,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/state/utils.ts"],"names":[],"mappings":"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"}
|
package/dist/this.d.ts
CHANGED
|
@@ -1,33 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Parsed representation of a `this` reference in an inline-lang expression.
|
|
3
|
+
*
|
|
4
|
+
* The first element is always `'this'`. The optional second element is a
|
|
5
|
+
* numeric index string when the reference targets a specific iteration item
|
|
6
|
+
* (e.g. `"this::0"` → `['this', '0']`).
|
|
4
7
|
*/
|
|
5
8
|
export type This = ['this', string?];
|
|
6
9
|
/**
|
|
7
|
-
* Returns
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* Returns `true` when `value` is a quoted `this` reference string.
|
|
11
|
+
*
|
|
12
|
+
* Matches the literal value `"this"` as well as indexed variants such as
|
|
13
|
+
* `"this::0"`.
|
|
14
|
+
*
|
|
15
|
+
* @param value - The string to test.
|
|
16
|
+
* @returns `true` if `value` is a `this` reference, `false` otherwise.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* isThis('"this"'); // true
|
|
21
|
+
* isThis('"this::0"'); // true
|
|
22
|
+
* isThis('other'); // false
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
10
25
|
* @public
|
|
11
26
|
*/
|
|
12
27
|
export declare const isThis: (value?: string) => boolean;
|
|
13
28
|
/**
|
|
14
|
-
* Returns
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
29
|
+
* Returns `true` when `value` begins with the `(this)` data-reference prefix.
|
|
30
|
+
*
|
|
31
|
+
* @param value - The string to test.
|
|
32
|
+
* @returns `true` if `value` is a `(this)` data reference, `false` otherwise.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* isDataThis('(this).name'); // true
|
|
37
|
+
* isDataThis('other'); // false
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
17
40
|
* @public
|
|
18
41
|
*/
|
|
19
42
|
export declare const isDataThis: (value?: string) => boolean | undefined;
|
|
20
43
|
/**
|
|
21
|
-
* Strips the `(this)` prefix
|
|
22
|
-
*
|
|
23
|
-
*
|
|
44
|
+
* Strips the `(this)` prefix from a data-reference string and splits the
|
|
45
|
+
* remaining dot-notation path into an array of property segments.
|
|
46
|
+
*
|
|
47
|
+
* @param value - A `(this)`-prefixed data-reference string (e.g. `"(this).user.name"`).
|
|
48
|
+
* @returns An array of path segments after the `(this)` prefix (e.g. `['', 'user', 'name']`).
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* parseDataThis('(this).user.name'); // ['', 'user', 'name']
|
|
53
|
+
* parseDataThis('(this)'); // ['']
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
24
56
|
* @public
|
|
25
57
|
*/
|
|
26
58
|
export declare const parseDataThis: (value: string) => string[];
|
|
27
59
|
/**
|
|
28
|
-
* Parses a quoted
|
|
29
|
-
*
|
|
30
|
-
*
|
|
60
|
+
* Parses a quoted `this` reference string into a `This` tuple.
|
|
61
|
+
*
|
|
62
|
+
* Strips the surrounding quotes and splits on `::` to separate the `'this'`
|
|
63
|
+
* keyword from an optional index. When `value` is `undefined` or empty,
|
|
64
|
+
* returns the bare `['this']` tuple.
|
|
65
|
+
*
|
|
66
|
+
* @param value - An optional quoted `this` reference string (e.g. `'"this::0"'`).
|
|
67
|
+
* @returns A `This` tuple representing the reference.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* parseThis('"this"'); // ['this']
|
|
72
|
+
* parseThis('"this::0"'); // ['this', '0']
|
|
73
|
+
* parseThis(undefined); // ['this']
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
31
76
|
* @public
|
|
32
77
|
*/
|
|
33
78
|
export declare const parseThis: (value?: string) => This;
|
package/dist/this.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"this.d.ts","sourceRoot":"","sources":["../src/this.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,YAEpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,wBAExC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,aAE1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC"}
|
package/dist/this.js
CHANGED
|
@@ -1,36 +1,78 @@
|
|
|
1
1
|
import { DATA_THIS, DOT_SEPARATOR, FN_SEPARATOR } from './constants';
|
|
2
2
|
const actionThisRegExp = new RegExp(`^"this(${FN_SEPARATOR}\\d+)?"$`);
|
|
3
3
|
/**
|
|
4
|
-
* Returns
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Returns `true` when `value` is a quoted `this` reference string.
|
|
5
|
+
*
|
|
6
|
+
* Matches the literal value `"this"` as well as indexed variants such as
|
|
7
|
+
* `"this::0"`.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The string to test.
|
|
10
|
+
* @returns `true` if `value` is a `this` reference, `false` otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* isThis('"this"'); // true
|
|
15
|
+
* isThis('"this::0"'); // true
|
|
16
|
+
* isThis('other'); // false
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
7
19
|
* @public
|
|
8
20
|
*/
|
|
9
21
|
export const isThis = (value) => {
|
|
10
22
|
return actionThisRegExp.test(value || '');
|
|
11
23
|
};
|
|
12
24
|
/**
|
|
13
|
-
* Returns
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
25
|
+
* Returns `true` when `value` begins with the `(this)` data-reference prefix.
|
|
26
|
+
*
|
|
27
|
+
* @param value - The string to test.
|
|
28
|
+
* @returns `true` if `value` is a `(this)` data reference, `false` otherwise.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* isDataThis('(this).name'); // true
|
|
33
|
+
* isDataThis('other'); // false
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
16
36
|
* @public
|
|
17
37
|
*/
|
|
18
38
|
export const isDataThis = (value) => {
|
|
19
39
|
return value?.startsWith(DATA_THIS);
|
|
20
40
|
};
|
|
21
41
|
/**
|
|
22
|
-
* Strips the `(this)` prefix
|
|
23
|
-
*
|
|
24
|
-
*
|
|
42
|
+
* Strips the `(this)` prefix from a data-reference string and splits the
|
|
43
|
+
* remaining dot-notation path into an array of property segments.
|
|
44
|
+
*
|
|
45
|
+
* @param value - A `(this)`-prefixed data-reference string (e.g. `"(this).user.name"`).
|
|
46
|
+
* @returns An array of path segments after the `(this)` prefix (e.g. `['', 'user', 'name']`).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* parseDataThis('(this).user.name'); // ['', 'user', 'name']
|
|
51
|
+
* parseDataThis('(this)'); // ['']
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
25
54
|
* @public
|
|
26
55
|
*/
|
|
27
56
|
export const parseDataThis = (value) => {
|
|
28
57
|
return value.replace(DATA_THIS, '').split(DOT_SEPARATOR);
|
|
29
58
|
};
|
|
30
59
|
/**
|
|
31
|
-
* Parses a quoted
|
|
32
|
-
*
|
|
33
|
-
*
|
|
60
|
+
* Parses a quoted `this` reference string into a `This` tuple.
|
|
61
|
+
*
|
|
62
|
+
* Strips the surrounding quotes and splits on `::` to separate the `'this'`
|
|
63
|
+
* keyword from an optional index. When `value` is `undefined` or empty,
|
|
64
|
+
* returns the bare `['this']` tuple.
|
|
65
|
+
*
|
|
66
|
+
* @param value - An optional quoted `this` reference string (e.g. `'"this::0"'`).
|
|
67
|
+
* @returns A `This` tuple representing the reference.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* parseThis('"this"'); // ['this']
|
|
72
|
+
* parseThis('"this::0"'); // ['this', '0']
|
|
73
|
+
* parseThis(undefined); // ['this']
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
34
76
|
* @public
|
|
35
77
|
*/
|
|
36
78
|
export const parseThis = (value) => {
|
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;AAWtE;;;;;;;;;;;;;;;;;GAiBG;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;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE;IAC3C,OAAO,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;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;;;;;;;;;;;;;;;;;;GAkBG;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"}
|