xmlui 0.9.21 → 0.9.23

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.
@@ -77,6 +77,7 @@ exports.AppMd = (0, ComponentDefs_1.createMetadata)({
77
77
  themeVarDescriptions: {
78
78
  "maxWidth‑content‑App": "This theme variable defines the maximum width of the main content. If the main " +
79
79
  "content is broader, the engine adds margins to keep the expected maximum size.",
80
+ "maxWidth-App-vertical": "This theme variable defines the app's full width in vertical layouts.",
80
81
  "boxShadow‑header‑App": "This theme variable sets the shadow of the app's header section.",
81
82
  "boxShadow‑navPanel‑App": "This theme variable sets the shadow of the app's navigation panel section " +
82
83
  "(visible only in vertical layouts).",
@@ -86,6 +87,7 @@ exports.AppMd = (0, ComponentDefs_1.createMetadata)({
86
87
  defaultThemeVars: {
87
88
  [`width-navPanel-${COMP}`]: "$space-64",
88
89
  [`maxWidth-content-${COMP}`]: "$maxWidth-content",
90
+ [`maxWidth-${COMP}-vertical`]: "100%",
89
91
  [`boxShadow-header-${COMP}`]: "$boxShadow-spread",
90
92
  [`boxShadow-navPanel-${COMP}`]: "$boxShadow-spread",
91
93
  [`scroll-padding-block-Pages`]: "$space-4",
@@ -7,7 +7,6 @@ const appLayoutNames = [
7
7
  "vertical",
8
8
  "vertical-sticky",
9
9
  "vertical-full-header",
10
- "vertical-constrained-width",
11
10
  "condensed",
12
11
  "condensed-sticky",
13
12
  "horizontal",
@@ -36,6 +36,8 @@ function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollb
36
36
  const { setActiveThemeTone, setActiveThemeId, themes } = (0, ThemeContext_1.useThemes)();
37
37
  const mounted = (0, react_1.useRef)(false);
38
38
  const layoutWithDefaultValue = layout || getThemeVar("layout-App") || "condensed-sticky";
39
+ const isFullVerticalWidth = getThemeVar("maxWidth-App-vertical") === "100%";
40
+ console.log("isVerticalMaxWidth", isFullVerticalWidth);
39
41
  const safeLayout = layoutWithDefaultValue === null || layoutWithDefaultValue === void 0 ? void 0 : layoutWithDefaultValue.trim().replace(/[\u2013\u2014\u2011]/g, "-"); //It replaces all – (–) and — (—) and non-breaking hyphen '‑' symbols with simple dashes (-).
40
42
  const { setLoggedInUser, mediaSize } = (0, AppContext_1.useAppContext)();
41
43
  const hasRegisteredHeader = header !== undefined;
@@ -138,6 +140,8 @@ function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollb
138
140
  logoContentDef,
139
141
  registerSubNavPanelSlot,
140
142
  subNavPanelSlot,
143
+ isFullVerticalWidth,
144
+ scrollWholePage,
141
145
  };
142
146
  }, [
143
147
  hasRegisteredNavPanel,
@@ -153,6 +157,8 @@ function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollb
153
157
  logoContentDef,
154
158
  registerSubNavPanelSlot,
155
159
  subNavPanelSlot,
160
+ isFullVerticalWidth,
161
+ scrollWholePage,
156
162
  ]);
157
163
  (0, react_1.useEffect)(() => {
158
164
  if (navPanelVisible) {
@@ -183,10 +189,7 @@ function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollb
183
189
  content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(wrapperBaseClasses, App_module_scss_1.default.vertical, App_module_scss_1.default.sticky), style: styleWithHelpers, children: [navPanelVisible && (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(App_module_scss_1.default.navPanelWrapper), children: navPanel }), (0, jsx_runtime_1.jsxs)("div", { className: App_module_scss_1.default.contentWrapper, ref: scrollPageContainerRef, children: [(0, jsx_runtime_1.jsx)("header", { ref: headerRefCallback, className: (0, classnames_1.default)(App_module_scss_1.default.headerWrapper, App_module_scss_1.default.sticky), children: header }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapper, ref: noScrollPageContainerRef, children: (0, jsx_runtime_1.jsx)(ScrollContext_1.ScrollContext.Provider, { value: scrollContainerRef, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapperInner, style: pagesWrapperInnerStyle, children: children }) }) }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.footerWrapper, ref: footerRefCallback, children: footer })] })] }));
184
190
  break;
185
191
  case "vertical-full-header":
