@vuu-ui/vuu-popups 0.8.1-debug → 0.8.2-debug

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/cjs/index.js CHANGED
@@ -64,6 +64,7 @@ __export(src_exports, {
64
64
  MenuItem: () => MenuItem,
65
65
  MenuItemGroup: () => MenuItemGroup,
66
66
  Popup: () => Popup,
67
+ PopupMenu: () => PopupMenu,
67
68
  PopupService: () => PopupService,
68
69
  Portal: () => Portal,
69
70
  Separator: () => Separator,
@@ -230,14 +231,14 @@ var isDrawer = (component) => component.type === Drawer_default;
230
231
  var isVertical = ({ props: { position = "left" } }) => position.match(/top|bottom/);
231
232
  var DockLayout = (props) => {
232
233
  const { children, className: classNameProp, id, style } = props;
233
- const classBase11 = "vuuDockLayout";
234
+ const classBase12 = "vuuDockLayout";
234
235
  const [drawers, content] = (0, import_vuu_utils.partition)(children, isDrawer);
235
236
  const [verticalDrawers, horizontalDrawers] = (0, import_vuu_utils.partition)(drawers, isVertical);
236
237
  const orientation = verticalDrawers.length === 0 ? "horizontal" : horizontalDrawers.length === 0 ? "vertical" : "both";
237
- const className = (0, import_classnames5.default)(classBase11, classNameProp, `${classBase11}-${orientation}`);
238
+ const className = (0, import_classnames5.default)(classBase12, classNameProp, `${classBase12}-${orientation}`);
238
239
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className, id, style, children: [
239
240
  drawers,
240
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${classBase11}-content`, children: content })
241
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${classBase12}-content`, children: content })
241
242
  ] });
242
243
  };
243
244
  DockLayout.displayName = "DockLayout";
@@ -1387,10 +1388,13 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
1387
1388
  const dimensionsRef = (0, import_react23.useRef)(dimensions);
1388
1389
  const measure = (0, import_react23.useCallback)((target) => {
1389
1390
  const rect = target.getBoundingClientRect();
1390
- return dimensionsRef.current.reduce((map, dim) => {
1391
- map[dim] = getTargetSize(target, rect, dim);
1392
- return map;
1393
- }, {});
1391
+ return dimensionsRef.current.reduce(
1392
+ (map, dim) => {
1393
+ map[dim] = getTargetSize(target, rect, dim);
1394
+ return map;
1395
+ },
1396
+ {}
1397
+ );
1394
1398
  }, []);
1395
1399
  (0, import_react23.useLayoutEffect)(() => {
1396
1400
  const target = ref.current;
@@ -1416,7 +1420,9 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
1416
1420
  }
1417
1421
  if (target) {
1418
1422
  if (observedMap.has(target)) {
1419
- throw Error("useResizeObserver attemping to observe same element twice");
1423
+ throw Error(
1424
+ "useResizeObserver attemping to observe same element twice"
1425
+ );
1420
1426
  }
1421
1427
  void registerObserver();
1422
1428
  }
@@ -1427,7 +1433,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
1427
1433
  cleanedUp = true;
1428
1434
  }
1429
1435
  };
