@jsenv/navi 0.12.4 → 0.12.7

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.
@@ -8555,6 +8555,27 @@ const useNavStateBasic = (id, initialValue, { debug } = {}) => {
8555
8555
 
8556
8556
  const useNavState = useNavStateBasic;
8557
8557
 
8558
+ const NEVER_SET = {};
8559
+ const useUrlSearchParam = (paramName) => {
8560
+ const documentUrl = documentUrlSignal.value;
8561
+ const searchParam = new URL(documentUrl).searchParams.get(paramName);
8562
+ const valueRef = useRef(NEVER_SET);
8563
+ const [value, setValue] = useState();
8564
+ if (valueRef.current !== searchParam) {
8565
+ valueRef.current = searchParam;
8566
+ setValue(searchParam);
8567
+ }
8568
+
8569
+ const setSearchParamValue = (newValue, { replace = true } = {}) => {
8570
+ const newUrlObject = new URL(window.location.href);
8571
+ newUrlObject.searchParams.set(paramName, newValue);
8572
+ const newUrl = newUrlObject.href;
8573
+ goTo(newUrl, { replace });
8574
+ };
8575
+
8576
+ return [value, setSearchParamValue];
8577
+ };
8578
+
8558
8579
  /**
8559
8580
  * UITransition
8560
8581
  *
@@ -12512,15 +12533,23 @@ const CharSlot = ({
12512
12533
  };
12513
12534
  const Icon = ({
12514
12535
  box,
12536
+ href,
12515
12537
  children,
12516
12538
  ...props
12517
12539
  }) => {
12540
+ const innerChildren = href ? jsx("svg", {
12541
+ width: "100%",
12542
+ height: "100%",
12543
+ children: jsx("use", {
12544
+ href: href
12545
+ })
12546
+ }) : children;
12518
12547
  if (box) {
12519
12548
  return jsx(Box, {
12520
12549
  layoutInline: true,
12521
12550
  layoutColumn: true,
12522
12551
  ...props,
12523
- children: children
12552
+ children: innerChildren
12524
12553
  });
12525
12554
  }
12526
12555
  return jsx(CharSlot, {
@@ -12528,7 +12557,7 @@ const Icon = ({
12528
12557
  ...props,
12529
12558
  children: jsx("span", {
12530
12559
  className: "navi_icon",
12531
- children: children
12560
+ children: innerChildren
12532
12561
  })
12533
12562
  });
12534
12563
  };
@@ -20293,8 +20322,143 @@ const Image = props => {
20293
20322
  });
20294
20323
  };
20295
20324
 
20325
+ const Code = ({
20326
+ contentSpacing = " ",
20327
+ children,
20328
+ ...rest
20329
+ }) => {
20330
+ return jsx(Box, {
20331
+ ...rest,
20332
+ as: "code",
20333
+ children: applyContentSpacingOnTextChildren(children, contentSpacing)
20334
+ });
20335
+ };
20336
+
20296
20337
  const LinkWithIcon = () => {};
20297
20338
 
20339
+ installImportMetaCss(import.meta);import.meta.css = /* css */`
20340
+ @layer navi {
20341
+ .navi_message_box {
20342
+ --background-color-info: #eaf6fc;
20343
+ --color-info: #376cc2;
20344
+ --background-color-success: #ecf9ef;
20345
+ --color-success: #50c464;
20346
+ --background-color-warning: #fdf6e3;
20347
+ --color-warning: #f19c05;
20348
+ --background-color-error: #fcebed;
20349
+ --color-error: #eb364b;
20350
+ }
20351
+ }
20352
+
20353
+ .navi_message_box {
20354
+ --x-background-color: var(--background-color-info);
20355
+ --x-color: var(--color-info);
20356
+ /* color: var(--x-color); */
20357
+ background-color: var(--x-background-color);
20358
+ }
20359
+
20360
+ .navi_message_box[data-level="info"] {
20361
+ --x-background-color: var(--background-color-info);
20362
+ --x-color: var(--color-info);
20363
+ }
20364
+ .navi_message_box[data-level="success"] {
20365
+ --x-background-color: var(--background-color-success);
20366
+ --x-color: var(--color-success);
20367
+ }
20368
+ .navi_message_box[data-level="warning"] {
20369
+ --x-background-color: var(--background-color-warning);
20370
+ --x-color: var(--color-warning);
20371
+ }
20372
+ .navi_message_box[data-level="error"] {
20373
+ --x-background-color: var(--background-color-error);
20374
+ --x-color: var(--color-error);
20375
+ }
20376
+
20377
+ .navi_message_box[data-left-stripe] {
20378
+ border-left: 6px solid var(--x-color);
20379
+ border-top-left-radius: 6px;
20380
+ border-bottom-left-radius: 6px;
20381
+ }
20382
+ `;
20383
+ Object.assign(PSEUDO_CLASSES, {
20384
+ ":-navi-info": {
20385
+ add: el => {
20386
+ el.setAttribute("data-level", "info");
20387
+ },
20388
+ remove: el => {
20389
+ if (el.getAttribute("data-level") === "info") {
20390
+ el.removeAttribute("data-level");
20391
+ }
20392
+ }
20393
+ },
20394
+ ":-navi-success": {
20395
+ add: el => {
20396
+ el.setAttribute("data-level", "success");
20397
+ },
20398
+ remove: el => {
20399
+ if (el.getAttribute("data-level") === "success") {
20400
+ el.removeAttribute("data-level");
20401
+ }
20402
+ }
20403
+ },
20404
+ ":-navi-warning": {
20405
+ add: el => {
20406
+ el.setAttribute("data-level", "warning");
20407
+ },
20408
+ remove: el => {
20409
+ if (el.getAttribute("data-level") === "warning") {
20410
+ el.removeAttribute("data-level");
20411
+ }
20412
+ }
20413
+ },
20414
+ ":-navi-error": {
20415
+ add: el => {
20416
+ el.setAttribute("data-level", "error");
20417
+ },
20418
+ remove: el => {
20419
+ if (el.getAttribute("data-level") === "error") {
20420
+ el.removeAttribute("data-level");
20421
+ }
20422
+ }
20423
+ }
20424
+ });
20425
+ const MessageBoxPseudoClasses = [":-navi-info", ":-navi-success", ":-navi-warning", ":-navi-error"];
20426
+ const MessageBoxLevelContext = createContext();
20427
+ const MessageBoxReportTitleChildContext = createContext();
20428
+ const MessageBox = ({
20429
+ level = "info",
20430
+ padding = "sm",
20431
+ contentSpacing = " ",
20432
+ leftStripe,
20433
+ children,
20434
+ ...rest
20435
+ }) => {
20436
+ const [hasTitleChild, setHasTitleChild] = useState(false);
20437
+ const innerLeftStripe = leftStripe === undefined ? hasTitleChild : leftStripe;
20438
+ return jsx(Box, {
20439
+ as: "div",
20440
+ role: level === "info" ? "status" : "alert",
20441
+ "data-left-stripe": innerLeftStripe ? "" : undefined,
20442
+ ...rest,
20443
+ baseClassName: "navi_message_box",
20444
+ padding: padding,
20445
+ pseudoClasses: MessageBoxPseudoClasses,
20446
+ basePseudoState: {
20447
+ ":-navi-info": level === "info",
20448
+ ":-navi-success": level === "success",
20449
+ ":-navi-warning": level === "warning",
20450
+ ":-navi-error": level === "error"
20451
+ },
20452
+ children: jsx(MessageBoxLevelContext.Provider, {
20453
+ value: level,
20454
+ children: jsx(MessageBoxReportTitleChildContext.Provider, {
20455
+ value: setHasTitleChild,
20456
+ children: applyContentSpacingOnTextChildren(children, contentSpacing)
20457
+ })
20458
+ })
20459
+ });
20460
+ };
20461
+
20298
20462
  const Svg = props => {
20299
20463
  return jsx(Box, {
20300
20464
  ...props,
@@ -20303,16 +20467,29 @@ const Svg = props => {
20303
20467
  };
20304
20468
 
20305
20469
  const Title = ({
20306
- as = "h1",
20470
+ as,
20307
20471
  bold = true,
20308
20472
  contentSpacing = " ",
20473
+ color,
20309
20474
  children,
20475
+ marginTop,
20476
+ marginBottom,
20310
20477
  ...rest
20311
20478
  }) => {
20479
+ const messageBoxLevel = useContext(MessageBoxLevelContext);
20480
+ const reportTitleToMessageBox = useContext(MessageBoxReportTitleChildContext);
20481
+ const innerColor = color === undefined ? messageBoxLevel ? `var(--x-color)` : undefined : color;
20482
+ const innerAs = as === undefined ? messageBoxLevel ? "h4" : "h1" : as;
20483
+ reportTitleToMessageBox?.(true);
20484
+ const innerMarginTop = marginTop === undefined ? messageBoxLevel ? "0" : undefined : marginTop;
20485
+ const innerMarginBottom = marginBottom === undefined ? messageBoxLevel ? "8px" : undefined : marginBottom;
20312
20486
  return jsx(Box, {
20313
20487
  ...rest,
20314
- as: as,
20488
+ as: innerAs,
20315
20489
  bold: bold,
20490
+ color: innerColor,
20491
+ marginTop: innerMarginTop,
20492
+ marginBottom: innerMarginBottom,
20316
20493
  children: applyContentSpacingOnTextChildren(children, contentSpacing)
20317
20494
  });
20318
20495
  };
@@ -20394,5 +20571,5 @@ const useDependenciesDiff = (inputs) => {
20394
20571
  return diffRef.current;
20395
20572
  };
20396
20573
 
20397
- export { ActionRenderer, ActiveKeyboardShortcuts, Box, Button, CharSlot, Checkbox, CheckboxList, Col, Colgroup, Count, Details, Editable, ErrorBoundaryContext, FontSizedSvg, Form, Icon, IconAndText, Image, Input, Label, Layout, Link, LinkWithIcon, Paragraph, Radio, RadioList, Route, RouteLink, Routes, RowNumberCol, RowNumberTableCell, SINGLE_SPACE_CONSTRAINT, SVGMaskOverlay, Select, SelectionContext, SummaryMarker, Svg, Tab, TabList, Table, TableCell, Tbody, Text, Thead, Title, Tr, UITransition, actionIntegratedVia, addCustomMessage, createAction, createSelectionKeyboardShortcuts, createUniqueValueConstraint, enableDebugActions, enableDebugOnDocumentLoading, forwardActionRequested, goBack, goForward, goTo, installCustomConstraintValidation, isCellSelected, isColumnSelected, isRowSelected, openCallout, rawUrlPart, reload, removeCustomMessage, rerunActions, resource, setBaseUrl, setupRoutes, stopLoad, stringifyTableSelectionValue, updateActions, useActionData, useActionStatus, useCellsAndColumns, useDependenciesDiff, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useKeyboardShortcuts, useNavState, useRouteStatus, useRunOnMount, useSelectableElement, useSelectionController, useSignalSync, useStateArray, valueInLocalStorage };
20574
+ export { ActionRenderer, ActiveKeyboardShortcuts, Box, Button, CharSlot, Checkbox, CheckboxList, Code, Col, Colgroup, Count, Details, Editable, ErrorBoundaryContext, FontSizedSvg, Form, Icon, IconAndText, Image, Input, Label, Layout, Link, LinkWithIcon, MessageBox, Paragraph, Radio, RadioList, Route, RouteLink, Routes, RowNumberCol, RowNumberTableCell, SINGLE_SPACE_CONSTRAINT, SVGMaskOverlay, Select, SelectionContext, SummaryMarker, Svg, Tab, TabList, Table, TableCell, Tbody, Text, Thead, Title, Tr, UITransition, actionIntegratedVia, addCustomMessage, createAction, createSelectionKeyboardShortcuts, createUniqueValueConstraint, enableDebugActions, enableDebugOnDocumentLoading, forwardActionRequested, goBack, goForward, goTo, installCustomConstraintValidation, isCellSelected, isColumnSelected, isRowSelected, openCallout, rawUrlPart, reload, removeCustomMessage, rerunActions, resource, setBaseUrl, setupRoutes, stopLoad, stringifyTableSelectionValue, updateActions, useActionData, useActionStatus, useCellsAndColumns, useDependenciesDiff, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useKeyboardShortcuts, useNavState, useRouteStatus, useRunOnMount, useSelectableElement, useSelectionController, useSignalSync, useStateArray, useUrlSearchParam, valueInLocalStorage };
20398
20575
  //# sourceMappingURL=jsenv_navi.js.map