186
- content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(wrapperBaseClasses, App_module_scss_1.default.verticalFullHeader), style: styleWithHelpers, ref: scrollPageContainerRef, children: [(0, jsx_runtime_1.jsx)("header", { className: (0, classnames_1.default)(App_module_scss_1.default.headerWrapper, App_module_scss_1.default.sticky), ref: headerRefCallback, children: header }), (0, jsx_runtime_1.jsxs)("div", { className: App_module_scss_1.default.content, children: [navPanelVisible && (0, jsx_runtime_1.jsx)("aside", { className: App_module_scss_1.default.navPanelWrapper, children: navPanel }), (0, jsx_runtime_1.jsx)("main", { className: App_module_scss_1.default.contentWrapper, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapper, ref: noScrollPageContainerRef, children: (0, jsx_runtime_1.jsx)(ScrollContext_1.ScrollContext.Provider, { value: scrollContainerRef, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapperInner, style: pagesWrapperInnerStyle, children: children }) }) }) })] }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.footerWrapper, ref: footerRefCallback, children: footer })] }));
187
- break;
188
- case "vertical-constrained-width":
189
- content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(wrapperBaseClasses, App_module_scss_1.default.verticalConstrained), style: styleWithHelpers, ref: scrollPageContainerRef, children: [(0, jsx_runtime_1.jsx)("header", { className: (0, classnames_1.default)(App_module_scss_1.default.headerWrapper, App_module_scss_1.default.sticky), ref: headerRefCallback, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.header, style: { paddingInline: 0 }, children: header }) }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(App_module_scss_1.default.content, App_module_scss_1.default.verticalConstrained), children: [navPanelVisible && (0, jsx_runtime_1.jsx)("aside", { className: App_module_scss_1.default.navPanelWrapper, children: navPanel }), (0, jsx_runtime_1.jsx)("main", { className: App_module_scss_1.default.contentWrapper, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapper, ref: noScrollPageContainerRef, children: (0, jsx_runtime_1.jsx)(ScrollContext_1.ScrollContext.Provider, { value: scrollContainerRef, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapperInner, style: pagesWrapperInnerStyle, children: children }) }) }) })] }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.footerWrapper, ref: footerRefCallback, children: footer })] }));
192
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(wrapperBaseClasses, App_module_scss_1.default.verticalFullHeader), style: styleWithHelpers, ref: scrollPageContainerRef, children: [(0, jsx_runtime_1.jsx)("header", { className: (0, classnames_1.default)(App_module_scss_1.default.headerWrapper, App_module_scss_1.default.sticky), ref: headerRefCallback, children: header }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.contentScroller, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.contentAligner, children: (0, jsx_runtime_1.jsxs)("div", { className: App_module_scss_1.default.content, children: [navPanelVisible && (0, jsx_runtime_1.jsx)("aside", { className: App_module_scss_1.default.navPanelWrapper, children: navPanel }), (0, jsx_runtime_1.jsx)("main", { className: App_module_scss_1.default.contentWrapper, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapper, ref: noScrollPageContainerRef, children: (0, jsx_runtime_1.jsx)(ScrollContext_1.ScrollContext.Provider, { value: scrollContainerRef, children: (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.PagesWrapperInner, style: pagesWrapperInnerStyle, children: children }) }) }) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: App_module_scss_1.default.footerWrapper, ref: footerRefCallback, children: footer })] }));
190
193
  break;
191
194
  case "condensed":
192
195
  case "condensed-sticky":
@@ -213,7 +216,6 @@ function getAppLayoutOrientation(appLayout) {
213
216
  case "vertical":
214
217
  case "vertical-sticky":
215
218
  case "vertical-full-header":
216
- case "vertical-constrained-width":
217
219
  return "vertical";
218
220
  default:
219
221
  return "horizontal";
@@ -40,16 +40,18 @@ function useLogoUrl() {
40
40
  const toneLogoUrl = (0, ThemeContext_1.useResourceUrl)(`resource:logo-${activeThemeTone}`) || logoUrlByTone[activeThemeTone];
41
41
  return toneLogoUrl || baseLogoUrl;
42
42
  }
43
- const AppHeader = ({ children, profileMenu, style = constants_1.EMPTY_OBJECT, logoContent, className, canRestrictContentWidth, navPanelVisible = true, toggleDrawer, showLogo, hasRegisteredNavPanel, title, titleContent, registerSubNavPanelSlot, }) => {
43
+ const AppHeader = ({ children, profileMenu, style = constants_1.EMPTY_OBJECT, logoContent, className, navPanelVisible = true, toggleDrawer, showLogo, hasRegisteredNavPanel, title, titleContent, registerSubNavPanelSlot, }) => {
44
44
  const { mediaSize } = (0, AppContext_1.useAppContext)();
45
45
  const logoUrl = useLogoUrl();
46
46
  const subNavPanelSlot = (0, react_1.useRef)(null);
47
47
  const safeLogoTitle = mediaSize.sizeIndex < 2 ? null : !titleContent && title ? ((0, jsx_runtime_1.jsx)(NavLinkNative_1.NavLink, { to: "/", displayActive: false, style: { paddingLeft: 0 }, children: title })) : (titleContent);
48
+ const layoutContext = (0, AppLayoutContext_1.useAppLayoutContext)();
48
49
  (0, hooks_1.useIsomorphicLayoutEffect)(() => {
49
50
  registerSubNavPanelSlot === null || registerSubNavPanelSlot === void 0 ? void 0 : registerSubNavPanelSlot(subNavPanelSlot.current);
50
51
  }, []);
51
52
  return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(AppHeader_module_scss_1.default.header, className), style: style, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(AppHeader_module_scss_1.default.headerInner, {
52
- [AppHeader_module_scss_1.default.full]: !canRestrictContentWidth,
53
+ [AppHeader_module_scss_1.default.verticalFullHeader]: (layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.layout) === "vertical-full-header",
54
+ [AppHeader_module_scss_1.default.scrollWholePage]: layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.scrollWholePage,
53
55
  }), children: [!navPanelVisible && hasRegisteredNavPanel && ((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: toggleDrawer, icon: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "hamburger" }), variant: "ghost", style: { color: "inherit", flexShrink: 0 } })), (0, jsx_runtime_1.jsx)("div", { className: AppHeader_module_scss_1.default.logoAndTitle, children: (showLogo || !navPanelVisible) &&
54
56
  (logoContent ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: AppHeader_module_scss_1.default.customLogoContainer, children: logoContent }), safeLogoTitle] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!!logoUrl && ((0, jsx_runtime_1.jsx)("div", { className: AppHeader_module_scss_1.default.logoContainer, children: (0, jsx_runtime_1.jsx)(NavLinkNative_1.NavLink, { to: "/", displayActive: false, style: { padding: 0, height: "100%" }, children: (0, jsx_runtime_1.jsx)(LogoNative_1.Logo, {}) }) })), safeLogoTitle] }))) }), (0, jsx_runtime_1.jsx)("div", { ref: subNavPanelSlot, className: AppHeader_module_scss_1.default.subNavPanelSlot }), (0, jsx_runtime_1.jsx)("div", { className: AppHeader_module_scss_1.default.childrenWrapper, children: children }), profileMenu && (0, jsx_runtime_1.jsx)("div", { className: AppHeader_module_scss_1.default.rightItems, children: profileMenu })] }) }));
