xmlui 0.9.19 → 0.9.20

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/dist/index.css CHANGED
@@ -7162,16 +7162,55 @@ li .htmlOl {
7162
7162
  * This function allows other CSS modules to get the value of the CSS variable specified in $componentVariable.
7163
7163
  Optionally, you can provide a $fallbackValue to set the variable's value if that is not defined.
7164
7164
  */
7165
- ._wrapper_8djl9_13 {
7165
+ ._wrapper_ntbxg_13 {
7166
7166
  opacity: 0.5;
7167
7167
  }
7168
- ._wrapper_8djl9_13:hover {
7168
+ ._wrapper_ntbxg_13:hover {
7169
7169
  opacity: 1;
7170
7170
  }
7171
- ._wrapper_8djl9_13[data-popper-reference-hidden=true] {
7171
+ ._wrapper_ntbxg_13[data-popper-reference-hidden=true] {
7172
7172
  opacity: 0;
7173
7173
  pointer-events: none;
7174
7174
  display: none;
7175
+ }
7176
+
7177
+ ._inspectableNode_ntbxg_25 {
7178
+ outline: 1px solid var(--xmlui-outlineColor--focus);
7179
+ outline-offset: 4px;
7180
+ position: relative;
7181
+ }
7182
+
7183
+ ._inspectableNode_ntbxg_25:hover {
7184
+ outline: 2px solid var(--xmlui-color-primary-500);
7185
+ }
7186
+
7187
+ ._inspectOverlay_ntbxg_35 {
7188
+ cursor: pointer;
7189
+ position: absolute;
7190
+ top: 0;
7191
+ left: 0;
7192
+ width: 100%;
7193
+ height: 100%;
7194
+ background: transparent;
7195
+ z-index: 1000;
7196
+ pointer-events: auto;
7197
+ }
7198
+
7199
+ ._inspectOverlay_ntbxg_35:hover {
7200
+ background: rgba(32, 107, 196, 0.1);
7201
+ }
7202
+
7203
+ ._inspectedNode_ntbxg_51 {
7204
+ outline: 2px solid var(--xmlui-color-primary-500);
7205
+ }
7206
+ ._inspectedNode_ntbxg_51 ._inspectOverlay_ntbxg_35 {
7207
+ background: rgba(32, 107, 196, 0.1);
7208
+ }
7209
+
7210
+ ._inspectIcon_ntbxg_58 {
7211
+ position: absolute;
7212
+ right: 0;
7213
+ top: -10px;
7175
7214
  }/*
7176
7215
  * This file contains all CSS variables AppEngine uses for styling the UI, including individual visual components.
7177
7216
  *
@@ -7921,6 +7960,20 @@ li .htmlOl {
7921
7960
  * This function allows other CSS modules to get the value of the CSS variable specified in $componentVariable.
7922
7961
  Optionally, you can provide a $fallbackValue to set the variable's value if that is not defined.
7923
7962
  */
7963
+ ._active_rwrkr_13 {
7964
+ background: var(--xmlui-color-primary-500);
7965
+ }/*
7966
+ * This file contains all CSS variables AppEngine uses for styling the UI, including individual visual components.
7967
+ *
7968
+ * We use a subset of these CSS variables in themes.
7969
+ */
7970
+ /*
7971
+ * This function creates a CSS variable name by combining the prefix and the argument variable name
7972
+ */
7973
+ /*
7974
+ * This function allows other CSS modules to get the value of the CSS variable specified in $componentVariable.
7975
+ Optionally, you can provide a $fallbackValue to set the variable's value if that is not defined.
7976
+ */
7924
7977
  ._dialogContent_1rief_13 {
7925
7978
  display: flex;
7926
7979
  flex-direction: column;
@@ -101,6 +101,7 @@ const HtmlTags_1 = require("./HtmlTags/HtmlTags");
101
101
  const ColorPicker_1 = require("./ColorPicker/ColorPicker");
102
102
  const RadioItem_1 = require("./RadioGroup/RadioItem");
103
103
  const SubNavPanel_1 = require("./SubNavPanel/SubNavPanel");
104
+ const InspectButton_1 = require("./InspectButton/InspectButton");
104
105
  /**
105
106
  * The framework has a specialized component concept, the "property holder
106
107
  * component." These components only hold property values but do not render
@@ -151,6 +152,7 @@ class ComponentRegistry {
151
152
  }
152
153
  });
153
154
  };
155
+ // --- Registers a renderable component using its renderer function
154
156
  this.registerCoreComponent = (component) => {
155
157
  const coreNamespaces = ["#xmlui-core-ns", ""];
156
158
  if ("compoundComponentDef" in component) {
@@ -169,7 +171,6 @@ class ComponentRegistry {
169
171
  this.registerComponentRenderer(component, ...appNamespaces);
170
172
  }
171
173
  };
172
- // --- Registers a renderable component using its renderer function
173
174
  // --- and metadata
174
175
  this.registerComponentRenderer = ({ type, renderer, metadata, isCompoundComponent, }, ...namespaces) => {
175
176
  const component = {
@@ -372,6 +373,7 @@ class ComponentRegistry {
372
373
  this.registerCoreComponent(AutoComplete_1.autoCompleteComponentRenderer);
373
374
  this.registerCoreComponent(DropdownMenu_1.dropdownMenuComponentRenderer);
374
375
  this.registerCoreComponent(ToneChangerButton_1.toneChangerButtonComponentRenderer);
376
+ this.registerCoreComponent(InspectButton_1.inspectButtonComponentRenderer);
375
377
  this.registerCoreComponent(FormSection_1.formSectionRenderer);
376
378
  this.registerCoreComponent(DropdownMenu_1.dropdownMenuComponentRenderer);
377
379
  this.registerCoreComponent(DropdownMenu_1.menuItemRenderer);
@@ -566,6 +568,19 @@ class ComponentRegistry {
566
568
  this.loaders.get(componentName) !== undefined ||
567
569
  this.actionFns.get(componentName) !== undefined);
568
570
  }
571
+ // --- Registers a loader renderer using its definition
572
+ registerLoaderRenderer({ type, renderer }) {
573
+ this.loaders.set(type, renderer);
574
+ }
575
+ /**
576
+ * This method destroys the component registry; It unsubscribes from the component manager.
577
+ * This method is called when the component registry is no longer needed, e.g., when the
578
+ * component provider is unmounted (HMR).
579
+ */
580
+ destroy() {
581
+ var _a;
582
+ (_a = this.extensionManager) === null || _a === void 0 ? void 0 : _a.unSubscribeFromRegistrations(this.extensionRegistered);
583
+ }
569
584
  // --- Registers a compound component using its definition and metadata
570
585
  registerCompoundComponentRenderer({ compoundComponentDef, metadata }, ...namespaces) {
571
586
  const component = {
@@ -582,19 +597,6 @@ class ComponentRegistry {
582
597
  registerActionFn({ actionName: functionName, actionFn }) {
583
598
  this.actionFns.set(functionName, actionFn);
584
599
  }
585
- // --- Registers a loader renderer using its definition
586
- registerLoaderRenderer({ type, renderer }) {
587
- this.loaders.set(type, renderer);
588
- }
589
- /**
590
- * This method destroys the component registry; It unsubscribes from the component manager.
591
- * This method is called when the component registry is no longer needed, e.g., when the
592
- * component provider is unmounted (HMR).
593
- */
594
- destroy() {
595
- var _a;
596
- (_a = this.extensionManager) === null || _a === void 0 ? void 0 : _a.unSubscribeFromRegistrations(this.extensionRegistered);
597
- }
598
600
  }
599
601
  exports.ComponentRegistry = ComponentRegistry;
600
602
  /**
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.inspectButtonComponentRenderer = exports.InspectButtonMd = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const ComponentDefs_1 = require("../../abstractions/ComponentDefs");
9
+ const renderers_1 = require("../../components-core/renderers");
10
+ const ButtonNative_1 = require("../Button/ButtonNative");
11
+ const InspectorContext_1 = require("../../components-core/InspectorContext");
12
+ const InspectButton_module_scss_1 = __importDefault(require("./InspectButton.module.scss"));
13
+ const themeVars_1 = require("../../components-core/theming/themeVars");
14
+ const COMP = "InspectButton";
15
+ exports.InspectButtonMd = (0, ComponentDefs_1.createMetadata)({
16
+ status: "experimental",
17
+ description: `The \`${COMP}\` component is a component that allows the user to change the tone of the app.`,
18
+ props: {},
19
+ themeVars: (0, themeVars_1.parseScssVar)(InspectButton_module_scss_1.default.themeVars),
20
+ });
21
+ function InspectButton({ children, style }) {
22
+ const { setInspectMode, inspectMode } = (0, InspectorContext_1.useInspectMode)();
23
+ return ((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { style: style, themeColor: inspectMode ? "primary" : "secondary", variant: inspectMode ? "solid" : "outlined", onClick: () => {
24
+ setInspectMode((prev) => !prev);
25
+ }, children: children }));
26
+ }
27
+ /**
28
+ * Define the renderer for the Button component
29
+ */
30
+ exports.inspectButtonComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.InspectButtonMd, ({ renderChild, node, layoutCss }) => {
31
+ return (0, jsx_runtime_1.jsx)(InspectButton, { style: layoutCss, children: renderChild(node.children) });
32
+ });
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.InspectorContext = void 0;
7
7
  exports.InspectorProvider = InspectorProvider;
8
8
  exports.useDevTools = useDevTools;
9
+ exports.useInspectMode = useInspectMode;
9
10
  exports.useInspector = useInspector;
10
11
  const jsx_runtime_1 = require("react/jsx-runtime");
11
12
  const react_1 = require("react");
@@ -26,6 +27,8 @@ function InspectorProvider({ children, sources, projectCompilation, mockApi, })
26
27
  const [showCode, setShowCode] = (0, react_1.useState)(false);
27
28
  const [devToolsSize, setDevToolsSize] = (0, react_1.useState)(0);
28
29
  const [devToolsSide, setDevToolsSide] = (0, react_1.useState)("bottom");
30
+ const [inspectMode, setInspectMode] = (0, react_1.useState)(false);
31
+ const [lastInspectedElement, setLastInspectedElement] = (0, react_1.useState)(null);
29
32
  const componentRegistry = (0, ComponentRegistryContext_1.useComponentRegistry)();
30
33
  const devToolsEntry = componentRegistry.lookupComponentRenderer("XMLUIDevtools.DevTools");
31
34
  const contextValue = (0, react_1.useMemo)(() => {
@@ -61,19 +64,30 @@ function InspectorProvider({ children, sources, projectCompilation, mockApi, })
61
64
  setDevToolsSide,
62
65
  devToolsEnabled: showCode,
63
66
  projectCompilation: projectCompilation,
67
+ setInspectMode,
68
+ inspectMode,
64
69
  mockApi,
65
70
  };
66
- }, [devToolsSide, devToolsSize, sources, inspectedNode, showCode, projectCompilation, mockApi]);
71
+ }, [
72
+ devToolsSide,
73
+ devToolsSize,
74
+ sources,
75
+ inspectedNode,
76
+ showCode,
77
+ projectCompilation,
78
+ inspectMode,
79
+ mockApi,
80
+ ]);
67
81
  return ((0, jsx_runtime_1.jsxs)(exports.InspectorContext.Provider, { value: contextValue, children: [children, process.env.VITE_USER_COMPONENTS_Inspect !== "false" &&
68
82
  showCode &&
69
83
  inspectedNode !== null &&
70
84
  (0, react_dom_1.createPortal)(devToolsEntry === null || devToolsEntry === void 0 ? void 0 : devToolsEntry.renderer({}), root), process.env.VITE_USER_COMPONENTS_Inspect !== "false" &&
71
85
  inspectable &&
72
86
  Object.values(inspectable).map((item) => {
73
- return ((0, jsx_runtime_1.jsx)(InspectButton, { setShowCode: setShowCode, inspectId: item.inspectId, node: item.node, setInspectedNode: setInspectedNode }, item.inspectId + +"-" + item.key));
87
+ return ((0, jsx_runtime_1.jsx)(InspectButton, { inspectedNode: inspectedNode, setShowCode: setShowCode, inspectId: item.inspectId, node: item.node, setInspectedNode: setInspectedNode, inspectMode: inspectMode }, item.inspectId + +"-" + item.key));
74
88
  })] }));
75
89
  }
76
- function InspectButton({ inspectId, node, setInspectedNode, setShowCode, }) {
90
+ function InspectButton({ inspectId, node, inspectedNode, setInspectedNode, setShowCode, inspectMode, }) {
77
91
  const { root } = (0, ThemeContext_1.useTheme)();
78
92
  const [referenceElement, setReferenceElement] = (0, react_1.useState)(null);
79
93
  const [popperElement, setPopperElement] = (0, react_1.useState)(null);
@@ -98,12 +112,55 @@ function InspectButton({ inspectId, node, setInspectedNode, setShowCode, }) {
98
112
  const [visible, setVisible] = (0, react_1.useState)(false);
99
113
  const timeoutRef = (0, react_1.useRef)(null);
100
114
  const hoverRef = (0, react_1.useRef)(false);
115
+ (0, react_1.useEffect)(() => {
116
+ if (!referenceElement) {
117
+ return;
118
+ }
119
+ if ((inspectedNode === null || inspectedNode === void 0 ? void 0 : inspectedNode.inspectId) === inspectId) {
120
+ referenceElement.classList.add(InspectorButton_module_scss_1.default.inspectedNode);
121
+ }
122
+ else {
123
+ referenceElement.classList.remove(InspectorButton_module_scss_1.default.inspectedNode);
124
+ }
125
+ }, [inspectId, inspectedNode, referenceElement]);
126
+ (0, react_1.useEffect)(() => {
127
+ if (inspectedNode) {
128
+ setShowCode(true);
129
+ }
130
+ else {
131
+ setShowCode(false);
132
+ }
133
+ }, [inspectedNode]);
101
134
  (0, react_1.useEffect)(() => {
102
135
  const htmlElement = document.querySelector(`[data-inspectId="${inspectId}"]`);
103
136
  if (!htmlElement) {
104
137
  return;
105
138
  }
106
139
  setReferenceElement(htmlElement);
140
+ if (inspectMode) {
141
+ htmlElement.classList.add(InspectorButton_module_scss_1.default.inspectableNode);
142
+ const overlay = document.createElement("div");
143
+ overlay.classList.add(InspectorButton_module_scss_1.default.inspectOverlay);
144
+ htmlElement.appendChild(overlay);
145
+ overlay.addEventListener("click", () => {
146
+ setInspectedNode((prev) => {
147
+ if ((prev === null || prev === void 0 ? void 0 : prev.inspectId) === inspectId) {
148
+ return null;
149
+ }
150
+ return Object.assign(Object.assign({}, node), { inspectId });
151
+ });
152
+ });
153
+ }
154
+ if (!inspectMode) {
155
+ htmlElement.classList.remove(InspectorButton_module_scss_1.default.inspectableNode);
156
+ setInspectedNode(null);
157
+ setShowCode(false);
158
+ const overlay = htmlElement.querySelector(`.${InspectorButton_module_scss_1.default.inspectOverlay}`);
159
+ if (overlay) {
160
+ overlay.remove();
161
+ }
162
+ htmlElement.classList.remove(InspectorButton_module_scss_1.default.inspectedNode);
163
+ }
107
164
  function mouseenter() {
108
165
  if (timeoutRef.current) {
109
166
  clearTimeout(timeoutRef.current);
@@ -127,22 +184,24 @@ function InspectButton({ inspectId, node, setInspectedNode, setShowCode, }) {
127
184
  htmlElement.removeEventListener("mouseenter", mouseenter);
128
185
  htmlElement.removeEventListener("mouseleave", mouseleave);
129
186
  };
130
- }, [inspectId]);
131
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: visible &&
132
- !!root &&
133
- (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, Object.assign({ variant: "ghost", className: (0, classnames_1.default)(InspectorButton_module_scss_1.default.wrapper, "_debug-inspect-button"), ref: (el) => setPopperElement(el), style: Object.assign(Object.assign({}, popperStyles.popper), { padding: 0 }) }, attributes.popper, { onMouseEnter: () => {
134
- hoverRef.current = true;
135
- if (timeoutRef.current) {
136
- clearTimeout(timeoutRef.current);
137
- timeoutRef.current = null;
138
- }
139
- }, onMouseLeave: () => {
140
- hoverRef.current = false;
141
- setVisible(false);
142
- }, onClick: () => {
143
- setInspectedNode(node);
144
- setShowCode(true);
145
- }, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "inspect", size: "md" }) })), root) }));
187
+ }, [inspectId, node, inspectMode, setInspectedNode, setShowCode]);
188
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: inspectMode
189
+ ? null
190
+ : visible &&
191
+ !!root &&
192
+ (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, Object.assign({ variant: "ghost", className: (0, classnames_1.default)(InspectorButton_module_scss_1.default.wrapper, "_debug-inspect-button"), ref: (el) => setPopperElement(el), style: Object.assign(Object.assign({}, popperStyles.popper), { padding: 0 }) }, attributes.popper, { onMouseEnter: () => {
193
+ hoverRef.current = true;
194
+ if (timeoutRef.current) {
195
+ clearTimeout(timeoutRef.current);
196
+ timeoutRef.current = null;
197
+ }
198
+ }, onMouseLeave: () => {
199
+ hoverRef.current = false;
200
+ setVisible(false);
201
+ }, onClick: () => {
202
+ setInspectedNode(node);
203
+ setShowCode(true);
204
+ }, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "inspect", size: "md" }) })), root) }));
146
205
  }
147
206
  function useDevTools() {
148
207
  const context = (0, react_1.useContext)(exports.InspectorContext);
@@ -159,6 +218,13 @@ function useDevTools() {
159
218
  mockApi: context === null || context === void 0 ? void 0 : context.mockApi,
160
219
  };
161
220
  }
221
+ function useInspectMode() {
222
+ const context = (0, react_1.useContext)(exports.InspectorContext);
223
+ return {
224
+ setInspectMode: context === null || context === void 0 ? void 0 : context.setInspectMode,
225
+ inspectMode: context === null || context === void 0 ? void 0 : context.inspectMode,
226
+ };
227
+ }
162
228
  function useInspector(node, uid) {
163
229
  var _a;
164
230
  const context = (0, react_1.useContext)(exports.InspectorContext);