@northlight/ui 2.33.5 → 2.33.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.
@@ -3927,6 +3927,7 @@ type StepsProps = TabsProps$1;
3927
3927
  interface StepProps extends TabProps {
3928
3928
  label: string;
3929
3929
  description?: string;
3930
+ indicator?: ReactNode;
3930
3931
  }
3931
3932
 
3932
3933
  /**
@@ -3948,9 +3949,13 @@ declare const StepPanel: (props: StepPanelProps) => JSX.Element;
3948
3949
  * (?
3949
3950
  <Steps>
3950
3951
  <StepList>
3951
- <Step label="Step 1" description="Name and email" />
3952
- <Step label="Step 2" description="Pick a password" />
3953
- <Step label="Step 3" description="Review" />
3952
+ <Step label="Step 1" description="Name and email" indicator={1} />
3953
+ <Step label="Step 2" description="Pick a password" indicator={2} />
3954
+ <Step label="Step 3"
3955
+ description="Review"
3956
+ indicator={<Icon as={ BrightnessSolid }
3957
+ size="xs" /> }
3958
+ />
3954
3959
  </StepList>
3955
3960
  <StepPanels>
3956
3961
  <StepPanel>1</StepPanel>
@@ -3970,10 +3975,16 @@ declare const Steps: (props: StepsProps) => JSX.Element;
3970
3975
  * @see Steps
3971
3976
  * @see {@link https://northlight.dev/reference/step}
3972
3977
  * @example
3973
- * (? <Step label="Step 1" description="Personal information" /> ?)
3978
+ * (?
3979
+ <Steps>
3980
+ <StepList>
3981
+ <Step label="Step 1" description="Personal information" indicator={1} />
3982
+ </StepList>
3983
+ </Steps>
3984
+ * ?)
3974
3985
  *
3975
3986
  */
3976
- declare const Step: ({ label, description, ...rest }: StepProps) => JSX.Element;
3987
+ declare const Step: ({ label, description, indicator, ...rest }: StepProps) => JSX.Element;
3977
3988
 
3978
3989
  /**
3979
3990
  * Used to render a navigational list of steps
@@ -3982,11 +3993,13 @@ declare const Step: ({ label, description, ...rest }: StepProps) => JSX.Element;
3982
3993
  * @see {@link https://northlight.dev/reference/step-list}
3983
3994
  * @example
3984
3995
  * (?
3996
+ * <Steps>
3985
3997
  <StepList>
3986
3998
  <Step label="Step 1" description="Name and email" />
3987
3999
  <Step label="Step 2" description="Pick a password" />
3988
4000
  <Step label="Step 3" description="Review" />
3989
4001
  </StepList>
4002
+ </Steps>
3990
4003
  * ?)
3991
4004
  *
3992
4005
  */
@@ -3,7 +3,7 @@ export { AbsoluteCenter, AccordionIcon, AlertDescription, AlertDialog, AlertDial
3
3
  import React, { useState, useEffect, useRef, isValidElement, cloneElement, Children, createContext, useContext, forwardRef as forwardRef$1, useImperativeHandle, memo, useMemo, useCallback } from 'react';
4
4
  import { CreatableSelect, chakraComponents, AsyncSelect, Select as Select$3 } from 'chakra-react-select';
5
5
  export { AsyncCreatableSelect, AsyncSelect, Select as ChakraReactSelect, CreatableSelect, chakraComponents as selectChakraComponents } from 'chakra-react-select';
6
- import { isNil, last, map, prop, difference, replace, split, path, T, keys, omit, merge, isEmpty, identity, any, init, append, ifElse, gt, always, defaultTo, take, inc, dec, forEach, is, trim, values, equals, mergeAll, toLower, find, times, add, has, not, all, filter, test, indexOf, remove, insert, intersection, findIndex, concat, head, match, length, propEq } from 'ramda';
6
+ import { isNil, last, map, prop, difference, replace, split, path, T, keys, omit, merge, isEmpty, identity, any, init, append, ifElse, gt, always, defaultTo, take, inc, dec, forEach, is, trim, values, equals, mergeAll, toLower, find, times, has, not, all, filter, test, indexOf, remove, insert, intersection, findIndex, concat, head, match, length, propEq } from 'ramda';
7
7
  import { useFocusManager, FocusScope, useFocusRing } from '@react-aria/focus';
8
8
  import { useForm, FormProvider, useFormContext, Controller } from 'react-hook-form';
9
9
  export { useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
@@ -19,7 +19,7 @@ import { useRadioGroupState } from '@react-stately/radio';
19
19
  import { useCheckboxGroupState } from '@react-stately/checkbox';
20
20
  import { useDateSegment, useDateField, useDatePicker, useDateRangePicker } from '@react-aria/datepicker';
21
21
  import { useDateFieldState, useDatePickerState, useDateRangePickerState } from '@react-stately/datepicker';
22
- import { createCalendar, today, isSameMonth, getWeeksInMonth, getDayOfWeek, GregorianCalendar, parseDate, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfYear, endOfYear } from '@internationalized/date';
22
+ import { createCalendar, today, isSameMonth, getWeeksInMonth, GregorianCalendar, parseDate, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfYear, endOfYear } from '@internationalized/date';
23
23
  import { useButton } from '@react-aria/button';
24
24
  import { useDateFormatter, useLocale, I18nProvider } from '@react-aria/i18n';
25
25
  import { useCalendarState } from '@react-stately/calendar';
@@ -326,7 +326,7 @@ const useOutsideRectClick = (ref, callback) => {
326
326
  document.removeEventListener("touchstart", onPointerDown, true);
327
327
  document.removeEventListener("touchend", onTouchEnd, true);
328
328
  };
329
- }, []);
329
+ }, [callback]);
330
330
  };