55
57
  };
@@ -59,6 +61,5 @@ function AppContextAwareAppHeader({ children, logoContent, profileMenu, style, c
59
61
  const { navPanelVisible, toggleDrawer, layout, hasRegisteredNavPanel, navPanelDef, logoContentDef, registerSubNavPanelSlot, } = appLayoutContext || {};
60
62
  // console.log("APP LAYOUT CONTEXT", appLayoutContext);
61
63
  const displayLogo = layout !== "vertical" && layout !== "vertical-sticky" && showLogo;
62
- const canRestrictContentWidth = layout !== "vertical-full-header";
63
- return ((0, jsx_runtime_1.jsxs)(exports.AppHeader, { hasRegisteredNavPanel: hasRegisteredNavPanel, navPanelVisible: navPanelVisible, toggleDrawer: toggleDrawer, canRestrictContentWidth: canRestrictContentWidth, showLogo: displayLogo, logoContent: logoContent || renderChild(logoContentDef), profileMenu: profileMenu, style: style, className: className, title: title, titleContent: titleContent, registerSubNavPanelSlot: registerSubNavPanelSlot, children: [(layout === null || layout === void 0 ? void 0 : layout.startsWith("condensed")) && navPanelVisible && ((0, jsx_runtime_1.jsx)("div", { style: { minWidth: 0 }, children: renderChild(navPanelDef) })), children] }));
64
+ return ((0, jsx_runtime_1.jsxs)(exports.AppHeader, { hasRegisteredNavPanel: hasRegisteredNavPanel, navPanelVisible: navPanelVisible, toggleDrawer: toggleDrawer, showLogo: displayLogo, logoContent: logoContent || renderChild(logoContentDef), profileMenu: profileMenu, style: style, className: className, title: title, titleContent: titleContent, registerSubNavPanelSlot: registerSubNavPanelSlot, children: [(layout === null || layout === void 0 ? void 0 : layout.startsWith("condensed")) && navPanelVisible && ((0, jsx_runtime_1.jsx)("div", { style: { minWidth: 0 }, children: renderChild(navPanelDef) })), children] }));
64
65
  }
@@ -13,8 +13,7 @@ const AppLayoutContext_1 = require("../App/AppLayoutContext");
13
13
  // React Footer component implementation
14
14
  exports.Footer = (0, react_1.forwardRef)(function Footer({ children, style, className, }, forwardedRef) {
15
15
  const { layout } = (0, AppLayoutContext_1.useAppLayoutContext)() || {};
16
- const canRestrictContentWidth = layout !== "vertical-full-header";
17
16
  return ((0, jsx_runtime_1.jsx)("div", { className: Footer_module_scss_1.default.outerWrapper, ref: forwardedRef, style: style, children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(Footer_module_scss_1.default.wrapper, className, {
18
- [Footer_module_scss_1.default.full]: !canRestrictContentWidth,
17
+ [Footer_module_scss_1.default.verticalFullHeader]: layout === "vertical-full-header",
19
18
  }), children: children }) }));
20
19
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formControlTypesMd = exports.formControlTypes = exports.FormContext = exports.validationModeMd = exports.defaultValidationMode = exports.validationModeValues = exports.validationSeverityMd = exports.validationSeverityValues = void 0;
4
- exports.useFormContext = useFormContext;
5
4
  exports.useFormContextPart = useFormContextPart;
6
5
  const use_context_selector_1 = require("use-context-selector");
7
6
  exports.validationSeverityValues = ["error", "warning", "valid", "none"];
@@ -28,9 +27,6 @@ exports.validationModeMd = [
28
27
  }
29
28
  ];
