@papernote/ui 1.7.2 → 1.7.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/index.js CHANGED
@@ -4240,7 +4240,7 @@ function Stepper({ steps, activeStep, completedSteps = [], orientation = 'horizo
4240
4240
  `, children: steps.map((step, index) => renderStep(step, index)) }));
4241
4241
  }
4242
4242
 
4243
- function Calendar({ value, onChange, events = [], onEventClick, rangeMode = false, rangeValue, onRangeChange, minDate, maxDate, disabledDates = [], showWeekNumbers = false, firstDayOfWeek = 0, className = '', }) {
4243
+ function Calendar({ value, onChange, onMonthChange, events = [], onEventClick, rangeMode = false, rangeValue, onRangeChange, minDate, maxDate, disabledDates = [], showWeekNumbers = false, firstDayOfWeek = 0, className = '', }) {
4244
4244
  const [currentMonth, setCurrentMonth] = React.useState(value || new Date());
4245
4245
  const [hoverDate, setHoverDate] = React.useState(null);
4246
4246
  // Generate calendar grid for current month
@@ -4364,21 +4364,31 @@ function Calendar({ value, onChange, events = [], onEventClick, rangeMode = fals
4364
4364
  };
4365
4365
  // Navigate months
4366
4366
  const previousMonth = () => {
4367
- setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1, 1));
4367
+ const newMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1, 1);
4368
+ setCurrentMonth(newMonth);
4369
+ onMonthChange?.(newMonth);
4368
4370
  };
4369
4371
  const nextMonth = () => {
4370
- setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 1));
4372
+ const newMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 1);
4373
+ setCurrentMonth(newMonth);
4374
+ onMonthChange?.(newMonth);
4371
4375
  };
4372
4376
  // Navigate years
4373
4377
  const previousYear = () => {
4374
- setCurrentMonth(new Date(currentMonth.getFullYear() - 1, currentMonth.getMonth(), 1));
4378
+ const newMonth = new Date(currentMonth.getFullYear() - 1, currentMonth.getMonth(), 1);
4379
+ setCurrentMonth(newMonth);
4380
+ onMonthChange?.(newMonth);
4375
4381
  };
4376
4382
  const nextYear = () => {
4377
- setCurrentMonth(new Date(currentMonth.getFullYear() + 1, currentMonth.getMonth(), 1));
4383
+ const newMonth = new Date(currentMonth.getFullYear() + 1, currentMonth.getMonth(), 1);
4384
+ setCurrentMonth(newMonth);
4385
+ onMonthChange?.(newMonth);
4378
4386
  };
4379
4387
  // Go to today
4380
4388
  const goToToday = () => {
4381
- setCurrentMonth(new Date());
4389
+ const today = new Date();
4390
+ setCurrentMonth(today);
4391
+ onMonthChange?.(today);
4382
4392
  };
4383
4393
  // Day names
4384
4394
  const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -4391,7 +4401,7 @@ function Calendar({ value, onChange, events = [], onEventClick, rangeMode = fals
4391
4401
  error: 'bg-error-500',
4392
4402
  accent: 'bg-accent-500',
4393
4403
  };
4394
- return (jsxRuntime.jsxs("div", { className: `bg-white rounded-lg border border-paper-200 shadow-sm ${className}`, children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 border-b border-paper-200", children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsxs("button", { onClick: previousYear, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Previous year", children: [jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 text-ink-600" }), jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 text-ink-600 -ml-3" })] }), jsxRuntime.jsx("button", { onClick: previousMonth, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Previous month", children: jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 text-ink-600" }) })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-ink-900", children: currentMonth.toLocaleDateString('en-US', { month: 'long', year: 'numeric' }) }), jsxRuntime.jsx("button", { onClick: goToToday, className: "px-3 py-1 text-sm font-medium text-accent-700 hover:bg-accent-50 rounded transition-colors", children: "Today" })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("button", { onClick: nextMonth, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Next month", children: jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-600" }) }), jsxRuntime.jsxs("button", { onClick: nextYear, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Next year", children: [jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-600" }), jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-600 -ml-3" })] })] })] }), jsxRuntime.jsx("div", { className: "p-4", children: jsxRuntime.jsxs("div", { className: "grid grid-cols-7 gap-1", children: [showWeekNumbers && jsxRuntime.jsx("div", { className: "h-8" }), adjustedDayNames.map((day) => (jsxRuntime.jsx("div", { className: "h-8 flex items-center justify-center text-xs font-semibold text-ink-600", children: day }, day))), Array.from({ length: 6 }).map((_, weekIndex) => (jsxRuntime.jsxs(React.Fragment, { children: [showWeekNumbers && (jsxRuntime.jsx("div", { className: "flex items-center justify-center text-xs text-ink-500 font-medium", children: getWeekNumber(calendarDays[weekIndex * 7]) })), calendarDays.slice(weekIndex * 7, weekIndex * 7 + 7).map((date, dayIndex) => {
4404
+ return (jsxRuntime.jsxs("div", { className: `bg-white rounded-lg border border-paper-200 shadow-sm ${className}`, children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 border-b border-paper-200", children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("button", { onClick: previousYear, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Previous year", children: jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "h-4 w-4 text-ink-600" }) }), jsxRuntime.jsx("button", { onClick: previousMonth, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Previous month", children: jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 text-ink-600" }) })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-ink-900", children: currentMonth.toLocaleDateString('en-US', { month: 'long', year: 'numeric' }) }), jsxRuntime.jsx("button", { onClick: goToToday, className: "px-3 py-1 text-sm font-medium text-accent-700 hover:bg-accent-50 rounded transition-colors", children: "Today" })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("button", { onClick: nextMonth, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Next month", children: jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-600" }) }), jsxRuntime.jsx("button", { onClick: nextYear, className: "p-1.5 hover:bg-paper-100 rounded transition-colors", "aria-label": "Next year", children: jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "h-4 w-4 text-ink-600" }) })] })] }), jsxRuntime.jsx("div", { className: "p-4", children: jsxRuntime.jsxs("div", { className: "grid grid-cols-7 gap-1", children: [showWeekNumbers && jsxRuntime.jsx("div", { className: "h-8" }), adjustedDayNames.map((day) => (jsxRuntime.jsx("div", { className: "h-8 flex items-center justify-center text-xs font-semibold text-ink-600", children: day }, day))), Array.from({ length: 6 }).map((_, weekIndex) => (jsxRuntime.jsxs(React.Fragment, { children: [showWeekNumbers && (jsxRuntime.jsx("div", { className: "flex items-center justify-center text-xs text-ink-500 font-medium", children: getWeekNumber(calendarDays[weekIndex * 7]) })), calendarDays.slice(weekIndex * 7, weekIndex * 7 + 7).map((date, dayIndex) => {
4395
4405
  const dateEvents = getEventsForDate(date);
4396
4406
  const selected = isSelected(date);
4397
4407
  const inRange = isInRange(date);
@@ -7283,6 +7293,9 @@ function Hide({ children, above, below, only, className = '' }) {
7283
7293
  * Hook to detect breadcrumb navigation and trigger callbacks.
7284
7294
  * Use this in host components to reset state when a breadcrumb is clicked.
7285
7295
  *
7296
+ * Note: This hook requires React Router context. If used outside a Router,
7297
+ * it will be a no-op (the callback will never be called).
7298
+ *
7286
7299
  * @param onReset - Callback fired when breadcrumb navigation is detected
7287
7300
  *
7288
7301
  * @example
@@ -7296,15 +7309,19 @@ function Hide({ children, above, below, only, className = '' }) {
7296
7309
  * }
7297
7310
  */
7298
7311
  function useBreadcrumbReset(onReset) {
7299
- const location = reactRouterDom.useLocation();
7312
+ const inRouter = reactRouterDom.useInRouterContext();
7300
7313
  const lastResetRef = React.useRef(null);
7314
+ // Only use useLocation when inside Router context
7315
+ const location = inRouter ? reactRouterDom.useLocation() : null;
7301
7316
  React.useEffect(() => {
7317
+ if (!location)
7318
+ return;
7302
7319
  const state = location.state;
7303
7320
  if (state?.breadcrumbReset && state.breadcrumbReset !== lastResetRef.current) {
7304
7321
  lastResetRef.current = state.breadcrumbReset;
7305
7322
  onReset();
7306
7323
  }
7307
- }, [location.state, onReset]);
7324
+ }, [location?.state, onReset, location]);
7308
7325
  }
7309
7326
  /**
7310
7327
  * Breadcrumbs navigation component.
@@ -7339,8 +7356,10 @@ function useBreadcrumbReset(onReset) {
7339
7356
  * }
7340
7357
  */
7341
7358
  function Breadcrumbs({ items, showHome = true }) {
7342
- const navigate = reactRouterDom.useNavigate();
7343
- const location = reactRouterDom.useLocation();
7359
+ const inRouter = reactRouterDom.useInRouterContext();
7360
+ // Only use router hooks when inside Router context
7361
+ const navigate = inRouter ? reactRouterDom.useNavigate() : null;
7362
+ const location = inRouter ? reactRouterDom.useLocation() : null;
7344
7363
  /**
7345
7364
  * Handle breadcrumb click with same-route detection.
7346
7365
  * When clicking a breadcrumb that points to the current route,
@@ -7349,6 +7368,9 @@ function Breadcrumbs({ items, showHome = true }) {
7349
7368
  const handleBreadcrumbClick = (e, href, onClick) => {
7350
7369
  // Always call onClick if provided (for custom actions)
7351
7370
  onClick?.();
7371
+ // If not in router context, let the browser handle navigation naturally
7372
+ if (!navigate || !location)
7373
+ return;
7352
7374
  // Check if we're navigating to the same base path
7353
7375
  const targetPath = href.split('?')[0].split('#')[0];
7354
7376
  const currentPath = location.pathname;
@@ -7365,7 +7387,16 @@ function Breadcrumbs({ items, showHome = true }) {
7365
7387
  }
7366
7388
  // Different route - let the Link handle it normally
7367
7389
  };
7368
- return (jsxRuntime.jsxs("nav", { "aria-label": "Breadcrumb", className: "flex items-center space-x-2 text-sm", children: [showHome && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactRouterDom.Link, { to: "/", className: "text-ink-500 hover:text-ink-900 transition-colors", "aria-label": "Home", onClick: (e) => handleBreadcrumbClick(e, '/'), children: jsxRuntime.jsx(lucideReact.Home, { className: "h-4 w-4" }) }), items.length > 0 && jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-400" })] })), items.map((item, index) => {
7390
+ // Helper to render a link - uses Link when in router, <a> when not
7391
+ const renderLink = (href, children, className, onClick, ariaLabel) => {
7392
+ if (inRouter) {
7393
+ return (jsxRuntime.jsx(reactRouterDom.Link, { to: href, className: className, onClick: onClick, "aria-label": ariaLabel, children: children }));
7394
+ }
7395
+ return (jsxRuntime.jsx("a", { href: href, className: className, onClick: (e) => {
7396
+ onClick?.(e);
7397
+ }, "aria-label": ariaLabel, children: children }));
7398
+ };
7399
+ return (jsxRuntime.jsxs("nav", { "aria-label": "Breadcrumb", className: "flex items-center space-x-2 text-sm", children: [showHome && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLink('/', jsxRuntime.jsx(lucideReact.Home, { className: "h-4 w-4" }), 'text-ink-500 hover:text-ink-900 transition-colors', (e) => handleBreadcrumbClick(e, '/'), 'Home'), items.length > 0 && jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-ink-400" })] })), items.map((item, index) => {
7369
7400
  const isLast = index === items.length - 1;
7370
7401
  const isActive = isLast;
7371
7402
  const content = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx("span", { className: "flex-shrink-0", children: item.icon }), jsxRuntime.jsx("span", { children: item.label })] }));
@@ -7374,9 +7405,9 @@ function Breadcrumbs({ items, showHome = true }) {
7374
7405
  if (isActive) {
7375
7406
  return (jsxRuntime.jsx("span", { className: "flex items-center gap-2 px-2 py-1 rounded-md bg-accent-50 text-accent-900 font-semibold transition-colors", "aria-current": "page", children: content }));
7376
7407
  }
7377
- // Has href - render as Link with same-route detection
7408
+ // Has href - render as Link (or <a> if no router) with same-route detection
7378
7409
  if (item.href) {
7379
- return (jsxRuntime.jsx(reactRouterDom.Link, { to: item.href, onClick: (e) => handleBreadcrumbClick(e, item.href, item.onClick), className: "flex items-center gap-2 text-ink-500 hover:text-ink-900 hover:underline transition-colors", children: content }));
7410
+ return renderLink(item.href, content, 'flex items-center gap-2 text-ink-500 hover:text-ink-900 hover:underline transition-colors', (e) => handleBreadcrumbClick(e, item.href, item.onClick));
7380
7411
  }
7381
7412
  // Only onClick (no href) - render as button
7382
7413
  if (item.onClick) {
@@ -10321,44 +10352,52 @@ function getAugmentedNamespace(n) {
10321
10352
  * (A1, A1:C5, ...)
10322
10353
  */
10323
10354
 
10324
- let Collection$3 = class Collection {
10355
+ var collection;
10356
+ var hasRequiredCollection;
10357
+
10358
+ function requireCollection () {
10359
+ if (hasRequiredCollection) return collection;
10360
+ hasRequiredCollection = 1;
10361
+ class Collection {
10325
10362
 
10326
- constructor(data, refs) {
10327
- if (data == null && refs == null) {
10328
- this._data = [];
10329
- this._refs = [];
10330
- } else {
10331
- if (data.length !== refs.length)
10332
- throw Error('Collection: data length should match references length.');
10333
- this._data = data;
10334
- this._refs = refs;
10335
- }
10336
- }
10363
+ constructor(data, refs) {
10364
+ if (data == null && refs == null) {
10365
+ this._data = [];
10366
+ this._refs = [];
10367
+ } else {
10368
+ if (data.length !== refs.length)
10369
+ throw Error('Collection: data length should match references length.');
10370
+ this._data = data;
10371
+ this._refs = refs;
10372
+ }
10373
+ }
10337
10374
 
10338
- get data() {
10339
- return this._data;
10340
- }
10375
+ get data() {
10376
+ return this._data;
10377
+ }
10341
10378
 
10342
- get refs() {
10343
- return this._refs;
10344
- }
10379
+ get refs() {
10380
+ return this._refs;
10381
+ }
10345
10382
 
10346
- get length() {
10347
- return this._data.length;
10348
- }
10383
+ get length() {
10384
+ return this._data.length;
10385
+ }
10349
10386
 
10350
- /**
10351
- * Add data and references to this collection.
10352
- * @param {{}} obj - data
10353
- * @param {{}} ref - reference
10354
- */
10355
- add(obj, ref) {
10356
- this._data.push(obj);
10357
- this._refs.push(ref);
10358
- }
10359
- };
10387
+ /**
10388
+ * Add data and references to this collection.
10389
+ * @param {{}} obj - data
10390
+ * @param {{}} ref - reference
10391
+ */
10392
+ add(obj, ref) {
10393
+ this._data.push(obj);
10394
+ this._refs.push(ref);
10395
+ }
10396
+ }
10360
10397
 
10361
- var collection = Collection$3;
10398
+ collection = Collection;
10399
+ return collection;
10400
+ }
10362
10401
 
10363
10402
  var helpers;
10364
10403
  var hasRequiredHelpers;
@@ -10367,7 +10406,7 @@ function requireHelpers () {
10367
10406
  if (hasRequiredHelpers) return helpers;
10368
10407
  hasRequiredHelpers = 1;
10369
10408
  const FormulaError = requireError();
10370
- const Collection = collection;
10409
+ const Collection = requireCollection();
10371
10410
 
10372
10411
  const Types = {
10373
10412
  NUMBER: 0,
@@ -20021,7 +20060,7 @@ var engineering = EngineeringFunctions;
20021
20060
 
20022
20061
  const FormulaError$b = requireError();
20023
20062
  const {FormulaHelpers: FormulaHelpers$8, Types: Types$6, WildCard, Address: Address$3} = requireHelpers();
20024
- const Collection$2 = collection;
20063
+ const Collection$2 = requireCollection();
20025
20064
  const H$5 = FormulaHelpers$8;
20026
20065
 
20027
20066
  const ReferenceFunctions$1 = {
@@ -31649,7 +31688,7 @@ var parsing = {
31649
31688
  const FormulaError$4 = requireError();
31650
31689
  const {Address: Address$1} = requireHelpers();
31651
31690
  const {Prefix: Prefix$1, Postfix: Postfix$1, Infix: Infix$1, Operators: Operators$1} = operators;
31652
- const Collection$1 = collection;
31691
+ const Collection$1 = requireCollection();
31653
31692
  const MAX_ROW$1 = 1048576, MAX_COLUMN$1 = 16384;
31654
31693
  const {NotAllInputParsedException} = require$$4;
31655
31694
 
@@ -32411,7 +32450,7 @@ var hooks$1 = {
32411
32450
  const FormulaError$2 = requireError();
32412
32451
  const {FormulaHelpers: FormulaHelpers$1, Types, Address} = requireHelpers();
32413
32452
  const {Prefix, Postfix, Infix, Operators} = operators;
32414
- const Collection = collection;
32453
+ const Collection = requireCollection();
32415
32454
  const MAX_ROW = 1048576, MAX_COLUMN = 16384;
32416
32455
 
32417
32456
  let Utils$1 = class Utils {