@omnia/velcron 8.0.159-dev → 8.0.162-dev

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.
@@ -1,6 +1,6 @@
1
1
  import { IFontAwesomeIcon } from "@omnia/fx-models";
2
2
  import { DynamicState } from "../DynamicState";
3
- import { VelcronEvent, VelcronOnEditModeEvent, VelcronOnLoadEvent, VelcronOnPersistingStateEvent, VelcronOnSavingEvent } from "./VelcronEvents";
3
+ import { VelcronEvent, VelcronOnActiveEvent, VelcronOnEditModeEvent, VelcronOnLoadEvent, VelcronOnPersistingStateEvent, VelcronOnSavingEvent } from "./VelcronEvents";
4
4
  /**
5
5
  * Velcron definition base
6
6
  */
@@ -31,9 +31,11 @@ export interface VelcronSpacing {
31
31
  bottom?: number | string;
32
32
  left?: number | string;
33
33
  }
34
+ export type VelcronSpacingTypes = "inner" | "layout";
34
35
  interface VelcronDimensionStyling {
35
36
  margin?: VelcronSpacing;
36
37
  padding?: VelcronSpacing;
38
+ spacingType?: VelcronSpacingTypes;
37
39
  }
38
40
  export interface VelcronStyling {
39
41
  margin?: number;
@@ -75,7 +77,7 @@ export interface VelcronAppDefinition<TState extends DynamicState = DynamicState
75
77
  version?: string;
76
78
  name?: string;
77
79
  body?: Array<VelcronDefinition>;
78
- events?: VelcronOnLoadEvent & VelcronOnEditModeEvent & VelcronOnSavingEvent & VelcronOnPersistingStateEvent;
80
+ events?: VelcronOnLoadEvent & VelcronOnEditModeEvent & VelcronOnSavingEvent & VelcronOnPersistingStateEvent & VelcronOnActiveEvent;
79
81
  actions?: {
80
82
  [name: string]: Array<string>;
81
83
  };
@@ -7,6 +7,9 @@ export type VelcronOnLoadEvent = {
7
7
  export type VelcronOnSavingEvent = {
8
8
  onSaving?: Array<string>;
9
9
  };
10
+ export type VelcronOnActiveEvent = {
11
+ onActive?: Array<string>;
12
+ };
10
13
  export type VelcronOnPersistingStateEvent = {
11
14
  onPersistState?: Array<string>;
12
15
  onRestoreState?: Array<string>;
@@ -1,4 +1,4 @@
1
- import { VelcronOnUpdatedEvent, VelcronOnClosedEvent, VelcronOnCloseRequestedEvent, VelcronOnPressEvent, VelcronSpacing, VelcronStyling, VelcronCustomComponentDefinition, VelcronAppDefinition, VelcronRendererResolverReference, EventHook, Future, TextBlueprint, VelcronBindableProp, ContainerBlueprint, BackgroundDefinition } from "@omnia/velcron/internal-do-not-import-from-here/shared/models";
1
+ import { VelcronOnUpdatedEvent, VelcronOnClosedEvent, VelcronOnCloseRequestedEvent, VelcronOnPressEvent, VelcronSpacing, VelcronStyling, VelcronCustomComponentDefinition, VelcronAppDefinition, VelcronRendererResolverReference, EventHook, Future, TextBlueprint, VelcronBindableProp, ContainerBlueprint, BackgroundDefinition, VelcronStateEditor } from "@omnia/velcron/internal-do-not-import-from-here/shared/models";
2
2
  import { VelcroncomponentArrayType, VelcronPrimitiveType } from "./VelcronTypes";
3
3
  import { AssignOperators, VelcronHorizontalAlignments, VelcronIconTypes, VelcronActionTypes, VelcronVerticalAlignments } from "./Enums";
4
4
  import { DynamicState, VelcronDefinition, useVelcronThemingStore } from "..";
@@ -35,6 +35,7 @@ export interface BuiltInComponentRenderers {
35
35
  "rive": unknown;
36
36
  "lottie": unknown;
37
37
  "slide-panel": unknown;
38
+ "editor": unknown;
38
39
  }
39
40
  export interface ColorSchemaReference {
40
41
  name: string;
@@ -63,7 +64,8 @@ export interface VelcronRenderContext {
63
64
  parent?: VelcronRenderContext;
64
65
  hooks?: VelcronRenderContextHooks;
65
66
  eventHandlers?: VelcronRenderContextEventHandlersInstance;
66
- editMode?: boolean;
67
+ $editmode?: boolean;
68
+ $active?: boolean;
67
69
  disposers: Array<() => void>;
68
70
  subApp?: boolean;
69
71
  }
@@ -293,6 +295,12 @@ export interface VelcronSlidePanelDefinition extends VelcronDefinition {
293
295
  style?: VelcronCardStyling;
294
296
  events?: VelcronOnPressEvent;
295
297
  }
298
+ export interface VelcronEditorDefinition extends VelcronDefinition {
299
+ type: "editor";
300
+ editor: VelcronStateEditor;
301
+ value: VelcronBindableProp<string>;
302
+ events?: VelcronOnUpdatedEvent;
303
+ }
296
304
  export interface VelcronDimensions {
297
305
  top: number | string;
298
306
  right: number | string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "8.0.159-dev",
4
+ "version": "8.0.162-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -24,6 +24,7 @@ export declare const VelcronConstants: {
24
24
  rive: string;
25
25
  lottie: string;
26
26
  "slide-panel": string;
27
+ editor: string;
27
28
  };
28
29
  events: {
29
30
  idTokenStart: string;
@@ -42,6 +43,8 @@ export declare const VelcronConstants: {
42
43
  };
43
44
  context: {
44
45
  thisToken: string;
46
+ editModeToken: string;
47
+ activeToken: string;
45
48
  };
46
49
  async: {
47
50
  noWaitToken: string;
@@ -27,6 +27,7 @@ exports.VelcronConstants = {
27
27
  rive: "rive",
28
28
  lottie: "lottie",
29
29
  "slide-panel": "slide-panel",
30
+ editor: "editor",
30
31
  },
31
32
  events: {
32
33
  idTokenStart: "$ev{",
@@ -44,7 +45,9 @@ exports.VelcronConstants = {
44
45
  propsToken: "$props"
45
46
  },
46
47
  context: {
47
- thisToken: "$this"
48
+ thisToken: "$this",
49
+ editModeToken: "$editmode",
50
+ activeToken: "$active"
48
51
  },
49
52
  async: {
50
53
  noWaitToken: "nowait",
@@ -10,11 +10,18 @@ class VelcronData {
10
10
  if (!VelcronData.isString(text)) {
11
11
  return text;
12
12
  }
13
+ //Bound to one state property and supports 2 way data binding > $bind: $state.title
13
14
  if (text.startsWith(VelcronConstants_1.VelcronConstants.state.bindToken)) {
14
- //Bound to one state property and supports 2 way data binding > $bind: $state.title
15
15
  text = text.substring(VelcronConstants_1.VelcronConstants.state.bindToken.length).trim();
16
16
  return VelcronData.getOrSet(renderContext, text);
17
17
  }
18
+ //Built-in context tokens
19
+ if (text === VelcronConstants_1.VelcronConstants.context.editModeToken) {
20
+ return renderContext.$editmode;
21
+ }
22
+ else if (text === VelcronConstants_1.VelcronConstants.context.activeToken) {
23
+ return renderContext.$active;
24
+ }
18
25
  //String interpolation > {{ $state.title }} and {{ $state.description }}
19
26
  const tokens = this.getTokens(text, false);
20
27
  tokens.forEach((token) => {
@@ -92,6 +99,13 @@ class VelcronData {
92
99
  else if (overrideNamesMatching) {
93
100
  propertiesToEval = overrideNamesMatching;
94
101
  }
102
+ propertiesToEval ??= {};
103
+ if (template.indexOf(VelcronConstants_1.VelcronConstants.context.editModeToken) > -1) {
104
+ propertiesToEval[VelcronConstants_1.VelcronConstants.context.editModeToken] = "renderContext";
105
+ }
106
+ if (template.indexOf(VelcronConstants_1.VelcronConstants.context.activeToken) > -1) {
107
+ propertiesToEval[VelcronConstants_1.VelcronConstants.context.activeToken] = "renderContext";
108
+ }
95
109
  const reservedWords = [
96
110
  "null",
97
111
  "return"
@@ -100,8 +114,10 @@ class VelcronData {
100
114
  template = VelcronData.addCtxToVariableNames(template, skipName, reservedWords, propertiesToEval);
101
115
  names.push("rootCtx");
102
116
  names.push("currentCtx");
117
+ names.push("renderContext");
103
118
  obj.push(renderContext.rootContext);
104
119
  obj.push(renderContext.currentContext);
120
+ obj.push(renderContext);
105
121
  //TODO we shouls try catch and return info
106
122
  const evalResult = Function(...names, "\"use strict\";return " + template)(...obj);
107
123
  return evalResult;
@@ -89,7 +89,8 @@ class VelcronRenderers {
89
89
  hooks: currentRenderCtx.hooks,
90
90
  computed: currentRenderCtx.computed,
91
91
  colors: currentRenderCtx.colors,
92
- editMode: currentRenderCtx.editMode,
92
+ $editmode: currentRenderCtx.$editmode,
93
+ $active: currentRenderCtx.$active,
93
94
  //blueprints: currentRenderCtx.blueprints,
94
95
  disposers: currentRenderCtx.disposers,
95
96
  properties: currentRenderCtx.properties,
@@ -89,14 +89,14 @@ class VelcronStyles {
89
89
  const styleBase = { ...definition.style };
90
90
  /**Generic styling */
91
91
  if (definition.margin) {
92
- const spacing = renderCtx.theming.get.spacing();
92
+ const spacing = renderCtx.theming.get.spacing(definition);
93
93
  styleBase["marginTop"] = this.unitProvider.formatDimension((0, __1.getSpacingValueFromBlueprint)(VelcronData_1.VelcronData.dataBind(renderCtx, definition.margin.top), spacing));
94
94
  styleBase["marginRight"] = this.unitProvider.formatDimension((0, __1.getSpacingValueFromBlueprint)(VelcronData_1.VelcronData.dataBind(renderCtx, definition.margin.right), spacing));
95
95
  styleBase["marginBottom"] = this.unitProvider.formatDimension((0, __1.getSpacingValueFromBlueprint)(VelcronData_1.VelcronData.dataBind(renderCtx, definition.margin.bottom), spacing));
96
96
  styleBase["marginLeft"] = this.unitProvider.formatDimension((0, __1.getSpacingValueFromBlueprint)(VelcronData_1.VelcronData.dataBind(renderCtx, definition.margin.left), spacing));
97
97
  }
98
98
  if (definition.padding) {
99
- const spacing = renderCtx.theming.get.spacing();
99
+ const spacing = renderCtx.theming.get.spacing(definition);
100
100
  // const padding:VelcronSpacing = definition.padding instanceof Object ? definition.padding :
101
101
  // VelcronData.getOrSetObjectByPathUsingRenderContext(renderCtx, definition.padding);
102
102
  //const padding = VelcronData.dataBind(renderCtx, definition.padding) as any as VelcronDimensions;
@@ -29,7 +29,7 @@ function isEditMode(definition, bindableProp, renderContext) {
29
29
  if ("edit" in definition && definition.edit !== undefined) {
30
30
  result = parser_1.VelcronData.evaluateBoolean(definition.edit, renderContext);
31
31
  }
32
- else if (renderContext.editMode) {
32
+ else if (renderContext.$editmode) {
33
33
  result = true;
34
34
  }
35
35
  return result;
@@ -8,7 +8,7 @@ export declare const useVelcronColorSchemaStore: (newStateWithName?: string) =>
8
8
  onContainer: ColorDefinition;
9
9
  isContainer: boolean;
10
10
  name: string;
11
- colorSchemaType: "info" | "error" | "primary" | "secondary" | ColorSchemaTypes | "accent1" | "accent2" | "accent3" | "neutral" | "warning" | "notification" | "background" | "dynamic";
11
+ colorSchemaType: "primary" | "secondary" | ColorSchemaTypes | "accent1" | "accent2" | "accent3" | "neutral" | "warning" | "notification" | "background" | "error" | "info" | "dynamic";
12
12
  id: import("@omnia/fx-models").GuidValue;
13
13
  };
14
14
  get: {
@@ -1,4 +1,4 @@
1
- import { ColorSchemaType, ColorSchemaTypes, ColorType, ColorTypes, ContainerBlueprint, ContainerVariant, ThemeDefinitionV2, TypographySize, TypographySizes, TypographyType, TypographyTypes } from "..";
1
+ import { ColorSchemaType, ColorSchemaTypes, ColorType, ColorTypes, ContainerBlueprint, ContainerVariant, ThemeDefinitionV2, TypographySize, TypographySizes, TypographyType, TypographyTypes, VelcronDefinition } from "..";
2
2
  export declare const useVelcronThemingStore: (newStateWithName?: string) => {
3
3
  state: {
4
4
  currentTheme: ThemeDefinitionV2;
@@ -7,7 +7,7 @@ export declare const useVelcronThemingStore: (newStateWithName?: string) => {
7
7
  componentBlueprints: () => void;
8
8
  containerBlueprint: (type: ContainerVariant | ContainerBlueprint | string) => any;
9
9
  colorSchema: (colorSchemaType: ColorSchemaTypes | ColorSchemaType) => import("..").ColorSchema;
10
- spacing: () => import("..").SpacingDefinition;
10
+ spacing: (definition?: VelcronDefinition) => import("..").SpacingDefinition;
11
11
  typography: (typographyType: TypographyTypes | TypographyType, size: TypographySizes | TypographySize) => any;
12
12
  color: (colorSchemaType: ColorSchemaTypes | ColorSchemaType, colorType: ColorTypes | ColorType) => string;
13
13
  colorDefinition: (colorSchemaType: ColorSchemaTypes | ColorSchemaType, colorType: ColorTypes | ColorType) => import("..").ColorDefinition;
@@ -22,8 +22,10 @@ exports.useVelcronThemingStore = (0, _1.defineVelcronStore)("VelcronTheming", {
22
22
  colorSchema: (colorSchemaType) => {
23
23
  return (0, __1.useThemeMethods)(() => state.currentTheme).colorSchema(colorSchemaType);
24
24
  },
25
- spacing: () => {
26
- return state.currentTheme.spacing.primary.inner;
25
+ spacing: (definition) => {
26
+ return definition?.spacingType === "layout" ?
27
+ state.currentTheme.spacing.primary.layout :
28
+ state.currentTheme.spacing.primary.inner;
27
29
  },
28
30
  typography: (typographyType, size) => {
29
31
  const typography = state.currentTheme.typography.primary;