30
29
  exports.FormContext = (0, use_context_selector_1.createContext)(undefined);
31
- function useFormContext() {
32
- return (0, use_context_selector_1.useContext)(exports.FormContext);
33
- }
34
30
  function useFormContextPart(selector) {
35
31
  return (0, use_context_selector_1.useContextSelector)(exports.FormContext, selector);
36
32
  }
@@ -52,6 +48,7 @@ exports.formControlTypes = [
52
48
  "switch",
53
49
  "slider",
54
50
  "colorpicker",
51
+ "items",
55
52
  ];
56
53
  exports.formControlTypesMd = [
57
54
  {
@@ -110,6 +107,10 @@ exports.formControlTypesMd = [
110
107
  value: "colorpicker",
111
108
  description: "Renders ColorPicker",
112
109
  },
110
+ {
111
+ value: "items",
112
+ description: "Renders Items",
113
+ },
113
114
  {
114
115
  value: "custom",
115
116
  description: "Custom control specified in children",
@@ -32,27 +32,9 @@ const ValidationSummary_1 = require("../ValidationSummary/ValidationSummary");
32
32
  const Validations_1 = require("../FormItem/Validations");
33
33
  const formActions_2 = require("../Form/formActions");
34
34
  const FormContext_1 = require("./FormContext");
35
- const setByPath = (obj, path, val) => {
36
- const keys = path.split(".");
37
- for (let i = 0; i < keys.length; i++) {
38
- const currentKey = keys[i];
39
- const nextKey = keys[i + 1];
40
- if (typeof nextKey !== "undefined") {
41
- obj[currentKey] = obj[currentKey] ? obj[currentKey] : {};
42
- }
43
- else {
44
- obj[currentKey] = val;
45
- }
46
- obj = obj[currentKey];
47
- }
48
- };
35
+ const lodash_es_1 = require("lodash-es");
49
36
  const getByPath = (obj, path) => {
50
- const keys = path.split(".");
51
- let ret = obj;
52
- for (let i = 0; i < keys.length; i++) {
53
- ret = ret === null || ret === void 0 ? void 0 : ret[keys[i]];
54
- }
55
- return ret;
37
+ return (0, lodash_es_1.get)(obj, path);
56
38
  };
57
39
  exports.getByPath = getByPath;
58
40
  const formReducer = (0, immer_1.default)((state, action) => {
@@ -71,16 +53,17 @@ const formReducer = (0, immer_1.default)((state, action) => {
71
53
  switch (action.type) {
72
54
  case formActions_1.FormActionKind.FIELD_INITIALIZED: {
73
55
  if (!state.interactionFlags[uid].isDirty || action.payload.force) {
74
- setByPath(state.subject, uid, action.payload.value);
56
+ (0, lodash_es_1.set)(state.subject, uid, action.payload.value);
75
57
  }
76
58
  break;
77
59
  }
78
60
  case formActions_1.FormActionKind.FIELD_REMOVED: {
79
61
  delete state.validationResults[uid];
62
+ delete state.interactionFlags[uid];
80
63
  break;
81
64
  }
82
65
  case formActions_1.FormActionKind.FIELD_VALUE_CHANGED: {
83
- setByPath(state.subject, uid, action.payload.value);
66
+ (0, lodash_es_1.set)(state.subject, uid, action.payload.value);
84
67
  state.interactionFlags[uid].isDirty = true;
85
68
  state.interactionFlags[uid].forceShowValidationResult = false;
86
69
  break;
@@ -170,6 +153,7 @@ const formReducer = (0, immer_1.default)((state, action) => {
170
153
  return Object.assign(Object.assign({}, initialState), { subject: originalSubject, resetVersion: ((_e = state.resetVersion) !== null && _e !== void 0 ? _e : 0) + 1 });
171
154
  }
172
155
  default:
156
+ break;
173
157
  }
174
158
  });
175
159
  const initialState = {
@@ -203,7 +187,6 @@ const Form = (0, react_2.forwardRef)(function ({ formState, dispatch, initialVal
203
187
  originalSubject: initialValue,
204
188
  validationResults: formState.validationResults,
205
189
  interactionFlags: formState.interactionFlags,
206
- resetVersion: formState.resetVersion,
207
190
  dispatch,
208
191
  enabled: isEnabled,
209
192
  };
@@ -212,7 +195,6 @@ const Form = (0, react_2.forwardRef)(function ({ formState, dispatch, initialVal
212
195
  formState.interactionFlags,
213
196
  formState.subject,
214
197
  formState.validationResults,
215
- formState.resetVersion,
216
198
  initialValue,
217
199
  isEnabled,
218
200
  itemLabelBreak,
@@ -330,7 +312,7 @@ const Form = (0, react_2.forwardRef)(function ({ formState, dispatch, initialVal
330
312
  update: updateData,
331
313
  });
332
314
  }, [doReset, updateData, registerComponentApi]);
333
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("form", { style: style, className: Form_module_scss_1.default.wrapper, onSubmit: doSubmit, onReset: doReset, id: id, ref: formRef, children: [(0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults }), (0, jsx_runtime_1.jsx)(FormContext_1.FormContext.Provider, { value: formContextValue, children: children }), buttonRow || ((0, jsx_runtime_1.jsxs)("div", { className: Form_module_scss_1.default.buttonRow, children: [swapCancelAndSave && [submitButton, cancelButton], !swapCancelAndSave && [cancelButton, submitButton]] }))] }), confirmSubmitModalVisible && ((0, jsx_runtime_1.jsx)(ModalDialogNative_1.ModalDialog, { onClose: () => setConfirmSubmitModalVisible(false), isInitiallyOpen: true, title: "Are you sure want to move forward?", children: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "vertical", style: { gap: "0.5rem" }, children: [(0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: "The following warnings were found during validation. Please make sure you are willing to move forward despite these issues." }), (0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults, fieldValidationResults: formState.validationResults }), (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", horizontalAlignment: "end", style: { gap: "1em" }, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", themeColor: "secondary", onClick: () => setConfirmSubmitModalVisible(false), children: "No" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => doSubmit(), autoFocus: true, children: "Yes, proceed" })] })] }) }))] }));
315
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("form", { style: style, className: Form_module_scss_1.default.wrapper, onSubmit: doSubmit, onReset: doReset, id: id, ref: formRef, children: [(0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults }), (0, jsx_runtime_1.jsx)(FormContext_1.FormContext.Provider, { value: formContextValue, children: children }), buttonRow || ((0, jsx_runtime_1.jsxs)("div", { className: Form_module_scss_1.default.buttonRow, children: [swapCancelAndSave && [submitButton, cancelButton], !swapCancelAndSave && [cancelButton, submitButton]] }))] }, formState.resetVersion), confirmSubmitModalVisible && ((0, jsx_runtime_1.jsx)(ModalDialogNative_1.ModalDialog, { onClose: () => setConfirmSubmitModalVisible(false), isInitiallyOpen: true, title: "Are you sure want to move forward?", children: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "vertical", style: { gap: "0.5rem" }, children: [(0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: "The following warnings were found during validation. Please make sure you are willing to move forward despite these issues." }), (0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults, fieldValidationResults: formState.validationResults }), (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", horizontalAlignment: "end", style: { gap: "1em" }, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", themeColor: "secondary", onClick: () => setConfirmSubmitModalVisible(false), children: "No" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => doSubmit(), autoFocus: true, children: "Yes, proceed" })] })] }) }))] }));
334
316
  });
