framepexls-ui-lib 0.1.16 → 0.1.18

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/AppTopbar.js CHANGED
@@ -40,7 +40,7 @@ function AppTopbar({ title, subtitle, secondary, primary, actions }) {
40
40
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-lg font-semibold tracking-tight", children: title }),
41
41
  subtitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-slate-500", children: subtitle })
42
42
  ] }) }),
43
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 z-10", children: [
44
44
  Array.isArray(actions) && actions.map((a, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
45
  import_Button.default,
46
46
  {
@@ -7,7 +7,7 @@ function AppTopbar({ title, subtitle, secondary, primary, actions }) {
7
7
  /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold tracking-tight", children: title }),
8
8
  subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-500", children: subtitle })
9
9
  ] }) }),
10
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 z-10", children: [
11
11
  Array.isArray(actions) && actions.map((a, idx) => /* @__PURE__ */ jsx(
12
12
  Button,
13
13
  {
package/dist/Dialog.js CHANGED
@@ -246,7 +246,7 @@ function DialogField({
246
246
  children,
247
247
  className
248
248
  }) {
249
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: cx("grid gap-1 text-sm content-start", className), children: [
249
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: cx("grid gap-1 text-sm content-start justify-start", className), children: [
250
250
  label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "font-medium", children: [
251
251
  label,
252
252
  " ",
package/dist/Dialog.mjs CHANGED
@@ -206,7 +206,7 @@ function DialogField({
206
206
  children,
207
207
  className
208
208
  }) {
209
- return /* @__PURE__ */ jsxs("label", { className: cx("grid gap-1 text-sm content-start", className), children: [
209
+ return /* @__PURE__ */ jsxs("label", { className: cx("grid gap-1 text-sm content-start justify-start", className), children: [
210
210
  label && /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
211
211
  label,
212
212
  " ",
package/dist/Dropdown.js CHANGED
@@ -39,7 +39,7 @@ __export(Dropdown_exports, {
39
39
  });
40
40
  module.exports = __toCommonJS(Dropdown_exports);
41
41
  var import_jsx_runtime = require("react/jsx-runtime");
42
- var import_react = require("react");
42
+ var import_react = __toESM(require("react"));
43
43
  var import_react_dom = require("react-dom");
44
44
  var import_iconos = require("./iconos/index");
45
45
  var import_Button = __toESM(require("./Button"));
@@ -165,7 +165,7 @@ function Content({
165
165
  className = "",
166
166
  maxHeight = 360
167
167
  }) {
168
- const { open, setOpen, triggerRef, menuRef, menuId, labelId, align } = useDropdown();
168
+ const { open, setOpen, triggerRef, menuRef, menuId, labelId, align, isAllowed, defaultHideUnauthorized } = useDropdown();
169
169
  const [pos, setPos] = (0, import_react.useState)({ top: 0, left: 0, origin: "top-left", maxH: maxHeight });
170
170
  const computePosition = (0, import_react.useCallback)(() => {
171
171
  var _a, _b;
@@ -221,6 +221,49 @@ function Content({
221
221
  }
222
222
  };
223
223
  if (!open) return null;
224
+ const normalizedChildren = (0, import_react.useMemo)(() => {
225
+ const arr = import_react.default.Children.toArray(children);
226
+ const list = arr.map((ch) => {
227
+ var _a, _b, _c;
228
+ if (import_react.default.isValidElement(ch)) {
229
+ const el = ch;
230
+ if (el.type === Separator) {
231
+ return { node: ch, kind: "SEP", visible: true };
232
+ }
233
+ if (el.type === Item) {
234
+ const require2 = (_a = el.props) == null ? void 0 : _a.require;
235
+ const hideIfUnauthorized = (_c = (_b = el.props) == null ? void 0 : _b.hideIfUnauthorized) != null ? _c : defaultHideUnauthorized;
236
+ const allowed = typeof isAllowed === "function" ? isAllowed(require2) : true;
237
+ const visible = hideIfUnauthorized ? !!allowed : true;
238
+ return { node: ch, kind: "ITEM", visible };
239
+ }
240
+ }
241
+ return { node: ch, kind: "OTHER", visible: true };
242
+ });
243
+ let filtered = list.filter((it) => it.visible);
244
+ const out = [];
245
+ for (const it of filtered) {
246
+ if (it.kind === "SEP") {
247
+ const prev = out.length > 0 ? out[out.length - 1] : null;
248
+ const prevIsSep = prev && import_react.default.isValidElement(prev) && prev.type === Separator;
249
+ if (prevIsSep) continue;
250
+ out.push(it.node);
251
+ } else {
252
+ out.push(it.node);
253
+ }
254
+ }
255
+ while (out.length > 0) {
256
+ const first = out[0];
257
+ if (import_react.default.isValidElement(first) && first.type === Separator) out.shift();
258
+ else break;
259
+ }
260
+ while (out.length > 0) {
261
+ const last = out[out.length - 1];
262
+ if (import_react.default.isValidElement(last) && last.type === Separator) out.pop();
263
+ else break;
264
+ }
265
+ return out;
266
+ }, [children, isAllowed, defaultHideUnauthorized]);
224
267
  return (0, import_react_dom.createPortal)(
225
268
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
226
269
  "div",
@@ -246,7 +289,7 @@ function Content({
246
289
  className
247
290
  ].join(" "),
248
291
  "data-open": "true",
249
- children
292
+ children: normalizedChildren
250
293
  }
251
294
  ),
252
295
  document.body
package/dist/Dropdown.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import {
3
+ import React, {
4
4
  createContext,
5
5
  useCallback,
6
6
  useContext,
@@ -135,7 +135,7 @@ function Content({
135
135
  className = "",
136
136
  maxHeight = 360
137
137
  }) {
138
- const { open, setOpen, triggerRef, menuRef, menuId, labelId, align } = useDropdown();
138
+ const { open, setOpen, triggerRef, menuRef, menuId, labelId, align, isAllowed, defaultHideUnauthorized } = useDropdown();
139
139
  const [pos, setPos] = useState({ top: 0, left: 0, origin: "top-left", maxH: maxHeight });
140
140
  const computePosition = useCallback(() => {
141
141
  var _a, _b;
@@ -191,6 +191,49 @@ function Content({
191
191
  }
192
192
  };
193
193
  if (!open) return null;
194
+ const normalizedChildren = useMemo(() => {
195
+ const arr = React.Children.toArray(children);
196
+ const list = arr.map((ch) => {
197
+ var _a, _b, _c;
198
+ if (React.isValidElement(ch)) {
199
+ const el = ch;
200
+ if (el.type === Separator) {
201
+ return { node: ch, kind: "SEP", visible: true };
202
+ }
203
+ if (el.type === Item) {
204
+ const require2 = (_a = el.props) == null ? void 0 : _a.require;
205
+ const hideIfUnauthorized = (_c = (_b = el.props) == null ? void 0 : _b.hideIfUnauthorized) != null ? _c : defaultHideUnauthorized;
206
+ const allowed = typeof isAllowed === "function" ? isAllowed(require2) : true;
207
+ const visible = hideIfUnauthorized ? !!allowed : true;
208
+ return { node: ch, kind: "ITEM", visible };
209
+ }
210
+ }
211
+ return { node: ch, kind: "OTHER", visible: true };
212
+ });
213
+ let filtered = list.filter((it) => it.visible);
214
+ const out = [];
215
+ for (const it of filtered) {
216
+ if (it.kind === "SEP") {
217
+ const prev = out.length > 0 ? out[out.length - 1] : null;
218
+ const prevIsSep = prev && React.isValidElement(prev) && prev.type === Separator;
219
+ if (prevIsSep) continue;
220
+ out.push(it.node);
221
+ } else {
222
+ out.push(it.node);
223
+ }
224
+ }
225
+ while (out.length > 0) {
226
+ const first = out[0];
227
+ if (React.isValidElement(first) && first.type === Separator) out.shift();
228
+ else break;
229
+ }
230
+ while (out.length > 0) {
231
+ const last = out[out.length - 1];
232
+ if (React.isValidElement(last) && last.type === Separator) out.pop();
233
+ else break;
234
+ }
235
+ return out;
236
+ }, [children, isAllowed, defaultHideUnauthorized]);
194
237
  return createPortal(
195
238
  /* @__PURE__ */ jsx(
196
239
  "div",
@@ -216,7 +259,7 @@ function Content({
216
259
  className
217
260
  ].join(" "),
218
261
  "data-open": "true",
219
- children
262
+ children: normalizedChildren
220
263
  }
221
264
  ),
222
265
  document.body
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framepexls-ui-lib",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Componentes UI de Framepexls para React/Next.",