@nswds/app 1.119.0 → 1.119.2

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.d.cts CHANGED
@@ -1098,13 +1098,19 @@ interface DynamicFaviconProps {
1098
1098
  }
1099
1099
  declare function DynamicFavicon({ lightModeFavicon, darkModeFavicon }: DynamicFaviconProps): null;
1100
1100
 
1101
- declare const ExpandableSearch: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLFormElement> & {
1101
+ type ExpandableSearchButtonProps = Omit<React$1.ComponentPropsWithoutRef<'button'>, 'type'> & {
1102
+ [key: `data-${string}`]: string | number | boolean | undefined;
1103
+ };
1104
+ declare const ExpandableSearch: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
1102
1105
  onAction?: (value: string) => void;
1103
1106
  defaultValue?: string;
1104
1107
  } & VariantProps<(props?: ({
1105
1108
  variant?: "default" | "white" | "primary-800" | "primary-600" | "primary-400" | "primary-200" | "grey-800" | "grey-600" | "grey-400" | "grey-200" | "accent-800" | "accent-600" | "accent-400" | "accent-200" | null | undefined;
1106
1109
  } & class_variance_authority_types.ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLFormElement>>;
1107
- declare const ExpandableSearchField: React$1.ForwardRefExoticComponent<React$1.InputHTMLAttributes<HTMLInputElement> & React$1.RefAttributes<HTMLInputElement>>;
1110
+ declare const ExpandableSearchField: React$1.ForwardRefExoticComponent<React$1.InputHTMLAttributes<HTMLInputElement> & {
1111
+ buttonLabel?: string;
1112
+ buttonProps?: ExpandableSearchButtonProps;
1113
+ } & React$1.RefAttributes<HTMLInputElement>>;
1108
1114
 
1109
1115
  declare function Fieldset({ className, ...props }: {
1110
1116
  className?: string;
package/dist/index.d.ts CHANGED
@@ -1098,13 +1098,19 @@ interface DynamicFaviconProps {
1098
1098
  }
1099
1099
  declare function DynamicFavicon({ lightModeFavicon, darkModeFavicon }: DynamicFaviconProps): null;
1100
1100
 
1101
- declare const ExpandableSearch: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLFormElement> & {
1101
+ type ExpandableSearchButtonProps = Omit<React$1.ComponentPropsWithoutRef<'button'>, 'type'> & {
1102
+ [key: `data-${string}`]: string | number | boolean | undefined;
1103
+ };
1104
+ declare const ExpandableSearch: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
1102
1105
  onAction?: (value: string) => void;
1103
1106
  defaultValue?: string;
1104
1107
  } & VariantProps<(props?: ({
1105
1108
  variant?: "default" | "white" | "primary-800" | "primary-600" | "primary-400" | "primary-200" | "grey-800" | "grey-600" | "grey-400" | "grey-200" | "accent-800" | "accent-600" | "accent-400" | "accent-200" | null | undefined;
1106
1109
  } & class_variance_authority_types.ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLFormElement>>;
1107
- declare const ExpandableSearchField: React$1.ForwardRefExoticComponent<React$1.InputHTMLAttributes<HTMLInputElement> & React$1.RefAttributes<HTMLInputElement>>;
1110
+ declare const ExpandableSearchField: React$1.ForwardRefExoticComponent<React$1.InputHTMLAttributes<HTMLInputElement> & {
1111
+ buttonLabel?: string;
1112
+ buttonProps?: ExpandableSearchButtonProps;
1113
+ } & React$1.RefAttributes<HTMLInputElement>>;
1108
1114
 
1109
1115
  declare function Fieldset({ className, ...props }: {
1110
1116
  className?: string;
package/dist/index.js CHANGED
@@ -14351,9 +14351,20 @@ function CodeDemoContent({ data, showCode = true, controls = defaultControls })
14351
14351
  React5__default.useEffect(() => {
14352
14352
  const frame2 = iframeRef.current;
14353
14353
  if (!frame2) return;
14354
+ const getTargetOrigin = () => {
14355
+ const src = frame2.getAttribute("src");
14356
+ if (!src || src === "about:blank") {
14357
+ return window.location.origin;
14358
+ }
14359
+ try {
14360
+ return new URL(src, window.location.href).origin;
14361
+ } catch {
14362
+ return window.location.origin;
14363
+ }
14364
+ };
14354
14365
  const send = () => {
14355
14366
  const msg = { type: "nswds-theme", payload: themeValues };
14356
- frame2.contentWindow?.postMessage(msg, "*");
14367
+ frame2.contentWindow?.postMessage(msg, getTargetOrigin());
14357
14368
  };
14358
14369
  send();
14359
14370
  frame2.addEventListener("load", send);
@@ -18278,85 +18289,131 @@ var expandableSearchFocusVariants = cva("", {
18278
18289
  }
18279
18290
  });
18280
18291
  var ExpandableSearchContext = React5.createContext(null);
18281
- var ExpandableSearch = React5.forwardRef(({ className, onAction, defaultValue = "", variant = "default", ...props }, ref) => {
18282
- const [value, setValue] = React5.useState(defaultValue);
18283
- const formRef = React5.useRef(null);
18284
- const resolvedVariant = variant ?? "default";
18285
- const handleAction = (e) => {
18286
- e.preventDefault();
18287
- if (onAction) {
18288
- onAction(value);
18289
- }
18290
- };
18291
- return /* @__PURE__ */ jsx(
18292
- ExpandableSearchContext.Provider,
18293
- {
18294
- value: { value, setValue, formRef, variant: resolvedVariant },
18295
- children: /* @__PURE__ */ jsx(
18296
- "form",
18292
+ var ExpandableSearch = React5.forwardRef(
18293
+ ({
18294
+ className,
18295
+ onAction,
18296
+ defaultValue = "",
18297
+ onSubmit,
18298
+ onFocusCapture,
18299
+ onBlurCapture,
18300
+ variant = "default",
18301
+ ...props
18302
+ }, ref) => {
18303
+ const [value, setValue] = React5.useState(defaultValue);
18304
+ const [formHasFocusWithin, setFormHasFocusWithin] = React5.useState(false);
18305
+ const resolvedVariant = variant ?? "default";
18306
+ const handleSubmit = (e) => {
18307
+ onSubmit?.(e);
18308
+ if (e.defaultPrevented) {
18309
+ return;
18310
+ }
18311
+ e.preventDefault();
18312
+ onAction?.(value);
18313
+ };
18314
+ const handleFocusCapture = (e) => {
18315
+ setFormHasFocusWithin(true);
18316
+ onFocusCapture?.(e);
18317
+ };
18318
+ const handleBlurCapture = (e) => {
18319
+ const nextFocusedElement = e.relatedTarget;
18320
+ if (!e.currentTarget.contains(nextFocusedElement)) {
18321
+ setFormHasFocusWithin(false);
18322
+ }
18323
+ onBlurCapture?.(e);
18324
+ };
18325
+ return /* @__PURE__ */ jsx(
18326
+ ExpandableSearchContext.Provider,
18327
+ {
18328
+ value: { value, setValue, formHasFocusWithin, variant: resolvedVariant },
18329
+ children: /* @__PURE__ */ jsx(
18330
+ "form",
18331
+ {
18332
+ ref,
18333
+ className: cn("group relative inline-block select-none", className),
18334
+ onBlurCapture: handleBlurCapture,
18335
+ onFocusCapture: handleFocusCapture,
18336
+ onSubmit: handleSubmit,
18337
+ ...props
18338
+ }
18339
+ )
18340
+ }
18341
+ );
18342
+ }
18343
+ );
18344
+ ExpandableSearch.displayName = "ExpandableSearch";
18345
+ var ExpandableSearchField = React5.forwardRef(
18346
+ ({ className, id: id3, buttonLabel = "Search", buttonProps, ...props }, ref) => {
18347
+ const context = React5.useContext(ExpandableSearchContext);
18348
+ if (!context) throw new Error("ExpandableSearchField must be used within ExpandableSearch");
18349
+ const generatedId = React5.useId();
18350
+ const {
18351
+ className: buttonClassName,
18352
+ children: buttonChildren,
18353
+ "aria-label": buttonAriaLabel,
18354
+ ...restButtonProps
18355
+ } = buttonProps ?? {};
18356
+ const isActive = context.value.length > 0 || context.formHasFocusWithin;
18357
+ const variant = context.variant;
18358
+ const inputId = id3 ?? generatedId;
18359
+ return /* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
18360
+ /* @__PURE__ */ jsx("label", { className: "sr-only", htmlFor: inputId, children: "Search" }),
18361
+ /* @__PURE__ */ jsx(
18362
+ "input",
18297
18363
  {
18298
18364
  ref,
18299
- className: cn("relative inline-block select-none", className),
18300
- onSubmit: handleAction,
18365
+ id: inputId,
18366
+ value: context.value,
18367
+ onChange: (e) => context.setValue(e.target.value),
18368
+ className: cn(
18369
+ "align-center flex h-12 w-12 cursor-pointer overflow-hidden rounded-sm border-0 text-transparent",
18370
+ "ring-offset-white focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
18371
+ "transition-[width,box-shadow,background-color] duration-300 ease-in-out",
18372
+ "placeholder:text-transparent placeholder:opacity-0",
18373
+ "expandable-search__input",
18374
+ expandableSearchFocusVariants({ variant }),
18375
+ expandableSearchCollapsedVariants({ variant }),
18376
+ // Conditionally apply classes based on active state
18377
+ {
18378
+ "p-0": !isActive,
18379
+ "w-96 cursor-auto pt-0 pr-12 pb-0 pl-4 outline-none select-auto": isActive
18380
+ },
18381
+ isActive && expandableSearchSurfaceVariants({ variant }),
18382
+ isActive && (variant === "default" ? "placeholder:text-grey-700 placeholder:opacity-100" : "placeholder:text-current placeholder:opacity-70"),
18383
+ className
18384
+ ),
18301
18385
  ...props
18302
18386
  }
18387
+ ),
18388
+ /* @__PURE__ */ jsx(
18389
+ "button",
18390
+ {
18391
+ "aria-label": buttonAriaLabel ?? buttonLabel,
18392
+ type: "submit",
18393
+ className: cn(
18394
+ "absolute top-0 right-0 z-10 flex h-12 w-12 rounded-sm transition-[background-color,box-shadow] duration-200",
18395
+ "ring-offset-white focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
18396
+ expandableSearchButtonVariants({ variant }),
18397
+ expandableSearchFocusVariants({ variant }),
18398
+ {
18399
+ "pointer-events-none": !isActive,
18400
+ "pointer-events-auto": isActive
18401
+ },
18402
+ buttonClassName
18403
+ ),
18404
+ ...restButtonProps,
18405
+ children: buttonChildren ?? /* @__PURE__ */ jsx(
18406
+ Icons.search,
18407
+ {
18408
+ "aria-hidden": "true",
18409
+ className: "m-auto block h-8 w-8 shrink-0 fill-current leading-none"
18410
+ }
18411
+ )
18412
+ }
18303
18413
  )
18304
- }
18305
- );
18306
- });
18307
- ExpandableSearch.displayName = "ExpandableSearch";
18308
- var ExpandableSearchField = React5.forwardRef(({ className, id: id3, ...props }, ref) => {
18309
- const context = React5.useContext(ExpandableSearchContext);
18310
- if (!context) throw new Error("ExpandableSearchField must be used within ExpandableSearch");
18311
- const [isFocused, setIsFocused] = React5.useState(false);
18312
- const generatedId = React5.useId();
18313
- const isActive = context.value.length > 0 || isFocused;
18314
- const variant = context.variant;
18315
- const inputId = id3 ?? generatedId;
18316
- return /* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
18317
- /* @__PURE__ */ jsx("label", { className: "sr-only", htmlFor: inputId, children: "Search" }),
18318
- /* @__PURE__ */ jsx(
18319
- "input",
18320
- {
18321
- ref,
18322
- id: inputId,
18323
- value: context.value,
18324
- onChange: (e) => context.setValue(e.target.value),
18325
- onFocus: () => setIsFocused(true),
18326
- onBlur: () => setIsFocused(false),
18327
- className: cn(
18328
- "peer align-center flex h-12 w-12 cursor-pointer overflow-hidden rounded-sm border-0 text-transparent",
18329
- "ring-offset-white focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
18330
- "transition-[width,box-shadow,background-color] duration-300 ease-in-out",
18331
- "placeholder:text-transparent placeholder:opacity-0",
18332
- "expandable-search__input",
18333
- expandableSearchFocusVariants({ variant }),
18334
- expandableSearchCollapsedVariants({ variant }),
18335
- // Conditionally apply classes based on active state
18336
- {
18337
- "p-0": !isActive,
18338
- "w-96 cursor-auto pt-0 pr-12 pb-0 pl-4 outline-none select-auto": isActive
18339
- },
18340
- isActive && expandableSearchSurfaceVariants({ variant }),
18341
- isActive && (variant === "default" ? "placeholder:text-grey-700 placeholder:opacity-100" : "placeholder:text-current placeholder:opacity-70"),
18342
- className
18343
- ),
18344
- ...props
18345
- }
18346
- ),
18347
- /* @__PURE__ */ jsx(
18348
- "button",
18349
- {
18350
- type: "button",
18351
- className: cn(
18352
- "pointer-events-none absolute top-0 right-0 z-10 flex h-12 w-12 rounded-sm transition-colors duration-200 peer-focus:pointer-events-auto",
18353
- expandableSearchButtonVariants({ variant })
18354
- ),
18355
- children: /* @__PURE__ */ jsx(Icons.search, { className: "m-auto block h-8 w-8 shrink-0 fill-current leading-none" })
18356
- }
18357
- )
18358
- ] });
18359
- });
18414
+ ] });
18415
+ }
18416
+ );
18360
18417
  ExpandableSearchField.displayName = "ExpandableSearchField";
18361
18418
  function Fieldset2({
18362
18419
  className,
@@ -18885,7 +18942,7 @@ function FormatToggle({ format, setFormat }) {
18885
18942
 
18886
18943
  // package.json
18887
18944
  var package_default = {
18888
- version: "1.118.0"};
18945
+ version: "1.119.1"};
18889
18946
  var SluggerContext = React5__default.createContext(null);
18890
18947
  function flattenText(nodes) {
18891
18948
  if (nodes == null || typeof nodes === "boolean") return "";
@@ -31312,7 +31369,14 @@ function SidebarProvider({
31312
31369
  } else {
31313
31370
  _setOpen(openState);
31314
31371
  }
31315
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
31372
+ const cookieParts = [
31373
+ `${SIDEBAR_COOKIE_NAME}=${encodeURIComponent(String(openState))}`,
31374
+ "path=/",
31375
+ `max-age=${SIDEBAR_COOKIE_MAX_AGE}`,
31376
+ "SameSite=Lax",
31377
+ "Secure"
31378
+ ];
31379
+ document.cookie = cookieParts.join("; ");
31316
31380
  },
31317
31381
  [setOpenProp, open]
31318
31382
  );