335
317
  Form.displayName = "Form";
336
318
  function FormWithContextVar({ node, renderChild, extractValue, style, lookupEventHandler, registerComponentApi, }) {
@@ -42,7 +42,7 @@ function fieldChanged(uid, value) {
42
42
  type: FormActionKind.FIELD_VALUE_CHANGED,
43
43
  payload: {
44
44
  uid,
45
- value,
45
+ value
46
46
  },
47
47
  };
48
48
  }
@@ -203,7 +203,7 @@ exports.formItemComponentRenderer = (0, renderers_1.createComponentRenderer)(COM
203
203
  const formItemType = extractValue.asOptionalString(type);
204
204
  const isCustomFormItem = formItemType === undefined && !!node.children;
205
205
  const inputTemplate = node.children || ((_a = node.props) === null || _a === void 0 ? void 0 : _a.inputTemplate);
206
- return ((0, jsx_runtime_1.jsx)(FormItemNative_1.FormItem, Object.assign({ style: layoutCss, layoutContext: layoutContext, labelBreak: extractValue.asOptionalBoolean(labelBreak), labelWidth: extractValue.asOptionalString(labelWidth), bindTo: extractValue.asString(bindTo), autoFocus: extractValue.asOptionalBoolean(autoFocus), enabled: extractValue.asOptionalBoolean(enabled), label: extractValue.asOptionalString(label), labelPosition: extractValue.asOptionalString(labelPosition), type: isCustomFormItem ? "custom" : formItemType, validations: resolvedValidationPropsAndEvents, onValidate: lookupEventHandler("validate"), customValidationsDebounce: extractValue.asOptionalNumber(customValidationsDebounce), validationMode: extractValue.asOptionalString(validationMode), registerComponentApi: registerComponentApi, maxTextLength: extractValue(maxTextLength), inputRenderer: inputTemplate
206
+ return ((0, jsx_runtime_1.jsx)(FormItemNative_1.FormItem, Object.assign({ style: layoutCss, layoutContext: layoutContext, labelBreak: extractValue.asOptionalBoolean(labelBreak), labelWidth: extractValue.asOptionalString(labelWidth), bindTo: extractValue.asString(bindTo), autoFocus: extractValue.asOptionalBoolean(autoFocus), enabled: extractValue.asOptionalBoolean(enabled), label: extractValue.asOptionalString(label), labelPosition: extractValue.asOptionalString(labelPosition), type: isCustomFormItem ? "custom" : formItemType, validations: resolvedValidationPropsAndEvents, onValidate: lookupEventHandler("validate"), customValidationsDebounce: extractValue.asOptionalNumber(customValidationsDebounce), validationMode: extractValue.asOptionalString(validationMode), registerComponentApi: registerComponentApi, maxTextLength: extractValue(maxTextLength), itemIndex: extractValue("{$itemIndex}"), initialValue: extractValue(node.props.initialValue), inputRenderer: inputTemplate
207
207
  ? (contextVars) => ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { contextVars: contextVars, node: inputTemplate, renderChild: renderChild, layoutContext: layoutContext }))
208
208
  : undefined }, resolvedRestProps, { children: isCustomFormItem ? ((0, jsx_runtime_1.jsx)(FormItemNative_1.CustomFormItem, { renderChild: renderChild, node: node, bindTo: extractValue.asString(bindTo) })) : (renderChild(node.children, {
209
209
  type: formItemType,
@@ -36,6 +36,8 @@ const SliderNative_1 = require("../Slider/SliderNative");
36
36
  const ColorPickerNative_1 = require("../ColorPicker/ColorPickerNative");
37
37
  const HelperText_1 = require("./HelperText");
38
38
  const NumberBox2Native_1 = require("../NumberBox/NumberBox2Native");
39
+ const ItemsNative_1 = require("../Items/ItemsNative");
40
+ const constants_1 = require("../../components-core/constants");
39
41
  const DEFAULT_LABEL_POSITIONS = {
40
42
  checkbox: "end",
41
43
  };
@@ -45,32 +47,63 @@ exports.defaultProps = {
45
47
  enabled: true,
46
48
  customValidationsDebounce: 0,
47
49
  };
50
+ const FormItemContext = (0, react_1.createContext)({ parentFormItemId: null });
51
+ function ArrayLikeFormItem({ children, formItemId, registerComponentApi, value = constants_1.EMPTY_ARRAY, updateState, }) {
52
+ const formContextValue = (0, react_1.useMemo)(() => {
53
+ return {
54
+ parentFormItemId: formItemId,
55
+ };
56
+ }, [formItemId]);
57
+ const addItem = (0, misc_1.useEvent)((item) => {
58
+ updateState({ value: [...value, item] });
59
+ });
60
+ const removeItem = (0, misc_1.useEvent)((index) => {
61
+ updateState({ value: value.filter((item, i) => i !== index) });
62
+ });
63
+ (0, react_1.useEffect)(() => {
64
+ registerComponentApi === null || registerComponentApi === void 0 ? void 0 : registerComponentApi({
65
+ addItem: addItem,
66
+ removeItem: removeItem,
67
+ });
68
+ }, [addItem, registerComponentApi, removeItem]);
69
+ return (0, jsx_runtime_1.jsx)(FormItemContext.Provider, { value: formContextValue, children: children });
70
+ }
48
71
  exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
49
- var _b;
50
- var { style, bindTo, type = exports.defaultProps.type, label, enabled = exports.defaultProps.enabled, labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak, children, validations, onValidate, customValidationsDebounce = exports.defaultProps.customValidationsDebounce, validationMode, registerComponentApi, maxTextLength, inputRenderer } = _a, rest = __rest(_a, ["style", "bindTo", "type", "label", "enabled", "labelPosition", "labelWidth", "labelBreak", "children", "validations", "onValidate", "customValidationsDebounce", "validationMode", "registerComponentApi", "maxTextLength", "inputRenderer"]);
72
+ var { style, bindTo, type = exports.defaultProps.type, label, enabled = exports.defaultProps.enabled, labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak, children, validations, onValidate, customValidationsDebounce = exports.defaultProps.customValidationsDebounce, validationMode, registerComponentApi, maxTextLength, inputRenderer, itemIndex, initialValue: initialValueFromProps } = _a, rest = __rest(_a, ["style", "bindTo", "type", "label", "enabled", "labelPosition", "labelWidth", "labelBreak", "children", "validations", "onValidate", "customValidationsDebounce", "validationMode", "registerComponentApi", "maxTextLength", "inputRenderer", "itemIndex", "initialValue"]);
51
73
  const defaultId = (0, react_1.useId)();
52
- const [formItemId, setFormItemId] = (0, react_1.useState)(bindTo);
74
+ const { parentFormItemId } = (0, react_1.useContext)(FormItemContext);
75
+ const formItemId = (0, react_1.useMemo)(() => {
76
+ const safeBindTo = bindTo || `${defaultId}${formActions_1.UNBOUND_FIELD_SUFFIX}`;
77
+ if (parentFormItemId) {
78
+ if (itemIndex !== undefined) {
79
+ let parentFieldReference = `${parentFormItemId}[${itemIndex}]`;
80
+ if (bindTo !== undefined && bindTo.trim() === "") {
81
+ return parentFieldReference;
82
+ }
83
+ else {
84
+ return `${parentFieldReference}.${safeBindTo}`;
85
+ }
86
+ }
87
+ }
88
+ else {
89
+ return safeBindTo;
90
+ }
91
+ }, [bindTo, defaultId, itemIndex, parentFormItemId]);
53
92
  const labelWidthValue = (0, FormContext_1.useFormContextPart)((value) => labelWidth || value.itemLabelWidth);
54
93
  const labelBreakValue = (0, FormContext_1.useFormContextPart)((value) => labelBreak !== undefined ? labelBreak : value.itemLabelBreak);
55
94
  const labelPositionValue = (0, FormContext_1.useFormContextPart)((value) => labelPosition || value.itemLabelPosition || DEFAULT_LABEL_POSITIONS[type]);
56
- const resetVersion = (_b = (0, FormContext_1.useFormContext)()) === null || _b === void 0 ? void 0 : _b.resetVersion;
57
95
  const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.originalSubject, formItemId));
58
- const initialValue = initialValueFromSubject === undefined ? rest.initialValue : initialValueFromSubject;
96
+ const initialValue = initialValueFromSubject === undefined ? initialValueFromProps : initialValueFromSubject;
59
97
  const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.subject, formItemId));
60
98
  const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[formItemId]);
61
99
  const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
62
100
  const formEnabled = (0, FormContext_1.useFormContextPart)((value) => value.enabled);
63
101
  const isEnabled = enabled && formEnabled;
64
102
  (0, react_1.useEffect)(() => {
65
- const newId = bindTo || `${defaultId}${formActions_1.UNBOUND_FIELD_SUFFIX}`;
66
- setFormItemId(newId);
67
- dispatch((0, formActions_1.fieldInitialized)(newId, initialValue));
68
- }, [bindTo, dispatch, initialValue]);
69
- (0, react_1.useEffect)(() => {
70
- if (resetVersion) {
71
- dispatch((0, formActions_1.fieldInitialized)(formItemId, initialValue, true));
103
+ if (initialValue !== undefined) {
104
+ dispatch((0, formActions_1.fieldInitialized)(formItemId, initialValue));
72
105
  }
73
- }, [resetVersion, formItemId, initialValue, dispatch]);
106
+ }, [dispatch, formItemId, initialValue]);
74
107
  (0, Validations_1.useValidation)(validations, onValidate, value, dispatch, formItemId, customValidationsDebounce);
75
108
  const onStateChange = (0, react_1.useCallback)(({ value }, options) => {
76
109
  //we already handled the initial value in the useEffect with fieldInitialized(...);
@@ -150,6 +183,10 @@ exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
150
183
  formControl = ((0, jsx_runtime_1.jsx)(ColorPickerNative_1.ColorPicker, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: isEnabled, validationStatus: validationStatus })));
151
184
  break;
152
185
  }
186
+ case "items": {
187
+ formControl = ((0, jsx_runtime_1.jsx)(ArrayLikeFormItem, { formItemId: formItemId, registerComponentApi: registerComponentApi, updateState: onStateChange, value: value, children: (0, jsx_runtime_1.jsx)(ItemsNative_1.Items, { items: value, renderItem: inputRenderer }) }));
188
+ break;
189
+ }
153
190
  case "custom": {
154
191
  formControl = children;
155
192
  break;
@@ -171,6 +208,9 @@ exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
171
208
  (validationResult === null || validationResult === void 0 ? void 0 : validationResult.validations.map((singleValidation, i) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [singleValidation.isValid && !!singleValidation.validMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.validMessage, status: "valid", style: { opacity: singleValidation.stale ? 0.5 : undefined } })), !singleValidation.isValid && !!singleValidation.invalidMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.invalidMessage, status: singleValidation.severity, style: { opacity: singleValidation.stale ? 0.5 : undefined } }))] }, i)))) }), children: formControl }));