1430
- }, [ref, measure]);
1436
+ }, [ref, measure, reportInitialSize, onResize]);
1431
1437
  (0, import_react23.useLayoutEffect)(() => {
1432
1438
  const target = ref.current;
1433
1439
  const record = observedMap.get(target);
@@ -1936,6 +1942,7 @@ var View = (0, import_react31.forwardRef)(function View2(props, forwardedRef) {
1936
1942
  className,
1937
1943
  collapsed,
1938
1944
  closeable,
1945
+ "data-path": dataPath,
1939
1946
  "data-resizeable": dataResizeable,
1940
1947
  dropTargets,
1941
1948
  expanded,
@@ -1943,7 +1950,7 @@ var View = (0, import_react31.forwardRef)(function View2(props, forwardedRef) {
1943
1950
  id: idProp,
1944
1951
  header,
1945
1952
  orientation = "horizontal",
1946
- path,
1953
+ path = dataPath,
1947
1954
  resize = "responsive",
1948
1955
  resizeable = dataResizeable,
1949
1956
  tearOut,
@@ -2074,7 +2081,7 @@ var Header = ({
2074
2081
  const [editing, setEditing] = (0, import_react32.useState)(false);
2075
2082
  const viewDispatch = useViewDispatch();
2076
2083
  const handleClose = (evt) => viewDispatch == null ? void 0 : viewDispatch({ type: "remove" }, evt);
2077
- const classBase11 = "vuuHeader";
2084
+ const classBase12 = "vuuHeader";
2078
2085
  const handleTitleMouseDown = () => {
2079
2086
  var _a;
2080
2087
  (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
@@ -2084,9 +2091,9 @@ var Header = ({
2084
2091
  };
2085
2092
  const orientation = collapsed || orientationProp;
2086
2093
  const className = (0, import_classnames13.default)(
2087
- classBase11,
2094
+ classBase12,
2088
2095
  classNameProp,
2089
- `${classBase11}-${orientation}`
2096
+ `${classBase12}-${orientation}`
2090
2097
  );
2091
2098
  const handleEnterEditMode = () => {
2092
2099
  setEditing(true);
@@ -2216,7 +2223,7 @@ var Palette = ({
2216
2223
  ...props
2217
2224
  }) => {
2218
2225
  const dispatch = useLayoutProviderDispatch();
2219
- const classBase11 = "vuuPalette";
2226
+ const classBase12 = "vuuPalette";
2220
2227
  function handleMouseDown(evt) {
2221
2228
  var _a;
2222
2229
  const target = evt.target;
@@ -2263,7 +2270,7 @@ var Palette = ({
2263
2270
  {
2264
2271
  ...props,
2265
2272
  borderless: true,
2266
- className: (0, import_classnames14.default)(classBase11, className, `${classBase11}-${orientation}`),
2273
+ className: (0, import_classnames14.default)(classBase12, className, `${classBase12}-${orientation}`),
2267
2274
  maxHeight: 800,
2268
2275
  selected: null,
2269
2276
  children: children.map(
@@ -2650,7 +2657,15 @@ var import_jsx_runtime28 = require("react/jsx-runtime");
2650
2657
 
2651
2658
  // ../vuu-shell/src/login/login-utils.ts
2652
2659
  var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
2653
- var redirectToLogin = (loginUrl = "login.html") => {
2660
+ var getAuthModeFromCookies = () => {
2661
+ const mode = (0, import_vuu_utils10.getCookieValue)("vuu-auth-mode");
2662
+ return mode != null ? mode : "";
2663
+ };
2664
+ var getDefaultLoginUrl = () => {
2665
+ const authMode = getAuthModeFromCookies();
2666
+ return authMode === "login" ? "login.html" : "demo.html";
2667
+ };
2668
+ var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
2654
2669
  window.location.href = loginUrl;
2655
2670
  };
2656
2671
  var logout = (loginUrl) => {
@@ -3748,6 +3763,7 @@ var Viewport = class {
3748
3763
  // TODO roll disabled/suspended into status
3749
3764
  this.status = "";
3750
3765
  this.suspended = false;
3766
+ this.suspendTimer = null;
3751
3767
  this.rangeRequestAlreadyPending = (range) => {
3752
3768
  const { bufferSize } = this;
3753
3769
  const bufferThreshold = bufferSize * 0.25;
@@ -4125,6 +4141,7 @@ var Viewport = class {
4125
4141
  disable(requestId) {
4126
4142
  this.awaitOperation(requestId, { type: "disable" });
4127
4143
  info2 == null ? void 0 : info2(\`disable: \${this.serverViewportId}\`);
4144
+ this.suspended = false;
4128
4145
  return {
4129
4146
  type: DISABLE_VP,
4130
4147
  viewPortId: this.serverViewportId
@@ -4555,7 +4572,19 @@ var ServerProxy = class {
4555
4572
  this.sendIfReady(request, requestId, viewport.status === "subscribed");
4556
4573
  }
4557
4574
  }
4575
+ suspendViewport(viewport) {
4576
+ viewport.suspend();
4577
+ viewport.suspendTimer = setTimeout(() => {
4578
+ info3 == null ? void 0 : info3("suspendTimer expired, escalate suspend to disable");
4579
+ this.disableViewport(viewport);
4580
+ }, 3e3);
4581
+ }
4558
4582
  resumeViewport(viewport) {
4583
+ if (viewport.suspendTimer) {
4584
+ debug4 == null ? void 0 : debug4("clear suspend timer");
4585
+ clearTimeout(viewport.suspendTimer);
4586
+ viewport.suspendTimer = null;
4587
+ }
4559
4588
  const rows = viewport.resume();
4560
4589
  this.postMessageToClient({
4561
4590
  clientViewportId: viewport.clientViewportId,
@@ -4675,7 +4704,7 @@ var ServerProxy = class {
4675
4704
  case "select":
4676
4705
  return this.select(viewport, message);
4677
4706
  case "suspend":
4678
- return viewport.suspend();
4707
+ return this.suspendViewport(viewport);
4679
4708
  case "resume":
4680
4709
  return this.resumeViewport(viewport);
4681
4710
  case "enable":
@@ -6755,8 +6784,8 @@ var Stack3 = class {
6755
6784
  // Start an empty stack
6756
6785
  /// @internal
6757
6786
  static start(p, state, pos = 0) {
6758
- let cx28 = p.parser.context;
6759
- return new Stack3(p, [], state, pos, pos, 0, [], 0, cx28 ? new StackContext(cx28, cx28.start) : null, 0, null);
6787
+ let cx29 = p.parser.context;
6788
+ return new Stack3(p, [], state, pos, pos, 0, [], 0, cx29 ? new StackContext(cx29, cx29.start) : null, 0, null);
6760
6789
  }
6761
6790
  /// The stack's current [context](#lr.ContextTracker) value, if
6762
6791
  /// any. Its type will depend on the context tracker's type
@@ -8257,10 +8286,10 @@ var LRParser = class extends Parser {
8257
8286
  if (config.props)
8258
8287
  copy.nodeSet = this.nodeSet.extend(...config.props);
8259
8288
  if (config.top) {
8260
- let info = this.topRules[config.top];
8261
- if (!info)
8289
+ let info2 = this.topRules[config.top];
8290
+ if (!info2)
8262
8291
  throw new RangeError(`Invalid top rule name ${config.top}`);
8263
- copy.top = info;
8292
+ copy.top = info2;
8264
8293
  }
8265
8294
  if (config.tokenizers)
8266
8295
  copy.tokenizers = this.tokenizers.map((t) => {
@@ -9443,6 +9472,7 @@ var cloneRow = (row, index, isExpanded) => {
9443
9472
 
9444
9473
  // ../vuu-data/src/remote-data-source.ts
9445
9474
  var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
9475
+ var { info } = (0, import_vuu_utils16.logger)("RemoteDataSource");
9446
9476
  var _config2, _groupBy2, _optimize, _range3, _selectedRowsCount3, _size3, _title3;
9447
9477
  var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9448
9478
  constructor({
@@ -9460,8 +9490,6 @@ var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9460
9490
  super();
9461
9491
  this.server = null;
9462
9492
  this.status = "initialising";
9463
- this.disabled = false;
9464
- this.suspended = false;
9465
9493
  __privateAdd(this, _config2, vanillaConfig);
9466
9494
  __privateAdd(this, _groupBy2, []);
9467
9495
  __privateAdd(this, _optimize, "throttle");
@@ -9600,6 +9628,7 @@ var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9600
9628
  }
9601
9629
  unsubscribe() {
9602
9630
  var _a, _b;
9631
+ info == null ? void 0 : info(`unsubscribe #${this.viewport}`);
9603
9632
  if (this.viewport) {
9604
9633
  (_a = this.server) == null ? void 0 : _a.unsubscribe(this.viewport);
9605
9634
  }
@@ -9608,8 +9637,9 @@ var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9608
9637
  }
9609
9638
  suspend() {
9610
9639
  var _a;
9640
+ info == null ? void 0 : info(`suspend #${this.viewport}, current status ${this.status}`);
9611
9641
  if (this.viewport) {
9612
- this.suspended = true;
9642
+ this.status = "suspended";
9613
9643
  (_a = this.server) == null ? void 0 : _a.send({
9614
9644
  type: "suspend",
9615
9645
  viewport: this.viewport
@@ -9619,20 +9649,25 @@ var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9619
9649
  }
9620
9650
  resume() {
9621
9651
  var _a;
9622
- if (this.viewport && this.suspended) {
9623
- (_a = this.server) == null ? void 0 : _a.send({
9624
- type: "resume",
9625
- viewport: this.viewport
9626
- });
9627
- this.suspended = false;
9652
+ info == null ? void 0 : info(`resume #${this.viewport}, current status ${this.status}`);
9653
+ if (this.viewport) {
9654
+ if (this.status === "disabled" || this.status === "disabling") {
9655
+ this.enable();
9656
+ } else if (this.status === "suspended") {
9657
+ (_a = this.server) == null ? void 0 : _a.send({
9658
+ type: "resume",
9659
+ viewport: this.viewport
9660
+ });
9661
+ this.status = "subscribed";
9662
+ }
9628
9663
  }
9629
9664
  return this;
9630
9665
  }
9631
9666
  disable() {
9632
9667
  var _a;
9668
+ info == null ? void 0 : info(`disable #${this.viewport}, current status ${this.status}`);
9633
9669
  if (this.viewport) {
9634
9670
  this.status = "disabling";
9635
- this.disabled = true;
9636
9671
  (_a = this.server) == null ? void 0 : _a.send({
9637
9672
  viewport: this.viewport,
9638
9673
  type: "disable"
@@ -9642,13 +9677,13 @@ var RemoteDataSource = class extends import_vuu_utils16.EventEmitter {
9642
9677
  }
9643
9678
  enable() {
9644
9679
  var _a;
9645
- if (this.viewport && this.disabled) {
9680
+ info == null ? void 0 : info(`enable #${this.viewport}, current status ${this.status}`);
9681
+ if (this.viewport && (this.status === "disabled" || this.status === "disabling")) {
9646
9682
  this.status = "enabling";
9647
9683
  (_a = this.server) == null ? void 0 : _a.send({
9648
9684
  viewport: this.viewport,
9649
9685
  type: "enable"
9650
9686
  });
9651
- this.disabled = false;
9652
9687
  }
9653
9688
  return this;
9654
9689
  }
@@ -11312,7 +11347,7 @@ var Popup = (props) => {
11312
11347
 
11313
11348
  // src/menu/useContextMenu.tsx
11314
11349
  var import_jsx_runtime45 = require("react/jsx-runtime");
11315
- var useContextMenu = (menuBuilder) => {
11350
+ var useContextMenu = (menuBuilder, menuActionHandler) => {
11316
11351
  const ctx = (0, import_react63.useContext)(ContextMenuContext);
11317
11352
  const [themeClass, densityClass, dataMode] = useThemeAttributes();
11318
11353
  const buildMenuOptions = (0, import_react63.useCallback)(
@@ -11340,11 +11375,12 @@ var useContextMenu = (menuBuilder) => {
11340
11375
  console.log({
11341
11376
  menuItemDescriptors
11342
11377
  });
11343
- if (menuItemDescriptors.length && (ctx == null ? void 0 : ctx.menuActionHandler)) {
11378
+ const menuHandler = menuActionHandler != null ? menuActionHandler : ctx == null ? void 0 : ctx.menuActionHandler;
11379
+ if (menuItemDescriptors.length && menuHandler) {
11344
11380
  console.log(`showContextMenu ${location2}`, {
11345
11381
  options
11346
11382
  });
11347
- showContextMenu(e, menuItemDescriptors, ctx.menuActionHandler, {
11383
+ showContextMenu(e, menuItemDescriptors, menuHandler, {
11348
11384
  ...ContextMenuProps2,
11349
11385
  className: (0, import_classnames29.default)(
11350
11386
  ContextMenuProps2 == null ? void 0 : ContextMenuProps2.className,
@@ -11366,6 +11402,7 @@ var useContextMenu = (menuBuilder) => {
11366
11402
  ctx == null ? void 0 : ctx.menuBuilders,
11367
11403
  dataMode,
11368
11404
  densityClass,
11405
+ menuActionHandler,
11369
11406
  menuBuilder,
11370
11407
  themeClass
11371
11408
  ]
@@ -11413,4 +11450,54 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
11413
11450
  );
11414
11451
  PopupService.showPopup({ left: 0, top: 0, component });
11415
11452
  };
11453
+
11454
+ // src/popup-menu/PopupMenu.tsx
11455
+ var import_react64 = require("react");
11456
+ var import_classnames30 = __toESM(require("classnames"));
11457
+ var import_jsx_runtime46 = require("react/jsx-runtime");
11458
+ var classBase11 = "vuuPopupMenu";
11459
+ var getPosition3 = (element) => {
11460
+ if (element) {
11461
+ const { bottom, left } = element.getBoundingClientRect();
11462
+ return { x: left, y: bottom + 6 };
11463
+ }
11464
+ };
11465
+ var PopupMenu = ({
11466
+ className,
11467
+ menuActionHandler,
11468
+ menuBuilder,
11469
+ menuLocation = "header",
11470
+ ...htmlAttributes
11471
+ }) => {
11472
+ const rootRef = (0, import_react64.useRef)(null);
11473
+ const [menuOpen, setMenuOpen] = (0, import_react64.useState)(false);
11474
+ const showContextMenu2 = useContextMenu(menuBuilder, menuActionHandler);
11475
+ const handleMenuClose = (0, import_react64.useCallback)(() => {
11476
+ setMenuOpen(false);
11477
+ }, []);
11478
+ const showColumnMenu = (0, import_react64.useCallback)(
11479
+ (e) => {
11480
+ setMenuOpen(true);
11481
+ showContextMenu2(e, menuLocation, {
11482
+ ContextMenuProps: {
11483
+ onClose: handleMenuClose,
11484
+ position: getPosition3(rootRef.current)
11485
+ }
11486
+ });
11487
+ },
11488
+ [handleMenuClose, menuLocation, showContextMenu2]
11489
+ );
11490
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11491
+ "span",
11492
+ {
11493
+ ...htmlAttributes,
11494
+ className: (0, import_classnames30.default)(classBase11, className, {
11495
+ [`${classBase11}-open`]: menuOpen
11496
+ }),
11497
+ "data-icon": "more-vert",
11498
+ onClick: showColumnMenu,
11499
+ ref: rootRef
11500
+ }
11501
+ );
11502
+ };
11416
11503
  //# sourceMappingURL=index.js.map