331
331
 
332
332
  const useScreenSize = () => {
@@ -2591,13 +2591,8 @@ const ColorPicker$1 = {
2591
2591
  };
2592
2592
 
2593
2593
  const Step$1 = {
2594
- parts: ["step", "label", "description"],
2595
- baseStyle: ({ theme: {
2596
- colors: color,
2597
- fontWeights,
2598
- space: spacing,
2599
- borders: borderWidth
2600
- } }) => ({
2594
+ parts: ["step", "label", "description", "indicator"],
2595
+ baseStyle: ({ theme: { colors: color, fontWeights, space: spacing, borders: borderWidth } }) => ({
2601
2596
  step: {
2602
2597
  justifyContent: "start",
2603
2598
  alignItems: "start",
@@ -2622,6 +2617,9 @@ const Step$1 = {
2622
2617
  bgColor: color.background.step.selected,
2623
2618
  borderColor: color.border.step.selected,
2624
2619
  color: color.border.step.selected,
2620
+ '[data-part="indicator"]': {
2621
+ bg: color.border.step.selected
2622
+ },
2625
2623
  _hover: {
2626
2624
  borderColor: color.border.step.selected,
2627
2625
  color: color.border.step.selected
@@ -2630,7 +2628,6 @@ const Step$1 = {
2630
2628
  },
2631
2629
  label: {
2632
2630
  color: "inherit",
2633
- pt: spacing.paddingTop.step.label,
2634
2631
  textAlign: "start",
2635
2632
  fontWeight: fontWeights.bold
2636
2633
  },
@@ -2638,6 +2635,19 @@ const Step$1 = {
2638
2635
  textAlign: "start",
2639
2636
  fontWeight: fontWeights.semiBold,
2640
2637
  color: color.text.default
2638
+ },
2639
+ indicator: {
2640
+ minW: 6,
2641
+ minH: 6,
2642
+ borderRadius: "full",
2643
+ bg: color.text.subdued,
2644
+ color: "mono.white",
2645
+ fontWeight: fontWeights.bold,
2646
+ fontSize: "xs",
2647
+ display: "flex",
2648
+ alignItems: "center",
2649
+ justifyContent: "center",
2650
+ marginTop: "2xs"
2641
2651
  }
2642
2652
  })
2643
2653
  };
@@ -3170,21 +3180,25 @@ const EditableText$1 = {
3170
3180
 
3171
3181
  const Toolbox$1 = {
3172
3182
  parts: ["container", "header", "body", "footer"],
3173
- baseStyle: ({ theme: { sizes: sizing } }) => ({
3183
+ baseStyle: ({ theme: {
3184
+ colors: color,
3185
+ sizes: sizing,
3186
+ borders: borderWidth
3187
+ } }) => ({
3174
3188
  container: {
3175
3189
  position: "relative",
3176
3190
  bg: "text.inverted",
3177
3191
  h: "100vh",
3178
- borderLeftWidth: "1px",
3192
+ borderLeftWidth: borderWidth.xs,
3179
3193
  borderLeftStyle: "solid",
3180
- borderLeftColor: "gray.100"
3194
+ borderLeftColor: color.border.default
3181
3195
  },
3182
3196
  header: {
3183
3197
  alignItems: "center",
3184
3198
  height: "16",
3185
- borderBottomWidth: "1px",
3199
+ borderBottomWidth: borderWidth.xs,
3186
3200
  borderBottomStyle: "solid",
3187
- borderBottomColor: "gray.100",
3201
+ borderBottomColor: color.border.default,
3188
3202
  pl: "4",
3189
3203
  pr: "16"
3190
3204
  },
@@ -3195,9 +3209,9 @@ const Toolbox$1 = {
3195
3209
  p: "4",
3196
3210
  alignItems: "center",
3197
3211
  height: "16",
3198
- borderTopWidth: "1px",
3212
+ borderTopWidth: borderWidth.xs,
3199
3213
  borderTopStyle: "solid",
3200
- borderTopColor: "gray.100"
3214
+ borderTopColor: color.border.default
3201
3215
  },
3202
3216
  body: {
3203
3217
  p: sizing["4"],
@@ -6602,8 +6616,7 @@ const months = [
6602
6616
  "September",
6603
6617
  "October",
6604
6618
  "November",
6605
- "December",
6606
- "January"
6619
+ "December"
6607
6620
  ];
6608
6621
 
6609
6622
  const MonthSelect = ({ state }) => {
@@ -6704,30 +6717,50 @@ const YearSelectRangeCalendar = ({
6704
6717
  return /* @__PURE__ */ React.createElement(YearSelect, { onChange, years });
6705
6718
  };
6706
6719
 
6707
- const getWeekNumberAtStartOfMonth = (year, month, weekDay) => {
6708
- if (month === 1) {
6709
- return weekDay > 3 ? 52 : 1;
6720
+ const MILLISECONDS_PER_DAY = 864e5;
6721
+ const getThursdayDate = (date) => {
6722
+ const thursdayDate = new Date(date);
6723
+ thursdayDate.setDate(date.getDate() + (4 - (date.getDay() || 7)));
6724
+ return thursdayDate;
6725
+ };
6726
+ const hasWeek53 = (year) => {
6727
+ const firstDayOfYear = new Date(year, 0, 1);
6728
+ return firstDayOfYear.getDay() === 4 || firstDayOfYear.getDay() === 3 && new Date(year, 1, 29).getMonth() === 1;
6729
+ };
6730
+ const getWeekNumberAtStartOfMonth = (year, month) => {
6731
+ const firstDayOfMonth = new Date(year, month - 1, 1);
6732
+ const thursdayOfFirstWeek = getThursdayDate(firstDayOfMonth);
6733
+ const firstDayOfYear = new Date(year, 0, 1);
6734
+ const firstThursdayOfYear = getThursdayDate(firstDayOfYear);
6735
+ const daysDifference = thursdayOfFirstWeek.getTime() - firstThursdayOfYear.getTime();
6736
+ const weekNumber = Math.ceil((daysDifference / MILLISECONDS_PER_DAY + 1) / 7);
6737
+ const isYearTransition = firstThursdayOfYear.getFullYear() < year;
6738
+ const isJanuaryTransition = isYearTransition && thursdayOfFirstWeek.getFullYear() < year && month === 1;
6739
+ if (isJanuaryTransition) {
6740
+ return hasWeek53(year - 1) ? 53 : 52;
6741
+ }
6742
+ if (isYearTransition && month > 1) {
6743
+ return weekNumber - 1;
6744
+ }
6745
+ if (month === 1 && weekNumber > 51) {
6746
+ return !hasWeek53(year - 1) ? 1 : weekNumber;
6710
6747
  }
6711
- const isLeapYear = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
6712
- const daysInMonths = [
6713
- 0,
6714
- 31,
6715
- isLeapYear ? 29 : 28,
6716
- 31,
6717
- 30,
6718
- 31,
6719
- 30,
6720
- 31,
6721
- 31,
6722
- 30,
6723
- 31,
6724
- 30,
6725
- 31
6726
- ];
6727
- const totalDaysUntilMonth = daysInMonths.slice(1, month).reduce(add, 1);
6728
- const weekNumber = Math.ceil(totalDaysUntilMonth / 7);
6729
6748
  return weekNumber;
6730
6749
  };
6750
+ const getDisplayWeek = (baseWeek, weekIndex, year, month) => {
6751
+ const isJanuaryEdgeCase = month === 1 && baseWeek > 51;
6752
+ if (isJanuaryEdgeCase) {
6753
+ return weekIndex === 0 ? baseWeek : weekIndex;
6754
+ }
6755
+ if (weekIndex === 0) {
6756
+ return baseWeek;
6757
+ }
6758
+ const nextWeek = baseWeek + weekIndex;
6759
+ if (nextWeek > 52) {
6760
+ return hasWeek53(year) && nextWeek === 53 ? 53 : nextWeek - 52;
6761
+ }
6762
+ return nextWeek;
6763
+ };
6731
6764
 
6732
6765
  var __defProp$1v = Object.defineProperty;
6733
6766
  var __defProps$i = Object.defineProperties;
@@ -6855,17 +6888,18 @@ const StandaloneCalendarGrid = (_a) => {
6855
6888
  const { gridProps, headerProps } = useCalendarGrid(rest, state);
6856
6889
  const weekDays = getWeekdays(firstDayOfWeek);
6857
6890
  const weeksInMonth = getWeeksInMonth(startDate, locale);
6858
- const weekNumberStart = useMemo(
6859
- () => getWeekNumberAtStartOfMonth(
6860
- startDate.year,
6861
- startDate.month,
6862
- getDayOfWeek(startDate, locale)
6863
- ),
6864
- [startDate.year, startDate.month]
6865
- );
6891
+ const weekNumberStart = useMemo(() => {
6892
+ const weekNumber = getWeekNumberAtStartOfMonth(startDate.year, startDate.month);
6893
+ return weekNumber;
6894
+ }, [startDate.year, startDate.month]);
6866
6895
  return /* @__PURE__ */ React.createElement(Box, __spreadProps$h(__spreadValues$1u({}, calendarProps), { h: "265px", p: "0" }), /* @__PURE__ */ React.createElement(Stack, null, /* @__PURE__ */ React.createElement(Flex, { justify: "space-between", w: "full", p: "1", alignItems: "center" }, /* @__PURE__ */ React.createElement(MonthButton, __spreadValues$1u({}, prevButtonProps), /* @__PURE__ */ React.createElement(Icon, { as: ChevronLeftSolid, boxSize: 4 })), /* @__PURE__ */ React.createElement(HStack, { spacing: "0" }, /* @__PURE__ */ React.createElement(MonthSelect, { state }), /* @__PURE__ */ React.createElement(YearSelectRangeCalendar, { state })), /* @__PURE__ */ React.createElement(MonthButton, __spreadValues$1u({}, nextButtonProps), /* @__PURE__ */ React.createElement(Icon, { as: ChevronRightSolid, boxSize: 4 }))), /* @__PURE__ */ React.createElement(chakra.table, __spreadProps$h(__spreadValues$1u({}, gridProps), { sx: { borderSpacing: "0" } }), /* @__PURE__ */ React.createElement(chakra.thead, __spreadValues$1u({}, headerProps), /* @__PURE__ */ React.createElement(chakra.tr, null, /* @__PURE__ */ React.createElement(chakra.th, null), /* @__PURE__ */ React.createElement(DayLabels, { weekDays }))), /* @__PURE__ */ React.createElement(chakra.tbody, null, times((weekIndex) => {
6867
- const weekNumber = weekNumberStart + weekIndex;
6868
- return /* @__PURE__ */ React.createElement(chakra.tr, { key: weekIndex }, /* @__PURE__ */ React.createElement(chakra.td, null, /* @__PURE__ */ React.createElement(Small, { sx: { color: "text.subdued" }, pr: "2" }, "w.", weekNumber > 52 ? weekNumber - 52 : weekNumber)), state.getDatesInWeek(weekIndex, startDate).map(
6896
+ const weekNumber = getDisplayWeek(
6897
+ weekNumberStart,
6898
+ weekIndex,
6899
+ startDate.year,
6900
+ startDate.month
6901
+ );
6902
+ return /* @__PURE__ */ React.createElement(chakra.tr, { key: weekIndex }, /* @__PURE__ */ React.createElement(chakra.td, null, /* @__PURE__ */ React.createElement(Small, { sx: { color: "text.subdued" }, pr: "2" }, "w.", weekNumber)), state.getDatesInWeek(weekIndex, startDate).map(
6869
6903
  (date) => date ? /* @__PURE__ */ React.createElement(
6870
6904
  RangeCell,
6871
6905
  {
@@ -8642,7 +8676,7 @@ const Toolbox = (_a) => {
8642
8676
  direction: direction === "left" ? "row-reverse" : "row"
8643
8677
  }, rest),
8644
8678
  isResizable && /* @__PURE__ */ React.createElement(ResizeHandle, __spreadValues$1d({}, resizeProps)),
8645
- /* @__PURE__ */ React.createElement(FocusScope, { autoFocus }, /* @__PURE__ */ React.createElement(VStack, { width: "full", height: "full" }, newChildren))
8679
+ /* @__PURE__ */ React.createElement(FocusScope, { autoFocus }, /* @__PURE__ */ React.createElement(VStack, { w: "full", h: "full", alignItems: "normal" }, newChildren))
8646
8680
  )
8647
8681
  ))
8648
8682
  );
@@ -13518,7 +13552,15 @@ const Toast = (_a) => {
13518
13552
  color: `icon.toast.${variant}`,
13519
13553
  boxSize: 6
13520
13554
  }
13521
- ), /* @__PURE__ */ React.createElement(Stack, { spacing: 0, alignItems: "flex-start" }, title && /* @__PURE__ */ React.createElement(Label, { size: "md" }, title), description && /* @__PURE__ */ React.createElement(P, null, description)), /* @__PURE__ */ React.createElement(
13555
+ ), /* @__PURE__ */ React.createElement(Stack, { spacing: 0, alignItems: "flex-start" }, title && /* @__PURE__ */ React.createElement(Label, { size: "md" }, title), description && /* @__PURE__ */ React.createElement(
13556
+ P,
13557
+ {
13558
+ sx: {
13559
+ color: variant === "ai" ? "color.text.inverted" : "text.default"
13560
+ }
13561
+ },
13562
+ description
13563
+ )), /* @__PURE__ */ React.createElement(
13522
13564
  CloseButton$1,
13523
13565
  {
13524
13566
  size: "sm",
@@ -13749,27 +13791,27 @@ var __objRest$9 = (source, exclude) => {
13749
13791
  return target;
13750
13792
  };
13751
13793
  const Step = (_a) => {
13752
- var _b = _a, { label, description } = _b, rest = __objRest$9(_b, ["label", "description"]);
13794
+ var _b = _a, { label, description, indicator } = _b, rest = __objRest$9(_b, ["label", "description", "indicator"]);
13753
13795
  const {
13754
13796
  step,
13755
13797
  label: labelStyle,
13756
- description: descriptionStyle
13798
+ description: descriptionStyle,
13799
+ indicator: indicatorStyle
13757
13800
  } = useMultiStyleConfig("Step");
13758
13801
  return /* @__PURE__ */ React.createElement(
13759
13802
  Tab,
13760
13803
  __spreadValues$a({
13761
13804
  sx: step
13762
13805
  }, rest),
13763
- /* @__PURE__ */ React.createElement(
13764
- Flex,
13806
+ /* @__PURE__ */ React.createElement(Flex, { flexDirection: "row", alignItems: "flex-start", gap: "4", _groupFocusVisible: ring }, indicator && /* @__PURE__ */ React.createElement(
13807
+ Box,
13765
13808
  {
13766
- flexDirection: "column",
13767
- alignItems: "flex-start",
13768
- _groupFocusVisible: ring
13809
+ sx: indicatorStyle,
13810
+ "data-part": "indicator",
13811
+ justifyContent: "center"
13769
13812
  },
13770
- /* @__PURE__ */ React.createElement(Capitalized, { sx: labelStyle }, label),
13771
- /* @__PURE__ */ React.createElement(Lead, { sx: descriptionStyle }, description)
13772
- )
13813
+ indicator
13814
+ ), /* @__PURE__ */ React.createElement(Flex, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Capitalized, { sx: labelStyle }, label), description && /* @__PURE__ */ React.createElement(Lead, { sx: descriptionStyle }, description)))
13773
13815
  );
13774
13816
  };
13775
13817