172
209
  });
173
210
  function CustomFormItem({ renderChild, node, bindTo, }) {
211
+ // IMPORTANT NOTE:
212
+ // why we use useFormContextPart, and not useFormContext?
213
+ // because we want to avoid re-rendering the whole form when the form state changes.
174
214
  const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.subject, bindTo));
175
215
  const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[bindTo]);
176
216
  const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
@@ -14,7 +14,7 @@ const numberRegex = /^[0-9]+$/;
14
14
  exports.ItemWithLabel = (0, react_1.forwardRef)(function ItemWithLabel({ id, labelPosition = "top", style, label, labelBreak = true, labelWidth, enabled = true, required = false, children, validationInProgress = false, shrinkToLabel = false, onFocus, onBlur, labelStyle, validationResult, isInputTemplateUsed = false, }, ref) {
15
15
  const generatedId = (0, react_1.useId)();
16
16
  const inputId = id || generatedId;
17
- if (label === undefined) {
17
+ if (label === undefined && !validationResult) {
18
18
  return ((0, jsx_runtime_1.jsx)(react_slot_1.Slot, { style: style, id: inputId, ref: ref, children: children }));
19
19
  // return cloneElement(children as ReactElement, {
20
20
  // ...mergeProps((children as ReactElement).props, {
@@ -18,10 +18,12 @@ function Items({ items, renderItem, reverse = false }) {
18
18
  if (!itemsToRender || !Array.isArray(itemsToRender)) {
19
19
  return null;
20
20
  }
21
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: itemsToRender.map((item, index) => renderItem({
22
- $item: item,
23
- $itemIndex: index,
24
- $isFirst: index === 0,
25
- $isLast: index === itemsToRender.length - 1,
26
- }, index)) }));
21
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: itemsToRender.map((item, index) => {
22
+ return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem === null || renderItem === void 0 ? void 0 : renderItem({
23
+ $item: item,
24
+ $itemIndex: index,
25
+ $isFirst: index === 0,
26
+ $isLast: index === itemsToRender.length - 1,
27
+ }, index) }, index);
28
+ }) }));
27
29
  }
