@epilot/spark-ui 0.30.2 → 0.30.3
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/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.cjs +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +1 -1
- package/dist/components/autocomplete.js +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.cjs +3 -1
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.js +3 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/combobox.cjs +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/dialog.cjs +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.cjs +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +7 -2
- package/dist/components/input-date-time.cjs.map +1 -1
- package/dist/components/input-date-time.js +7 -2
- package/dist/components/input-date-time.js.map +1 -1
- package/dist/components/input-date.cjs +1 -1
- package/dist/components/input-date.js +1 -1
- package/dist/components/input-group.cjs +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-otp.cjs +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/period-tabs.cjs +1 -1
- package/dist/components/period-tabs.js +1 -1
- package/dist/components/pill.cjs +1 -1
- package/dist/components/pill.js +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/power-network.cjs +1 -1
- package/dist/components/power-network.js +1 -1
- package/dist/components/schedule-list.cjs +1 -1
- package/dist/components/schedule-list.js +1 -1
- package/dist/components/select.cjs +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/sheet.cjs +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/stepper.cjs +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/table.cjs +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.cjs +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toast.cjs +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/tooltip.cjs +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/trace.cjs +1 -1
- package/dist/components/trace.js +1 -1
- package/dist/lib/calendar-day-button.cjs +23 -0
- package/dist/lib/calendar-day-button.cjs.map +1 -0
- package/dist/lib/calendar-day-button.d.cts +14 -0
- package/dist/lib/calendar-day-button.d.ts +14 -0
- package/dist/lib/calendar-day-button.js +20 -0
- package/dist/lib/calendar-day-button.js.map +1 -0
- package/dist/lib/calendar-lists.cjs +6 -5
- package/dist/lib/calendar-lists.cjs.map +1 -1
- package/dist/lib/calendar-lists.js +6 -5
- package/dist/lib/calendar-lists.js.map +1 -1
- package/dist/lib/input-date-parts.cjs +3 -2
- package/dist/lib/input-date-parts.cjs.map +1 -1
- package/dist/lib/input-date-parts.js +3 -2
- package/dist/lib/input-date-parts.js.map +1 -1
- package/dist/lib/scroll-within.cjs +27 -0
- package/dist/lib/scroll-within.cjs.map +1 -0
- package/dist/lib/scroll-within.d.cts +14 -0
- package/dist/lib/scroll-within.d.ts +14 -0
- package/dist/lib/scroll-within.js +25 -0
- package/dist/lib/scroll-within.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,9 +4,9 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
const require_components_theme = require("./theme.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
8
|
let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
|
|
8
9
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
let _base_ui_react_popover = require("@base-ui/react/popover");
|
|
11
11
|
let cn = require("cn");
|
|
12
12
|
//#region src/components/popover.tsx
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { PortalTheme } from "./theme.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
7
|
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
9
9
|
//#region src/components/popover.tsx
|
|
10
10
|
const PopoverAnchorContext = React$1.createContext(null);
|
|
@@ -5,8 +5,8 @@ const require_components_skeleton = require("./skeleton.cjs");
|
|
|
5
5
|
const require_components_typography = require("./typography.cjs");
|
|
6
6
|
const require_components_number_flow = require("./number-flow.cjs");
|
|
7
7
|
let react = require("react");
|
|
8
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
10
10
|
let cn = require("cn");
|
|
11
11
|
//#region src/components/power-network.tsx
|
|
12
12
|
const SOURCE_VARIANTS = {
|
|
@@ -5,8 +5,8 @@ import { Skeleton } from "./skeleton.js";
|
|
|
5
5
|
import { SectionTitle } from "./typography.js";
|
|
6
6
|
import NumberFlow from "./number-flow.js";
|
|
7
7
|
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
8
|
-
import { Home } from "@epilot/spark-icons";
|
|
9
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Home } from "@epilot/spark-icons";
|
|
10
10
|
//#region src/components/power-network.tsx
|
|
11
11
|
const SOURCE_VARIANTS = {
|
|
12
12
|
grid: {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/schedule-list.tsx
|
|
10
10
|
const ScheduleList = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { Add, Delete } from "@epilot/spark-icons";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Add, Delete } from "@epilot/spark-icons";
|
|
6
6
|
//#region src/components/schedule-list.tsx
|
|
7
7
|
const ScheduleList = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
8
8
|
ref,
|
|
@@ -7,8 +7,8 @@ const require_lib_input_box_variants = require("../lib/input-box-variants.cjs");
|
|
|
7
7
|
const require_components_field = require("./field.cjs");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_chunk.__toESM(react);
|
|
10
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
11
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
12
12
|
let _base_ui_react_select = require("@base-ui/react/select");
|
|
13
13
|
let cn = require("cn");
|
|
14
14
|
//#region src/components/select.tsx
|
|
@@ -5,8 +5,8 @@ import { PortalTheme } from "./theme.js";
|
|
|
5
5
|
import { boxChrome, floatingChrome } from "../lib/input-box-variants.js";
|
|
6
6
|
import { useFieldControl } from "./field.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import { Check, Close, KeyboardArrowDown } from "@epilot/spark-icons";
|
|
9
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Check, Close, KeyboardArrowDown } from "@epilot/spark-icons";
|
|
10
10
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
11
11
|
//#region src/components/select.tsx
|
|
12
12
|
const Select = Select$1.Root;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/separator.tsx
|
|
10
10
|
const dots = "bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
6
|
//#region src/components/separator.tsx
|
|
7
7
|
const dots = "bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted";
|
|
8
8
|
const dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`;
|
|
@@ -5,8 +5,8 @@ const require_components_theme = require("./theme.cjs");
|
|
|
5
5
|
const require_components_button = require("./button.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_chunk.__toESM(react);
|
|
8
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
10
10
|
let _base_ui_react_dialog = require("@base-ui/react/dialog");
|
|
11
11
|
let cn = require("cn");
|
|
12
12
|
//#region src/components/sheet.tsx
|
package/dist/components/sheet.js
CHANGED
|
@@ -3,8 +3,8 @@ import { cn } from "../utils/cn.js";
|
|
|
3
3
|
import { PortalTheme } from "./theme.js";
|
|
4
4
|
import { buttonVariants } from "./button.js";
|
|
5
5
|
import "react";
|
|
6
|
-
import { Close } from "@epilot/spark-icons";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Close } from "@epilot/spark-icons";
|
|
8
8
|
import { Dialog } from "@base-ui/react/dialog";
|
|
9
9
|
//#region src/components/sheet.tsx
|
|
10
10
|
function Sheet(props) {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/skeleton.tsx
|
|
10
10
|
const Skeleton = react.forwardRef(({ className, render, loading = true, children, ...props }, ref) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
5
4
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
6
|
//#region src/components/skeleton.tsx
|
|
7
7
|
const Skeleton = React$1.forwardRef(({ className, render, loading = true, children, ...props }, ref) => {
|
|
8
8
|
const hasElement = loading || render != null;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/stepper.tsx
|
|
10
10
|
const STEP_BUTTON = "touch-target inline-flex size-8 items-center justify-center rounded-sm text-gray transition-colors hover:bg-gray-a3 disabled:opacity-40 disabled:hover:bg-transparent motion-reduce:transition-none";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
6
6
|
//#region src/components/stepper.tsx
|
|
7
7
|
const STEP_BUTTON = "touch-target inline-flex size-8 items-center justify-center rounded-sm text-gray transition-colors hover:bg-gray-a3 disabled:opacity-40 disabled:hover:bg-transparent motion-reduce:transition-none";
|
|
8
8
|
const Stepper = React$1.forwardRef(({ value, onValueChange, onValueCommit, min = 0, max = 100, step = 1, formatValue = (v) => String(v), disabled, className, commitDelayMs = 400, "aria-label": ariaLabel, decreaseLabel, increaseLabel }, ref) => {
|
|
@@ -4,8 +4,8 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
const require_components_skeleton = require("./skeleton.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
9
|
let cn = require("cn");
|
|
10
10
|
//#region src/components/table.tsx
|
|
11
11
|
const TableContext = react.createContext({
|
package/dist/components/table.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { Skeleton } from "./skeleton.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
|
-
import { ArrowDownward, ArrowUpward, SwapVert } from "@epilot/spark-icons";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ArrowDownward, ArrowUpward, SwapVert } from "@epilot/spark-icons";
|
|
7
7
|
//#region src/components/table.tsx
|
|
8
8
|
const TableContext = React$1.createContext({
|
|
9
9
|
sort: null,
|
package/dist/components/tabs.cjs
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let _base_ui_react_tabs = require("@base-ui/react/tabs");
|
|
9
9
|
let cn = require("cn");
|
|
10
10
|
//#region src/components/tabs.tsx
|
package/dist/components/tabs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
6
6
|
import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
7
7
|
//#region src/components/tabs.tsx
|
|
8
8
|
const useIsomorphicLayoutEffect = typeof window === "undefined" ? React$1.useEffect : React$1.useLayoutEffect;
|
|
@@ -5,8 +5,8 @@ const require_lib_input_box_variants = require("../lib/input-box-variants.cjs");
|
|
|
5
5
|
const require_components_field = require("./field.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_chunk.__toESM(react);
|
|
8
|
-
let class_variance_authority = require("class-variance-authority");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let class_variance_authority = require("class-variance-authority");
|
|
10
10
|
let cn = require("cn");
|
|
11
11
|
//#region src/components/textarea.tsx
|
|
12
12
|
const textareaVariants = (0, class_variance_authority.cva)("flex w-full min-w-0 bg-transparent text-gray transition-[color,background-color,border-color] group-data-[invalid=true]/field:text-error placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:placeholder:text-gray-disabled aria-invalid:text-error motion-reduce:transition-none", {
|
|
@@ -3,8 +3,8 @@ import { cn } from "../utils/cn.js";
|
|
|
3
3
|
import { INSET_UNDERLINE, boxChrome } from "../lib/input-box-variants.js";
|
|
4
4
|
import { useFieldControl } from "./field.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
|
-
import { cva } from "class-variance-authority";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
8
|
//#region src/components/textarea.tsx
|
|
9
9
|
const textareaVariants = cva("flex w-full min-w-0 bg-transparent text-gray transition-[color,background-color,border-color] group-data-[invalid=true]/field:text-error placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:placeholder:text-gray-disabled aria-invalid:text-error motion-reduce:transition-none", {
|
|
10
10
|
variants: {
|
|
@@ -7,9 +7,9 @@ const require_lib_theme_types = require("../lib/theme-types.cjs");
|
|
|
7
7
|
const require_lib_accent_theme = require("../lib/accent-theme.cjs");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_chunk.__toESM(react);
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
11
|
let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
|
|
11
12
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
12
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
13
|
let cn = require("cn");
|
|
14
14
|
//#region src/components/theme.tsx
|
|
15
15
|
/** The epilot brand accent — the scale `spark-default.css` ships statically. */
|
package/dist/components/theme.js
CHANGED
|
@@ -5,9 +5,9 @@ import { isSparkNeutralFamily } from "../lib/theme-types.js";
|
|
|
5
5
|
import { CURATED_ACCENTS, accentSparkVars, appearanceForBackground, generateAccentScale, getMatchingNeutral, invertAccentScale, isParsableColor, neutralFamilyVars, neutralSparkVars, resolveAutoNeutral } from "../lib/accent-theme.js";
|
|
6
6
|
import { cn } from "../utils/cn.js";
|
|
7
7
|
import * as React$1 from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
9
10
|
import { useRender } from "@base-ui/react/use-render";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/theme.tsx
|
|
12
12
|
/** The epilot brand accent — the scale `spark-default.css` ships statically. */
|
|
13
13
|
const DEFAULT_ACCENT = "#005EB4";
|
|
@@ -7,8 +7,8 @@ const require_components_button = require("./button.cjs");
|
|
|
7
7
|
const require_components_spinner = require("./spinner.cjs");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_chunk.__toESM(react);
|
|
10
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
11
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
12
12
|
let _base_ui_react_toast = require("@base-ui/react/toast");
|
|
13
13
|
let cn = require("cn");
|
|
14
14
|
//#region src/components/toast.tsx
|
package/dist/components/toast.js
CHANGED
|
@@ -5,8 +5,8 @@ import { PortalTheme } from "./theme.js";
|
|
|
5
5
|
import { buttonVariants } from "./button.js";
|
|
6
6
|
import { Spinner } from "./spinner.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import { Cancel, CheckCircle, Close, Info, Warning } from "@epilot/spark-icons";
|
|
9
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Cancel, CheckCircle, Close, Info, Warning } from "@epilot/spark-icons";
|
|
10
10
|
import { Toast } from "@base-ui/react/toast";
|
|
11
11
|
//#region src/components/toast.tsx
|
|
12
12
|
const TOAST_ICONS = {
|
|
@@ -4,8 +4,8 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
const require_components_theme = require("./theme.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
9
|
let _base_ui_react_tooltip = require("@base-ui/react/tooltip");
|
|
10
10
|
let cn = require("cn");
|
|
11
11
|
//#region src/components/tooltip.tsx
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { PortalTheme } from "./theme.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { Info } from "@epilot/spark-icons";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Info } from "@epilot/spark-icons";
|
|
7
7
|
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
8
8
|
//#region src/components/tooltip.tsx
|
|
9
9
|
const TooltipProvider = ({ delay = 0, ...props }) => {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let _base_ui_react_collapsible = require("@base-ui/react/collapsible");
|
|
9
9
|
let cn = require("cn");
|
|
10
10
|
//#region src/components/trace.tsx
|
package/dist/components/trace.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { ChevronRight } from "@epilot/spark-icons";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ChevronRight } from "@epilot/spark-icons";
|
|
6
6
|
import { Collapsible } from "@base-ui/react/collapsible";
|
|
7
7
|
//#region src/components/trace.tsx
|
|
8
8
|
function Trace({ className, ...props }) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_chunk.__toESM(react);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/lib/calendar-day-button.tsx
|
|
9
|
+
/** DayPicker's day button, minus the page scroll when it takes focus. */
|
|
10
|
+
function ScrollFreeDayButton({ day: _day, modifiers, ...props }) {
|
|
11
|
+
const ref = react.useRef(null);
|
|
12
|
+
react.useEffect(() => {
|
|
13
|
+
if (modifiers.focused) ref.current?.focus({ preventScroll: true });
|
|
14
|
+
}, [modifiers.focused]);
|
|
15
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
16
|
+
ref,
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.ScrollFreeDayButton = ScrollFreeDayButton;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=calendar-day-button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-day-button.cjs","names":["React"],"sources":["../../src/lib/calendar-day-button.tsx"],"sourcesContent":["'use client'\n\nimport type { DayButtonProps } from '@daypicker/react'\nimport * as React from 'react'\n\n/** DayPicker's day button, minus the page scroll when it takes focus. */\nexport function ScrollFreeDayButton({\n day: _day,\n modifiers,\n ...props\n}: DayButtonProps) {\n const ref = React.useRef<HTMLButtonElement>(null)\n React.useEffect(() => {\n if (modifiers.focused) ref.current?.focus({ preventScroll: true })\n }, [modifiers.focused])\n return <button ref={ref} {...props} />\n}\n"],"mappings":";;;;;;;;;AAMA,SAAgB,oBAAoB,EAClC,KAAK,MACL,WACA,GAAG,SACc;CACjB,MAAM,MAAMA,MAAM,OAA0B,IAAI;CAChD,MAAM,gBAAgB;EACpB,IAAI,UAAU,SAAS,IAAI,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;CACnE,GAAG,CAAC,UAAU,OAAO,CAAC;CACtB,OAAO,iBAAA,GAAA,kBAAA,KAAC,UAAD;EAAa;EAAK,GAAI;CAAQ,CAAA;AACvC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DayButtonProps } from "@daypicker/react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/calendar-day-button.d.ts
|
|
6
|
+
/** DayPicker's day button, minus the page scroll when it takes focus. */
|
|
7
|
+
declare function ScrollFreeDayButton({
|
|
8
|
+
day: _day,
|
|
9
|
+
modifiers,
|
|
10
|
+
...props
|
|
11
|
+
}: DayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ScrollFreeDayButton };
|
|
14
|
+
//# sourceMappingURL=calendar-day-button.d.cts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DayButtonProps } from "@daypicker/react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/calendar-day-button.d.ts
|
|
6
|
+
/** DayPicker's day button, minus the page scroll when it takes focus. */
|
|
7
|
+
declare function ScrollFreeDayButton({
|
|
8
|
+
day: _day,
|
|
9
|
+
modifiers,
|
|
10
|
+
...props
|
|
11
|
+
}: DayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ScrollFreeDayButton };
|
|
14
|
+
//# sourceMappingURL=calendar-day-button.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/lib/calendar-day-button.tsx
|
|
6
|
+
/** DayPicker's day button, minus the page scroll when it takes focus. */
|
|
7
|
+
function ScrollFreeDayButton({ day: _day, modifiers, ...props }) {
|
|
8
|
+
const ref = React$1.useRef(null);
|
|
9
|
+
React$1.useEffect(() => {
|
|
10
|
+
if (modifiers.focused) ref.current?.focus({ preventScroll: true });
|
|
11
|
+
}, [modifiers.focused]);
|
|
12
|
+
return /* @__PURE__ */ jsx("button", {
|
|
13
|
+
ref,
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ScrollFreeDayButton };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=calendar-day-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-day-button.js","names":["React"],"sources":["../../src/lib/calendar-day-button.tsx"],"sourcesContent":["'use client'\n\nimport type { DayButtonProps } from '@daypicker/react'\nimport * as React from 'react'\n\n/** DayPicker's day button, minus the page scroll when it takes focus. */\nexport function ScrollFreeDayButton({\n day: _day,\n modifiers,\n ...props\n}: DayButtonProps) {\n const ref = React.useRef<HTMLButtonElement>(null)\n React.useEffect(() => {\n if (modifiers.focused) ref.current?.focus({ preventScroll: true })\n }, [modifiers.focused])\n return <button ref={ref} {...props} />\n}\n"],"mappings":";;;;;;AAMA,SAAgB,oBAAoB,EAClC,KAAK,MACL,WACA,GAAG,SACc;CACjB,MAAM,MAAMA,QAAM,OAA0B,IAAI;CAChD,QAAM,gBAAgB;EACpB,IAAI,UAAU,SAAS,IAAI,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;CACnE,GAAG,CAAC,UAAU,OAAO,CAAC;CACtB,OAAO,oBAAC,UAAD;EAAa;EAAK,GAAI;CAAQ,CAAA;AACvC"}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
5
|
const require_components_button = require("../components/button.cjs");
|
|
6
|
+
const require_lib_scroll_within = require("./scroll-within.cjs");
|
|
6
7
|
let react = require("react");
|
|
7
8
|
react = require_chunk.__toESM(react);
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
10
|
let _daypicker_react = require("@daypicker/react");
|
|
9
11
|
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
10
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let cn = require("cn");
|
|
12
13
|
//#region src/lib/calendar-lists.tsx
|
|
13
14
|
const ListContext = react.createContext({
|
|
@@ -117,8 +118,8 @@ function OptionList({ label, onClose, onPick, options }) {
|
|
|
117
118
|
const listRef = react.useRef(null);
|
|
118
119
|
react.useEffect(() => {
|
|
119
120
|
const current = listRef.current?.querySelector("[aria-selected=\"true\"]");
|
|
120
|
-
current?.
|
|
121
|
-
current
|
|
121
|
+
current?.focus({ preventScroll: true });
|
|
122
|
+
require_lib_scroll_within.scrollWithin(listRef.current, current ?? null, "center");
|
|
122
123
|
}, []);
|
|
123
124
|
const onKeyDown = (event) => {
|
|
124
125
|
if (event.key === "Escape") {
|
|
@@ -137,7 +138,7 @@ function OptionList({ label, onClose, onPick, options }) {
|
|
|
137
138
|
}[event.key];
|
|
138
139
|
if (target === void 0) return;
|
|
139
140
|
event.preventDefault();
|
|
140
|
-
items[Math.max(0, Math.min(items.length - 1, target))]
|
|
141
|
+
require_lib_scroll_within.focusWithin(listRef.current, items[Math.max(0, Math.min(items.length - 1, target))] ?? null);
|
|
141
142
|
};
|
|
142
143
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
143
144
|
"aria-label": label,
|
|
@@ -171,7 +172,7 @@ function MonthGrid(props) {
|
|
|
171
172
|
const close = (list) => {
|
|
172
173
|
const opener = list?.parentElement?.querySelector(`[data-slot=calendar-list-button][data-type=${view}]`);
|
|
173
174
|
setView("days");
|
|
174
|
-
requestAnimationFrame(() => opener?.focus());
|
|
175
|
+
requestAnimationFrame(() => opener?.focus({ preventScroll: true }));
|
|
175
176
|
};
|
|
176
177
|
const pick = (target, list) => {
|
|
177
178
|
goToMonth(clamp(target, start, end));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-lists.cjs","names":["React","buttonVariants","ChevronLeft","ArrowDropDown","ChevronRight","Check","DayGrid"],"sources":["../../src/lib/calendar-lists.tsx"],"sourcesContent":["'use client'\n\nimport {\n MonthGrid as DayGrid,\n type MonthCaptionProps,\n type MonthGridProps,\n useDayPicker,\n} from '@daypicker/react'\nimport {\n ArrowDropDown,\n Check,\n ChevronLeft,\n ChevronRight,\n} from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { buttonVariants } from '../components/button'\nimport { cn } from '../utils/cn'\n\ntype View = 'days' | 'month' | 'year'\n\nexport type CalendarListLabels = {\n nextYear: string\n previousYear: string\n}\n\nconst ListContext = React.createContext<{\n labels: CalendarListLabels\n setView: (view: View) => void\n view: View\n}>({\n labels: { nextYear: 'Next year', previousYear: 'Previous year' },\n setView: () => undefined,\n view: 'days',\n})\n\nconst monthOf = (year: number, month: number) => new Date(year, month, 1)\n\nfunction useBounds() {\n const { dayPickerProps } = useDayPicker()\n const year = new Date().getFullYear()\n const start = dayPickerProps.startMonth ?? monthOf(year - 100, 0)\n const end = dayPickerProps.endMonth ?? monthOf(year + 100, 11)\n return {\n end: monthOf(end.getFullYear(), end.getMonth()),\n start: monthOf(start.getFullYear(), start.getMonth()),\n }\n}\n\nconst clamp = (date: Date, start: Date, end: Date) =>\n date < start ? start : date > end ? end : date\n\nfunction useMonthName() {\n const { dayPickerProps } = useDayPicker()\n return React.useMemo(\n () =>\n new Intl.DateTimeFormat(dayPickerProps.locale?.code, { month: 'long' }),\n [dayPickerProps.locale?.code],\n )\n}\n\nconst arrowClassName = cn(\n buttonVariants({ size: 'icon-small', variant: 'tertiary' }),\n 'text-gray-light hover:text-gray focus-visible:focus-outline disabled:opacity-30 data-hidden:invisible [[data-high-contrast]_&]:text-gray-a12',\n)\n\nfunction Stepper({\n label,\n listLabel,\n nextLabel,\n onNext,\n onPrevious,\n previousLabel,\n type,\n}: {\n label: string\n listLabel: string\n nextLabel: string\n onNext?: () => void\n onPrevious?: () => void\n previousLabel: string\n type: 'month' | 'year'\n}) {\n const { setView, view } = React.useContext(ListContext)\n const listOpen = view !== 'days'\n const open = view === type\n return (\n <div className=\"flex items-center gap-1\">\n <button\n aria-label={previousLabel}\n className={arrowClassName}\n data-hidden={listOpen || undefined}\n disabled={!onPrevious}\n onClick={onPrevious}\n tabIndex={listOpen ? -1 : undefined}\n type=\"button\"\n >\n <ChevronLeft className=\"[--spark-icon-size:20px]\" />\n </button>\n <button\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label={`${label}, ${listLabel}`}\n className={cn(\n 'inline-flex h-8 cursor-pointer items-center rounded-md pl-2 text-sm font-bold text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n listOpen && !open && 'opacity-50',\n )}\n data-slot=\"calendar-list-button\"\n data-type={type}\n onClick={() => setView(open ? 'days' : type)}\n type=\"button\"\n >\n {label}\n <ArrowDropDown\n className={cn(\n '[--spark-icon-size:20px]',\n listOpen && !open && 'invisible',\n )}\n />\n </button>\n <button\n aria-label={nextLabel}\n className={arrowClassName}\n data-hidden={listOpen || undefined}\n disabled={!onNext}\n onClick={onNext}\n tabIndex={listOpen ? -1 : undefined}\n type=\"button\"\n >\n <ChevronRight className=\"[--spark-icon-size:20px]\" />\n </button>\n </div>\n )\n}\n\nfunction MonthCaption({\n calendarMonth,\n className,\n displayIndex: _,\n ...props\n}: MonthCaptionProps) {\n const { goToMonth, labels: dayPickerLabels } = useDayPicker()\n const { labels } = React.useContext(ListContext)\n const { end, start } = useBounds()\n const monthName = useMonthName()\n const date = calendarMonth.date\n const year = date.getFullYear()\n const month = date.getMonth()\n const go = (target: Date) => goToMonth(clamp(target, start, end))\n const previousMonth = monthOf(year, month - 1)\n const nextMonth = monthOf(year, month + 1)\n return (\n <div\n {...props}\n className={cn('flex h-10 items-center justify-between gap-4', className)}\n data-slot=\"calendar-header\"\n >\n <Stepper\n label={monthName.format(date)}\n listLabel={dayPickerLabels.labelMonthDropdown()}\n nextLabel={dayPickerLabels.labelNext(nextMonth)}\n onNext={nextMonth <= end ? () => go(nextMonth) : undefined}\n onPrevious={\n previousMonth >= start ? () => go(previousMonth) : undefined\n }\n previousLabel={dayPickerLabels.labelPrevious(previousMonth)}\n type=\"month\"\n />\n <Stepper\n label={String(year)}\n listLabel={dayPickerLabels.labelYearDropdown()}\n nextLabel={labels.nextYear}\n onNext={\n year < end.getFullYear()\n ? () => go(monthOf(year + 1, month))\n : undefined\n }\n onPrevious={\n year > start.getFullYear()\n ? () => go(monthOf(year - 1, month))\n : undefined\n }\n previousLabel={labels.previousYear}\n type=\"year\"\n />\n </div>\n )\n}\n\ntype Option = {\n disabled?: boolean\n label: string\n selected: boolean\n value: number\n}\n\nfunction OptionList({\n label,\n onClose,\n onPick,\n options,\n}: {\n label: string\n onClose: (list: HTMLElement | null) => void\n onPick: (value: number, list: HTMLElement | null) => void\n options: Option[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the current month or year is in view and focused when the list opens\n React.useEffect(() => {\n const current = listRef.current?.querySelector<HTMLButtonElement>(\n '[aria-selected=\"true\"]',\n )\n current?.scrollIntoView?.({ block: 'center' })\n current?.focus()\n }, [])\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n // closes the list, not the popup it sits in\n event.preventDefault()\n event.stopPropagation()\n onClose(listRef.current)\n return\n }\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\n '[role=\"option\"]:not(:disabled)',\n ) ?? [],\n )\n const index = items.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: items.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n items[Math.max(0, Math.min(items.length - 1, target))]?.focus()\n }\n\n return (\n <div\n aria-label={label}\n className=\"mt-1 flex max-h-72 w-full flex-col gap-0.5 overflow-y-auto [scrollbar-width:none]\"\n data-slot=\"calendar-list\"\n onKeyDown={onKeyDown}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {options.map((option) => (\n <button\n aria-selected={option.selected}\n className={cn(\n 'flex shrink-0 cursor-pointer items-center gap-3 rounded-md py-2 pr-2 pl-3 text-left text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline disabled:cursor-not-allowed disabled:opacity-50',\n option.selected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n disabled={option.disabled}\n key={option.value}\n onClick={() => onPick(option.value, listRef.current)}\n role=\"option\"\n tabIndex={option.selected ? 0 : -1}\n type=\"button\"\n >\n <Check\n className={cn(\n '[--spark-icon-size:20px]',\n !option.selected && 'invisible',\n )}\n />\n {option.label}\n </button>\n ))}\n </div>\n )\n}\n\nfunction MonthGrid(props: MonthGridProps) {\n const { goToMonth, labels: dayPickerLabels, months } = useDayPicker()\n const { setView, view } = React.useContext(ListContext)\n const { end, start } = useBounds()\n const monthName = useMonthName()\n\n if (view === 'days') return <DayGrid {...props} />\n\n const shown = months[0]?.date ?? new Date()\n const year = shown.getFullYear()\n const month = shown.getMonth()\n // focus goes back to the month or year button the list opened from; it sits in the caption,\n // a separate DayPicker part, so it is found from the list's month container\n const close = (list: HTMLElement | null) => {\n const opener = list?.parentElement?.querySelector<HTMLButtonElement>(\n `[data-slot=calendar-list-button][data-type=${view}]`,\n )\n setView('days')\n requestAnimationFrame(() => opener?.focus())\n }\n const pick = (target: Date, list: HTMLElement | null) => {\n goToMonth(clamp(target, start, end))\n close(list)\n }\n\n if (view === 'month') {\n return (\n <OptionList\n label={dayPickerLabels.labelMonthDropdown()}\n onClose={close}\n onPick={(value, list) => pick(monthOf(year, value), list)}\n options={Array.from({ length: 12 }, (_, value) => ({\n disabled: monthOf(year, value) < start || monthOf(year, value) > end,\n label: monthName.format(monthOf(year, value)),\n selected: value === month,\n value,\n }))}\n />\n )\n }\n\n return (\n <OptionList\n label={dayPickerLabels.labelYearDropdown()}\n onClose={close}\n onPick={(value, list) => pick(monthOf(value, month), list)}\n options={Array.from(\n { length: end.getFullYear() - start.getFullYear() + 1 },\n (_, index) => {\n const value = start.getFullYear() + index\n return { label: String(value), selected: value === year, value }\n },\n )}\n />\n )\n}\n\nfunction CalendarListsProvider({\n children,\n labels,\n}: {\n children: React.ReactNode\n labels: CalendarListLabels\n}) {\n const [view, setView] = React.useState<View>('days')\n const value = React.useMemo(() => ({ labels, setView, view }), [labels, view])\n return <ListContext.Provider value={value}>{children}</ListContext.Provider>\n}\n\nexport {\n CalendarListsProvider,\n MonthCaption as ListMonthCaption,\n MonthGrid as ListMonthGrid,\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,cAAcA,MAAM,cAIvB;CACD,QAAQ;EAAE,UAAU;EAAa,cAAc;CAAgB;CAC/D,eAAe,KAAA;CACf,MAAM;AACR,CAAC;AAED,MAAM,WAAW,MAAc,UAAkB,IAAI,KAAK,MAAM,OAAO,CAAC;AAExE,SAAS,YAAY;CACnB,MAAM,EAAE,oBAAA,GAAA,iBAAA,cAAgC;CACxC,MAAM,wBAAO,IAAI,KAAK,GAAE,YAAY;CACpC,MAAM,QAAQ,eAAe,cAAc,QAAQ,OAAO,KAAK,CAAC;CAChE,MAAM,MAAM,eAAe,YAAY,QAAQ,OAAO,KAAK,EAAE;CAC7D,OAAO;EACL,KAAK,QAAQ,IAAI,YAAY,GAAG,IAAI,SAAS,CAAC;EAC9C,OAAO,QAAQ,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC;CACtD;AACF;AAEA,MAAM,SAAS,MAAY,OAAa,QACtC,OAAO,QAAQ,QAAQ,OAAO,MAAM,MAAM;AAE5C,SAAS,eAAe;CACtB,MAAM,EAAE,oBAAA,GAAA,iBAAA,cAAgC;CACxC,OAAOA,MAAM,cAET,IAAI,KAAK,eAAe,eAAe,QAAQ,MAAM,EAAE,OAAO,OAAO,CAAC,GACxE,CAAC,eAAe,QAAQ,IAAI,CAC9B;AACF;AAEA,MAAM,kBAAA,GAAA,GAAA,IACJC,0BAAAA,eAAe;CAAE,MAAM;CAAc,SAAS;AAAW,CAAC,GAC1D,8IACF;AAEA,SAAS,QAAQ,EACf,OACA,WACA,WACA,QACA,YACA,eACA,QASC;CACD,MAAM,EAAE,SAAS,SAASD,MAAM,WAAW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ACnD,MAAM,QAAQA,MAAM,eAAe;EAAE;EAAQ;EAAS;CAAK,IAAI,CAAC,QAAQ,IAAI,CAAC;CAC7E,OAAO,iBAAA,GAAA,kBAAA,KAAC,YAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC7E"}
|
|
1
|
+
{"version":3,"file":"calendar-lists.cjs","names":["React","buttonVariants","ChevronLeft","ArrowDropDown","ChevronRight","Check","DayGrid"],"sources":["../../src/lib/calendar-lists.tsx"],"sourcesContent":["'use client'\n\nimport {\n MonthGrid as DayGrid,\n type MonthCaptionProps,\n type MonthGridProps,\n useDayPicker,\n} from '@daypicker/react'\nimport {\n ArrowDropDown,\n Check,\n ChevronLeft,\n ChevronRight,\n} from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { buttonVariants } from '../components/button'\nimport { cn } from '../utils/cn'\nimport { focusWithin, scrollWithin } from './scroll-within'\n\ntype View = 'days' | 'month' | 'year'\n\nexport type CalendarListLabels = {\n nextYear: string\n previousYear: string\n}\n\nconst ListContext = React.createContext<{\n labels: CalendarListLabels\n setView: (view: View) => void\n view: View\n}>({\n labels: { nextYear: 'Next year', previousYear: 'Previous year' },\n setView: () => undefined,\n view: 'days',\n})\n\nconst monthOf = (year: number, month: number) => new Date(year, month, 1)\n\nfunction useBounds() {\n const { dayPickerProps } = useDayPicker()\n const year = new Date().getFullYear()\n const start = dayPickerProps.startMonth ?? monthOf(year - 100, 0)\n const end = dayPickerProps.endMonth ?? monthOf(year + 100, 11)\n return {\n end: monthOf(end.getFullYear(), end.getMonth()),\n start: monthOf(start.getFullYear(), start.getMonth()),\n }\n}\n\nconst clamp = (date: Date, start: Date, end: Date) =>\n date < start ? start : date > end ? end : date\n\nfunction useMonthName() {\n const { dayPickerProps } = useDayPicker()\n return React.useMemo(\n () =>\n new Intl.DateTimeFormat(dayPickerProps.locale?.code, { month: 'long' }),\n [dayPickerProps.locale?.code],\n )\n}\n\nconst arrowClassName = cn(\n buttonVariants({ size: 'icon-small', variant: 'tertiary' }),\n 'text-gray-light hover:text-gray focus-visible:focus-outline disabled:opacity-30 data-hidden:invisible [[data-high-contrast]_&]:text-gray-a12',\n)\n\nfunction Stepper({\n label,\n listLabel,\n nextLabel,\n onNext,\n onPrevious,\n previousLabel,\n type,\n}: {\n label: string\n listLabel: string\n nextLabel: string\n onNext?: () => void\n onPrevious?: () => void\n previousLabel: string\n type: 'month' | 'year'\n}) {\n const { setView, view } = React.useContext(ListContext)\n const listOpen = view !== 'days'\n const open = view === type\n return (\n <div className=\"flex items-center gap-1\">\n <button\n aria-label={previousLabel}\n className={arrowClassName}\n data-hidden={listOpen || undefined}\n disabled={!onPrevious}\n onClick={onPrevious}\n tabIndex={listOpen ? -1 : undefined}\n type=\"button\"\n >\n <ChevronLeft className=\"[--spark-icon-size:20px]\" />\n </button>\n <button\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label={`${label}, ${listLabel}`}\n className={cn(\n 'inline-flex h-8 cursor-pointer items-center rounded-md pl-2 text-sm font-bold text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n listOpen && !open && 'opacity-50',\n )}\n data-slot=\"calendar-list-button\"\n data-type={type}\n onClick={() => setView(open ? 'days' : type)}\n type=\"button\"\n >\n {label}\n <ArrowDropDown\n className={cn(\n '[--spark-icon-size:20px]',\n listOpen && !open && 'invisible',\n )}\n />\n </button>\n <button\n aria-label={nextLabel}\n className={arrowClassName}\n data-hidden={listOpen || undefined}\n disabled={!onNext}\n onClick={onNext}\n tabIndex={listOpen ? -1 : undefined}\n type=\"button\"\n >\n <ChevronRight className=\"[--spark-icon-size:20px]\" />\n </button>\n </div>\n )\n}\n\nfunction MonthCaption({\n calendarMonth,\n className,\n displayIndex: _,\n ...props\n}: MonthCaptionProps) {\n const { goToMonth, labels: dayPickerLabels } = useDayPicker()\n const { labels } = React.useContext(ListContext)\n const { end, start } = useBounds()\n const monthName = useMonthName()\n const date = calendarMonth.date\n const year = date.getFullYear()\n const month = date.getMonth()\n const go = (target: Date) => goToMonth(clamp(target, start, end))\n const previousMonth = monthOf(year, month - 1)\n const nextMonth = monthOf(year, month + 1)\n return (\n <div\n {...props}\n className={cn('flex h-10 items-center justify-between gap-4', className)}\n data-slot=\"calendar-header\"\n >\n <Stepper\n label={monthName.format(date)}\n listLabel={dayPickerLabels.labelMonthDropdown()}\n nextLabel={dayPickerLabels.labelNext(nextMonth)}\n onNext={nextMonth <= end ? () => go(nextMonth) : undefined}\n onPrevious={\n previousMonth >= start ? () => go(previousMonth) : undefined\n }\n previousLabel={dayPickerLabels.labelPrevious(previousMonth)}\n type=\"month\"\n />\n <Stepper\n label={String(year)}\n listLabel={dayPickerLabels.labelYearDropdown()}\n nextLabel={labels.nextYear}\n onNext={\n year < end.getFullYear()\n ? () => go(monthOf(year + 1, month))\n : undefined\n }\n onPrevious={\n year > start.getFullYear()\n ? () => go(monthOf(year - 1, month))\n : undefined\n }\n previousLabel={labels.previousYear}\n type=\"year\"\n />\n </div>\n )\n}\n\ntype Option = {\n disabled?: boolean\n label: string\n selected: boolean\n value: number\n}\n\nfunction OptionList({\n label,\n onClose,\n onPick,\n options,\n}: {\n label: string\n onClose: (list: HTMLElement | null) => void\n onPick: (value: number, list: HTMLElement | null) => void\n options: Option[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the current month or year is in view and focused when the list opens\n React.useEffect(() => {\n const current = listRef.current?.querySelector<HTMLButtonElement>(\n '[aria-selected=\"true\"]',\n )\n current?.focus({ preventScroll: true })\n scrollWithin(listRef.current, current ?? null, 'center')\n }, [])\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n // closes the list, not the popup it sits in\n event.preventDefault()\n event.stopPropagation()\n onClose(listRef.current)\n return\n }\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\n '[role=\"option\"]:not(:disabled)',\n ) ?? [],\n )\n const index = items.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: items.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n focusWithin(\n listRef.current,\n items[Math.max(0, Math.min(items.length - 1, target))] ?? null,\n )\n }\n\n return (\n <div\n aria-label={label}\n className=\"mt-1 flex max-h-72 w-full flex-col gap-0.5 overflow-y-auto [scrollbar-width:none]\"\n data-slot=\"calendar-list\"\n onKeyDown={onKeyDown}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {options.map((option) => (\n <button\n aria-selected={option.selected}\n className={cn(\n 'flex shrink-0 cursor-pointer items-center gap-3 rounded-md py-2 pr-2 pl-3 text-left text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline disabled:cursor-not-allowed disabled:opacity-50',\n option.selected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n disabled={option.disabled}\n key={option.value}\n onClick={() => onPick(option.value, listRef.current)}\n role=\"option\"\n tabIndex={option.selected ? 0 : -1}\n type=\"button\"\n >\n <Check\n className={cn(\n '[--spark-icon-size:20px]',\n !option.selected && 'invisible',\n )}\n />\n {option.label}\n </button>\n ))}\n </div>\n )\n}\n\nfunction MonthGrid(props: MonthGridProps) {\n const { goToMonth, labels: dayPickerLabels, months } = useDayPicker()\n const { setView, view } = React.useContext(ListContext)\n const { end, start } = useBounds()\n const monthName = useMonthName()\n\n if (view === 'days') return <DayGrid {...props} />\n\n const shown = months[0]?.date ?? new Date()\n const year = shown.getFullYear()\n const month = shown.getMonth()\n // focus goes back to the month or year button the list opened from; it sits in the caption,\n // a separate DayPicker part, so it is found from the list's month container\n const close = (list: HTMLElement | null) => {\n const opener = list?.parentElement?.querySelector<HTMLButtonElement>(\n `[data-slot=calendar-list-button][data-type=${view}]`,\n )\n setView('days')\n requestAnimationFrame(() => opener?.focus({ preventScroll: true }))\n }\n const pick = (target: Date, list: HTMLElement | null) => {\n goToMonth(clamp(target, start, end))\n close(list)\n }\n\n if (view === 'month') {\n return (\n <OptionList\n label={dayPickerLabels.labelMonthDropdown()}\n onClose={close}\n onPick={(value, list) => pick(monthOf(year, value), list)}\n options={Array.from({ length: 12 }, (_, value) => ({\n disabled: monthOf(year, value) < start || monthOf(year, value) > end,\n label: monthName.format(monthOf(year, value)),\n selected: value === month,\n value,\n }))}\n />\n )\n }\n\n return (\n <OptionList\n label={dayPickerLabels.labelYearDropdown()}\n onClose={close}\n onPick={(value, list) => pick(monthOf(value, month), list)}\n options={Array.from(\n { length: end.getFullYear() - start.getFullYear() + 1 },\n (_, index) => {\n const value = start.getFullYear() + index\n return { label: String(value), selected: value === year, value }\n },\n )}\n />\n )\n}\n\nfunction CalendarListsProvider({\n children,\n labels,\n}: {\n children: React.ReactNode\n labels: CalendarListLabels\n}) {\n const [view, setView] = React.useState<View>('days')\n const value = React.useMemo(() => ({ labels, setView, view }), [labels, view])\n return <ListContext.Provider value={value}>{children}</ListContext.Provider>\n}\n\nexport {\n CalendarListsProvider,\n MonthCaption as ListMonthCaption,\n MonthGrid as ListMonthGrid,\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,cAAcA,MAAM,cAIvB;CACD,QAAQ;EAAE,UAAU;EAAa,cAAc;CAAgB;CAC/D,eAAe,KAAA;CACf,MAAM;AACR,CAAC;AAED,MAAM,WAAW,MAAc,UAAkB,IAAI,KAAK,MAAM,OAAO,CAAC;AAExE,SAAS,YAAY;CACnB,MAAM,EAAE,oBAAA,GAAA,iBAAA,cAAgC;CACxC,MAAM,wBAAO,IAAI,KAAK,GAAE,YAAY;CACpC,MAAM,QAAQ,eAAe,cAAc,QAAQ,OAAO,KAAK,CAAC;CAChE,MAAM,MAAM,eAAe,YAAY,QAAQ,OAAO,KAAK,EAAE;CAC7D,OAAO;EACL,KAAK,QAAQ,IAAI,YAAY,GAAG,IAAI,SAAS,CAAC;EAC9C,OAAO,QAAQ,MAAM,YAAY,GAAG,MAAM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,KAAK,IAAI;GACjE,OAAO,UAAU,OAAO,QAAQ,MAAM,KAAK,CAAC;GAC5C,UAAU,UAAU;GACpB;EACF,EAAE;CACH,CAAA;CAIL,OACE,iBAAA,GAAA,kBAAA,KAAC,YAAD;EACE,OAAO,gBAAgB,kBAAkB;EACzC,SAAS;EACT,SAAS,OAAO,SAAS,KAAK,QAAQ,OAAO,KAAK,GAAG,IAAI;EACzD,SAAS,MAAM,KACb,EAAE,QAAQ,IAAI,YAAY,IAAI,MAAM,YAAY,IAAI,EAAE,IACrD,GAAG,UAAU;GACZ,MAAM,QAAQ,MAAM,YAAY,IAAI;GACpC,OAAO;IAAE,OAAO,OAAO,KAAK;IAAG,UAAU,UAAU;IAAM;GAAM;EACjE,CACF;CACD,CAAA;AAEL;AAEA,SAAS,sBAAsB,EAC7B,UACA,UAIC;CACD,MAAM,CAAC,MAAM,WAAWN,MAAM,SAAe,MAAM;CACnD,MAAM,QAAQA,MAAM,eAAe;EAAE;EAAQ;EAAS;CAAK,IAAI,CAAC,QAAQ,IAAI,CAAC;CAC7E,OAAO,iBAAA,GAAA,kBAAA,KAAC,YAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC7E"}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { cn } from "../utils/cn.js";
|
|
4
4
|
import { buttonVariants } from "../components/button.js";
|
|
5
|
+
import { focusWithin, scrollWithin } from "./scroll-within.js";
|
|
5
6
|
import * as React$1 from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
import { MonthGrid as MonthGrid$1, useDayPicker } from "@daypicker/react";
|
|
7
9
|
import { ArrowDropDown, Check, ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/lib/calendar-lists.tsx
|
|
10
11
|
const ListContext = React$1.createContext({
|
|
11
12
|
labels: {
|
|
@@ -114,8 +115,8 @@ function OptionList({ label, onClose, onPick, options }) {
|
|
|
114
115
|
const listRef = React$1.useRef(null);
|
|
115
116
|
React$1.useEffect(() => {
|
|
116
117
|
const current = listRef.current?.querySelector("[aria-selected=\"true\"]");
|
|
117
|
-
current?.
|
|
118
|
-
current
|
|
118
|
+
current?.focus({ preventScroll: true });
|
|
119
|
+
scrollWithin(listRef.current, current ?? null, "center");
|
|
119
120
|
}, []);
|
|
120
121
|
const onKeyDown = (event) => {
|
|
121
122
|
if (event.key === "Escape") {
|
|
@@ -134,7 +135,7 @@ function OptionList({ label, onClose, onPick, options }) {
|
|
|
134
135
|
}[event.key];
|
|
135
136
|
if (target === void 0) return;
|
|
136
137
|
event.preventDefault();
|
|
137
|
-
items[Math.max(0, Math.min(items.length - 1, target))]
|
|
138
|
+
focusWithin(listRef.current, items[Math.max(0, Math.min(items.length - 1, target))] ?? null);
|
|
138
139
|
};
|
|
139
140
|
return /* @__PURE__ */ jsx("div", {
|
|
140
141
|
"aria-label": label,
|
|
@@ -168,7 +169,7 @@ function MonthGrid(props) {
|
|
|
168
169
|
const close = (list) => {
|
|
169
170
|
const opener = list?.parentElement?.querySelector(`[data-slot=calendar-list-button][data-type=${view}]`);
|
|
170
171
|
setView("days");
|
|
171
|
-
requestAnimationFrame(() => opener?.focus());
|
|
172
|
+
requestAnimationFrame(() => opener?.focus({ preventScroll: true }));
|
|
172
173
|
};
|
|
173
174
|
const pick = (target, list) => {
|
|
174
175
|
goToMonth(clamp(target, start, end));
|