@@ -34,8 +34,7 @@ exports.NavGroup = (0, react_1.forwardRef)(function NavGroup({ node, style, labe
34
34
  const navPanelContext = (0, react_1.useContext)(NavPanelNative_1.NavPanelContext);
35
35
  let inline = (appLayoutContext === null || appLayoutContext === void 0 ? void 0 : appLayoutContext.layout) === "vertical" ||
36
36
  (appLayoutContext === null || appLayoutContext === void 0 ? void 0 : appLayoutContext.layout) === "vertical-sticky" ||
37
- (appLayoutContext === null || appLayoutContext === void 0 ? void 0 : appLayoutContext.layout) === "vertical-full-header" ||
38
- (appLayoutContext === null || appLayoutContext === void 0 ? void 0 : appLayoutContext.layout) === "vertical-constrained-width";
37
+ (appLayoutContext === null || appLayoutContext === void 0 ? void 0 : appLayoutContext.layout) === "vertical-full-header";
39
38
  if (navPanelContext !== null) {
40
39
  inline = navPanelContext.inDrawer;
41
40
  }
@@ -47,7 +46,7 @@ exports.NavGroup = (0, react_1.forwardRef)(function NavGroup({ node, style, labe
47
46
  iconVerticalCollapsed: iconVerticalCollapsed !== null && iconVerticalCollapsed !== void 0 ? iconVerticalCollapsed : exports.defaultProps.iconVerticalCollapsed,
48
47
  iconVerticalExpanded: iconVerticalExpanded !== null && iconVerticalExpanded !== void 0 ? iconVerticalExpanded : exports.defaultProps.iconVerticalExpanded,
49
48
  };
50
- }, [level]);
49
+ }, [iconHorizontalCollapsed, iconHorizontalExpanded, iconVerticalCollapsed, iconVerticalExpanded, level]);
51
50
  return ((0, jsx_runtime_1.jsx)(NavGroupContext.Provider, { value: navGroupContextValue, children: inline ? ((0, jsx_runtime_1.jsx)(ExpandableNavGroup, { to: to, style: style, label: label, icon: icon, node: node, renderChild: renderChild, ref: ref, initiallyExpanded: initiallyExpanded })) : ((0, jsx_runtime_1.jsx)(DropDownNavGroup, { label: label, icon: icon, node: node, renderChild: renderChild, ref: ref, to: to })) }));
52
51
  });
53
52
  const ExpandableNavGroup = (0, react_1.forwardRef)(function ExpandableNavGroup({ style = constants_1.EMPTY_OBJECT, label, icon, renderChild, node, to, initiallyExpanded = false, }, ref) {
@@ -69,7 +69,9 @@ const SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwar
69
69
  [Select_module_scss_1.default.error]: validationStatus === "error",
70
70
  [Select_module_scss_1.default.warning]: validationStatus === "warning",
71
71
  [Select_module_scss_1.default.valid]: validationStatus === "valid",
72
- }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: (0, jsx_runtime_1.jsx)(react_select_1.Value, { placeholder: placeholder }) }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.Viewport, { className: (0, classnames_1.default)(Select_module_scss_1.default.selectViewport), children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }) }));
72
+ }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: (0, jsx_runtime_1.jsx)(react_select_1.Value, { placeholder: placeholder }) }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent,
73
+ // position="popper"
74
+ style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.Viewport, { className: (0, classnames_1.default)(Select_module_scss_1.default.selectViewport), children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }) }));
73
75
  });
74
76
  exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, value, enabled = true, placeholder, updateState = constants_1.noop, validationStatus = "none", onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, emptyListTemplate, optionLabelRenderer, optionRenderer, valueRenderer, style, dropdownHeight, children, autoFocus = false, searchable = false, multiSelect = false, label, labelPosition, labelWidth, labelBreak, required = false, inProgress = false, inProgressNotificationMessage = "Loading...", }, ref) {
75
77
  var _a;