orynn 0.5.0 → 0.6.0

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.cjs CHANGED
@@ -623,7 +623,10 @@ function Popover({
623
623
  left: pos.left,
624
624
  top: pos.top,
625
625
  width: matchWidth ? pos.width : void 0,
626
- minWidth: pos.width,
626
+ // Only pin the min-width to the anchor when we're matching it. With
627
+ // `matchWidth={false}` the panel sizes to its own content, so a wide
628
+ // trigger doesn't stretch it across the screen.
629
+ minWidth: matchWidth ? pos.width : void 0,
627
630
  maxHeight: pos.maxHeight,
628
631
  transform: pos.placement === "top" ? "translateY(-100%)" : void 0
629
632
  },
@@ -798,7 +801,7 @@ function Calendar({
798
801
  onSelect,
799
802
  mode = "single",
800
803
  selectedDates,
801
- range,
804
+ range: range2,
802
805
  previewRange: previewRange2,
803
806
  onHoverDate,
804
807
  minDate,
@@ -817,11 +820,14 @@ function Calendar({
817
820
  precision = "day",
818
821
  fixedWeeks = true,
819
822
  defaultMonth,
820
- numberOfMonths = 1
823
+ numberOfMonths = 1,
824
+ className,
825
+ style,
826
+ fillWidth
821
827
  }) {
822
828
  const panels = Math.max(1, Math.floor(numberOfMonths));
823
829
  const today = startOfDay(/* @__PURE__ */ new Date());
824
- const anchor = value ?? (mode === "range" ? range?.start ?? range?.end ?? null : null) ?? (mode === "multiple" ? selectedDates?.[0] ?? null : null) ?? defaultMonth ?? null;
830
+ const anchor = value ?? (mode === "range" ? range2?.start ?? range2?.end ?? null : null) ?? (mode === "multiple" ? selectedDates?.[0] ?? null : null) ?? defaultMonth ?? null;
825
831
  const initial = anchor ?? clampDate(today, minDate, maxDate);
826
832
  const [nav, setNav] = react.useState({ y: initial.getFullYear(), m: initial.getMonth() });
827
833
  const [focused, setFocused] = react.useState(initial);
@@ -982,9 +988,9 @@ function Calendar({
982
988
  if (mode === "multiple") {
983
989
  selected = (selectedDates ?? []).some((x) => isSameDay(x, d));
984
990
  } else if (mode === "range") {
985
- rangeStart = isRangeStart(d, range) || !!previewRange2 && isRangeStart(d, previewRange2);
986
- rangeEnd = isRangeEnd(d, range) || !!previewRange2 && isRangeEnd(d, previewRange2);
987
- inRange = isWithinRange(d, range) || !!previewRange2 && isWithinRange(d, previewRange2);
991
+ rangeStart = isRangeStart(d, range2) || !!previewRange2 && isRangeStart(d, previewRange2);
992
+ rangeEnd = isRangeEnd(d, range2) || !!previewRange2 && isRangeEnd(d, previewRange2);
993
+ inRange = isWithinRange(d, range2) || !!previewRange2 && isWithinRange(d, previewRange2);
988
994
  selected = rangeStart || rangeEnd;
989
995
  } else {
990
996
  selected = isSameDay(d, value);
@@ -1144,10 +1150,12 @@ function Calendar({
1144
1150
  return /* @__PURE__ */ jsxRuntime.jsxs(
1145
1151
  "div",
1146
1152
  {
1147
- className: "orynn-calendar",
1153
+ className: cx("orynn-calendar", className),
1154
+ style,
1148
1155
  ref: gridRef,
1149
1156
  "data-view": view,
1150
1157
  "data-months": panels > 1 ? panels : void 0,
1158
+ "data-fill": fillWidth || void 0,
1151
1159
  children: [
1152
1160
  header,
1153
1161
  " ",
@@ -1221,7 +1229,7 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1221
1229
  value: valueProp,
1222
1230
  defaultValue,
1223
1231
  onChange,
1224
- format = "yyyy-MM-dd",
1232
+ format = "dd-MMM-yyyy",
1225
1233
  minDate,
1226
1234
  maxDate,
1227
1235
  disabledDates,
@@ -1235,6 +1243,7 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1235
1243
  precision = "day",
1236
1244
  fixedWeeks = true,
1237
1245
  numberOfMonths,
1246
+ calendarWidth,
1238
1247
  showTime = false,
1239
1248
  timeStep = 5,
1240
1249
  defaultMonth,
@@ -1252,7 +1261,7 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1252
1261
  const panelId = `${id}-cal`;
1253
1262
  const withTimePicker = showTime && mode === "single";
1254
1263
  const closeOnSelect = closeOnSelectProp ?? !withTimePicker;
1255
- const fmt = withTimePicker && format === "yyyy-MM-dd" ? "yyyy-MM-dd HH:mm" : format;
1264
+ const fmt = withTimePicker && format === "dd-MMM-yyyy" ? "dd-MMM-yyyy HH:mm" : format;
1256
1265
  const isControlled = valueProp !== void 0;
1257
1266
  const [innerRaw, setInnerRaw] = react.useState(() => defaultValue ?? null);
1258
1267
  const raw = isControlled ? valueProp : innerRaw;
@@ -1365,9 +1374,9 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1365
1374
  if (closeOnSelect && !inline) closeAndRefocus();
1366
1375
  };
1367
1376
  const setTimeField = (part, n) => {
1368
- const base2 = curDate ?? startOfDay(/* @__PURE__ */ new Date());
1369
- const t = timeParts(base2);
1370
- commit(withTime(base2, { ...t, [part]: n, s: 0 }));
1377
+ const base3 = curDate ?? startOfDay(/* @__PURE__ */ new Date());
1378
+ const t = timeParts(base3);
1379
+ commit(withTime(base3, { ...t, [part]: n, s: 0 }));
1371
1380
  };
1372
1381
  const timeColumn = withTimePicker ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orynn-datepicker__time", children: [
1373
1382
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-datepicker__time-label", children: "Time" }),
@@ -1395,11 +1404,18 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1395
1404
  )
1396
1405
  ] })
1397
1406
  ] }) : null;
1407
+ const calendarStyle = calendarWidth != null ? {
1408
+ "--orynn-calendar-min-width": typeof calendarWidth === "number" ? `${calendarWidth}px` : calendarWidth
1409
+ } : void 0;
1410
+ const hasExtras = (numberOfMonths ?? 1) > 1 || (presets?.length ?? 0) > 0 || withTimePicker;
1411
+ const fillWidth = inline || !hasExtras;
1398
1412
  const calendar = /* @__PURE__ */ jsxRuntime.jsx(
1399
1413
  Calendar,
1400
1414
  {
1401
1415
  value: curDate,
1402
1416
  onSelect: select,
1417
+ style: calendarStyle,
1418
+ fillWidth,
1403
1419
  mode,
1404
1420
  selectedDates: mode === "multiple" ? curDates : void 0,
1405
1421
  range: mode === "range" ? curRange : void 0,
@@ -1574,7 +1590,7 @@ var DatePicker = /* @__PURE__ */ react.forwardRef(
1574
1590
  setOpen(false);
1575
1591
  setGridFocus(false);
1576
1592
  },
1577
- matchWidth: false,
1593
+ matchWidth: fillWidth,
1578
1594
  id: panelId,
1579
1595
  role: "dialog",
1580
1596
  children: cal
@@ -2437,8 +2453,8 @@ var NumberField = /* @__PURE__ */ react.forwardRef(
2437
2453
  };
2438
2454
  const bump = (dir, mode = "n") => {
2439
2455
  const amount = mode === "l" ? shiftStep ?? step * 10 : mode === "s" ? smallStep ?? step / 10 : step;
2440
- const base2 = value ?? (dir > 0 ? effMin ?? 0 : max ?? 0);
2441
- let next = round(base2 + amount * dir, scale);
2456
+ const base3 = value ?? (dir > 0 ? effMin ?? 0 : max ?? 0);
2457
+ let next = round(base3 + amount * dir, scale);
2442
2458
  if (clampMode !== "none") next = clamp(next, effMin, max);
2443
2459
  else if (!allowNegative && next < 0) next = 0;
2444
2460
  setNumber(next);
@@ -3997,9 +4013,65 @@ function Form(props) {
3997
4013
  }
3998
4014
  );
3999
4015
  }
4016
+ var Accordion = /* @__PURE__ */ react.forwardRef(
4017
+ function Accordion2({ className, variant = "bordered", size = "md", ...props }, ref) {
4018
+ return /* @__PURE__ */ jsxRuntime.jsx(
4019
+ radixUi.Accordion.Root,
4020
+ {
4021
+ ref,
4022
+ "data-slot": "accordion",
4023
+ "data-variant": variant,
4024
+ "data-size": size,
4025
+ className: cx("orynn-accordion", className),
4026
+ ...props
4027
+ }
4028
+ );
4029
+ }
4030
+ );
4031
+ var AccordionItem = /* @__PURE__ */ react.forwardRef(function AccordionItem2({ className, ...props }, ref) {
4032
+ return /* @__PURE__ */ jsxRuntime.jsx(
4033
+ radixUi.Accordion.Item,
4034
+ {
4035
+ ref,
4036
+ "data-slot": "accordion-item",
4037
+ className: cx("orynn-accordion__item", className),
4038
+ ...props
4039
+ }
4040
+ );
4041
+ });
4042
+ var AccordionTrigger = /* @__PURE__ */ react.forwardRef(function AccordionTrigger2({ className, children, icon, iconPosition = "end", hideIcon = false, ...props }, ref) {
4043
+ const indicator = hideIcon ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-accordion__icon", "data-slot": "accordion-icon", "aria-hidden": "true", children: icon ?? /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, {}) });
4044
+ return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Header, { className: "orynn-accordion__header", "data-slot": "accordion-header", children: /* @__PURE__ */ jsxRuntime.jsxs(
4045
+ radixUi.Accordion.Trigger,
4046
+ {
4047
+ ref,
4048
+ "data-slot": "accordion-trigger",
4049
+ "data-icon-position": iconPosition,
4050
+ className: cx("orynn-accordion__trigger", className),
4051
+ ...props,
4052
+ children: [
4053
+ iconPosition === "start" && indicator,
4054
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-accordion__label", children }),
4055
+ iconPosition === "end" && indicator
4056
+ ]
4057
+ }
4058
+ ) });
4059
+ });
4060
+ var AccordionContent = /* @__PURE__ */ react.forwardRef(function AccordionContent2({ className, children, ...props }, ref) {
4061
+ return /* @__PURE__ */ jsxRuntime.jsx(
4062
+ radixUi.Accordion.Content,
4063
+ {
4064
+ ref,
4065
+ "data-slot": "accordion-content",
4066
+ className: cx("orynn-accordion__content", className),
4067
+ ...props,
4068
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "orynn-accordion__body", children })
4069
+ }
4070
+ );
4071
+ });
4000
4072
 
4001
4073
  // src/primitives/shared/classes.ts
4002
- var mod = (base2, key, fallback) => key === fallback ? void 0 : `${base2}--${key}`;
4074
+ var mod = (base3, key, fallback) => key === fallback ? void 0 : `${base3}--${key}`;
4003
4075
  function buttonClasses(variant = "default", size = "default") {
4004
4076
  return cx(
4005
4077
  "orynn-button",
@@ -4021,6 +4093,10 @@ var Button = /* @__PURE__ */ react.forwardRef(function Button2({
4021
4093
  leftIcon,
4022
4094
  rightIcon,
4023
4095
  fullWidth = false,
4096
+ hoverEffect,
4097
+ focusStyle,
4098
+ selected,
4099
+ cursor,
4024
4100
  disabled,
4025
4101
  children,
4026
4102
  ...props
@@ -4031,6 +4107,11 @@ var Button = /* @__PURE__ */ react.forwardRef(function Button2({
4031
4107
  "data-size": size,
4032
4108
  "data-loading": loading || void 0,
4033
4109
  "data-full-width": fullWidth || void 0,
4110
+ "data-hover-effect": hoverEffect,
4111
+ "data-focus-style": focusStyle,
4112
+ "data-selected": selected || void 0,
4113
+ "data-cursor": cursor,
4114
+ "aria-pressed": selected,
4034
4115
  className: cx(buttonClasses(variant, size), className),
4035
4116
  ...props
4036
4117
  };
@@ -4053,6 +4134,596 @@ var Button = /* @__PURE__ */ react.forwardRef(function Button2({
4053
4134
  }
4054
4135
  );
4055
4136
  });
4137
+ var toArray2 = (v) => v == null ? void 0 : Array.isArray(v) ? v : [v];
4138
+ var Slider = /* @__PURE__ */ react.forwardRef(function Slider2({
4139
+ className,
4140
+ value,
4141
+ defaultValue,
4142
+ min = 0,
4143
+ max = 100,
4144
+ step = 1,
4145
+ size = "md",
4146
+ marks,
4147
+ showTicks = false,
4148
+ tooltip = "none",
4149
+ formatValue,
4150
+ orientation = "horizontal",
4151
+ onValueChange,
4152
+ ...props
4153
+ }, ref) {
4154
+ const controlled = value !== void 0;
4155
+ const initial = toArray2(value) ?? toArray2(defaultValue) ?? [min];
4156
+ const [internal, setInternal] = react.useState(initial);
4157
+ const current = controlled ? toArray2(value) : internal;
4158
+ const handleChange = (next) => {
4159
+ if (!controlled) setInternal(next);
4160
+ onValueChange?.(next);
4161
+ };
4162
+ const fmt = (n) => formatValue ? formatValue(n) : n;
4163
+ const ticks = react.useMemo(() => {
4164
+ if (!showTicks) return [];
4165
+ const count = Math.floor((max - min) / step);
4166
+ if (count < 1 || count > 60) return [];
4167
+ return Array.from({ length: count + 1 }, (_, i) => min + i * step);
4168
+ }, [showTicks, min, max, step]);
4169
+ const pct = (n) => (n - min) / (max - min) * 100;
4170
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4171
+ radixUi.Slider.Root,
4172
+ {
4173
+ ref,
4174
+ "data-slot": "slider",
4175
+ "data-size": size,
4176
+ "data-orientation": orientation,
4177
+ "data-tooltip": tooltip === "none" ? void 0 : tooltip,
4178
+ className: cx("orynn-slider", className),
4179
+ min,
4180
+ max,
4181
+ step,
4182
+ orientation,
4183
+ onValueChange: handleChange,
4184
+ ...controlled ? { value: current } : { defaultValue: initial },
4185
+ ...props,
4186
+ children: [
4187
+ /* @__PURE__ */ jsxRuntime.jsxs(radixUi.Slider.Track, { "data-slot": "slider-track", className: "orynn-slider__track", children: [
4188
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Range, { "data-slot": "slider-range", className: "orynn-slider__range" }),
4189
+ ticks.map((t) => /* @__PURE__ */ jsxRuntime.jsx(
4190
+ "span",
4191
+ {
4192
+ className: "orynn-slider__tick",
4193
+ "aria-hidden": "true",
4194
+ style: { insetInlineStart: `${pct(t)}%` }
4195
+ },
4196
+ `tick-${t}`
4197
+ ))
4198
+ ] }),
4199
+ current.map((v, i) => /* @__PURE__ */ jsxRuntime.jsx(
4200
+ radixUi.Slider.Thumb,
4201
+ {
4202
+ "data-slot": "slider-thumb",
4203
+ className: "orynn-slider__thumb",
4204
+ "aria-label": props["aria-label"] ?? `Value ${i + 1}`,
4205
+ children: tooltip !== "none" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-slider__tooltip", "data-slot": "slider-tooltip", children: fmt(v) })
4206
+ },
4207
+ `thumb-${i}`
4208
+ )),
4209
+ marks && marks.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "orynn-slider__marks", "aria-hidden": "true", children: marks.map((m) => /* @__PURE__ */ jsxRuntime.jsxs(
4210
+ "span",
4211
+ {
4212
+ className: "orynn-slider__mark",
4213
+ style: { insetInlineStart: `${pct(m.value)}%` },
4214
+ children: [
4215
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-slider__mark-dot" }),
4216
+ m.label != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-slider__mark-label", children: m.label })
4217
+ ]
4218
+ },
4219
+ `mark-${m.value}`
4220
+ )) })
4221
+ ]
4222
+ }
4223
+ );
4224
+ });
4225
+ var CIRCLE_SIZE = { sm: 40, md: 56, lg: 72 };
4226
+ var CIRCLE_STROKE = { sm: 4, md: 5, lg: 6 };
4227
+ var Progress = /* @__PURE__ */ react.forwardRef(function Progress2({
4228
+ className,
4229
+ value,
4230
+ max = 100,
4231
+ shape = "line",
4232
+ size = "md",
4233
+ variant = "default",
4234
+ showValue = false,
4235
+ label,
4236
+ striped = false,
4237
+ animated = false,
4238
+ radius,
4239
+ circleThickness,
4240
+ circleSize,
4241
+ formatValue,
4242
+ style,
4243
+ ...props
4244
+ }, ref) {
4245
+ const indeterminate = value == null;
4246
+ const clamped = indeterminate ? 0 : Math.min(max, Math.max(0, value));
4247
+ const pct = max > 0 ? clamped / max * 100 : 0;
4248
+ const text = formatValue ? formatValue(clamped, max) : `${Math.round(pct)}%`;
4249
+ const shared = {
4250
+ ref,
4251
+ "data-slot": "progress",
4252
+ "data-shape": shape,
4253
+ "data-size": size,
4254
+ "data-variant": variant,
4255
+ "data-indeterminate": indeterminate || void 0,
4256
+ value: indeterminate ? null : clamped,
4257
+ max,
4258
+ ...props
4259
+ };
4260
+ if (shape === "circle") {
4261
+ const dim = circleSize ?? CIRCLE_SIZE[size];
4262
+ const stroke = circleThickness ?? CIRCLE_STROKE[size];
4263
+ const r = (dim - stroke) / 2;
4264
+ const circ = 2 * Math.PI * r;
4265
+ const offset = indeterminate ? circ * 0.7 : circ * (1 - pct / 100);
4266
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4267
+ radixUi.Progress.Root,
4268
+ {
4269
+ ...shared,
4270
+ className: cx("orynn-progress", "orynn-progress--circle", className),
4271
+ style: { inlineSize: dim, blockSize: dim, ...style },
4272
+ children: [
4273
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "orynn-progress__svg", viewBox: `0 0 ${dim} ${dim}`, "aria-hidden": "true", children: [
4274
+ /* @__PURE__ */ jsxRuntime.jsx(
4275
+ "circle",
4276
+ {
4277
+ className: "orynn-progress__ring-track",
4278
+ cx: dim / 2,
4279
+ cy: dim / 2,
4280
+ r,
4281
+ fill: "none",
4282
+ strokeWidth: stroke
4283
+ }
4284
+ ),
4285
+ /* @__PURE__ */ jsxRuntime.jsx(
4286
+ "circle",
4287
+ {
4288
+ className: "orynn-progress__ring",
4289
+ cx: dim / 2,
4290
+ cy: dim / 2,
4291
+ r,
4292
+ fill: "none",
4293
+ strokeWidth: stroke,
4294
+ strokeLinecap: "round",
4295
+ strokeDasharray: circ,
4296
+ strokeDashoffset: offset
4297
+ }
4298
+ )
4299
+ ] }),
4300
+ showValue && !indeterminate && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-progress__circle-value", children: text })
4301
+ ]
4302
+ }
4303
+ );
4304
+ }
4305
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orynn-progress__wrap", children: [
4306
+ (label != null || showValue && !indeterminate) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orynn-progress__meta", children: [
4307
+ label != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-progress__label", children: label }),
4308
+ showValue && !indeterminate && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-progress__value", children: text })
4309
+ ] }),
4310
+ /* @__PURE__ */ jsxRuntime.jsx(
4311
+ radixUi.Progress.Root,
4312
+ {
4313
+ ...shared,
4314
+ "data-striped": striped || animated || void 0,
4315
+ "data-animated": animated || void 0,
4316
+ className: cx("orynn-progress", className),
4317
+ style: { borderRadius: radius != null ? radius : void 0, ...style },
4318
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4319
+ radixUi.Progress.Indicator,
4320
+ {
4321
+ className: "orynn-progress__bar",
4322
+ "data-slot": "progress-bar",
4323
+ style: {
4324
+ transform: indeterminate ? void 0 : `translateX(-${100 - pct}%)`
4325
+ }
4326
+ }
4327
+ )
4328
+ }
4329
+ )
4330
+ ] });
4331
+ });
4332
+ var toasts = [];
4333
+ var listeners = /* @__PURE__ */ new Set();
4334
+ var counter = 0;
4335
+ var emit = () => {
4336
+ for (const l of listeners) l(toasts);
4337
+ };
4338
+ var subscribe = (l) => {
4339
+ listeners.add(l);
4340
+ return () => {
4341
+ listeners.delete(l);
4342
+ };
4343
+ };
4344
+ var getSnapshot = () => toasts;
4345
+ var upsert = (record) => {
4346
+ const i = toasts.findIndex((t) => t.id === record.id);
4347
+ toasts = i === -1 ? [...toasts, record] : toasts.map((t) => t.id === record.id ? record : t);
4348
+ emit();
4349
+ };
4350
+ var dismissToast = (id) => {
4351
+ toasts = id == null ? [] : toasts.filter((t) => t.id !== id);
4352
+ emit();
4353
+ };
4354
+ var isMessage = (v) => typeof v === "string" || typeof v === "number" || react.isValidElement(v);
4355
+ var normalize = (input, extra) => isMessage(input) ? { title: input, ...extra } : { ...input, ...extra };
4356
+ function base2(input, extra) {
4357
+ const opts = normalize(input, extra);
4358
+ const id = opts.id ?? `toast-${++counter}`;
4359
+ upsert({ ...opts, id, createdAt: Date.now() });
4360
+ return id;
4361
+ }
4362
+ var withVariant = (variant) => (message, opts) => base2(message, { ...opts, variant });
4363
+ var toast = base2;
4364
+ toast.success = withVariant("success");
4365
+ toast.error = withVariant("error");
4366
+ toast.warning = withVariant("warning");
4367
+ toast.info = withVariant("info");
4368
+ toast.loading = withVariant("loading");
4369
+ toast.dismiss = dismissToast;
4370
+ toast.promise = (promise, msgs, opts) => {
4371
+ const id = base2(msgs.loading, {
4372
+ ...opts,
4373
+ variant: "loading",
4374
+ duration: Number.POSITIVE_INFINITY
4375
+ });
4376
+ promise.then(
4377
+ (value) => {
4378
+ const m = typeof msgs.success === "function" ? msgs.success(value) : msgs.success;
4379
+ base2(m, { ...opts, id, variant: "success", duration: opts?.duration });
4380
+ },
4381
+ (err) => {
4382
+ const m = typeof msgs.error === "function" ? msgs.error(err) : msgs.error;
4383
+ base2(m, { ...opts, id, variant: "error", duration: opts?.duration });
4384
+ }
4385
+ );
4386
+ return promise;
4387
+ };
4388
+ function AngleIcon() {
4389
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
4390
+ "path",
4391
+ {
4392
+ d: "M12 8v5M12 16h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",
4393
+ stroke: "currentColor",
4394
+ strokeWidth: "2",
4395
+ strokeLinecap: "round",
4396
+ strokeLinejoin: "round"
4397
+ }
4398
+ ) });
4399
+ }
4400
+ function InfoIcon() {
4401
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
4402
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "2" }),
4403
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 11v5M12 8h.01", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
4404
+ ] });
4405
+ }
4406
+ function CircleXIcon() {
4407
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
4408
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "2" }),
4409
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m15 9-6 6M9 9l6 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
4410
+ ] });
4411
+ }
4412
+ var VARIANT_ICON = {
4413
+ default: null,
4414
+ success: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}),
4415
+ error: /* @__PURE__ */ jsxRuntime.jsx(CircleXIcon, {}),
4416
+ warning: /* @__PURE__ */ jsxRuntime.jsx(AngleIcon, {}),
4417
+ info: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, {}),
4418
+ loading: /* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, { className: "orynn-spin" })
4419
+ };
4420
+ var SWIPE = {
4421
+ "top-left": "left",
4422
+ "top-center": "up",
4423
+ "top-right": "right",
4424
+ "bottom-left": "left",
4425
+ "bottom-center": "down",
4426
+ "bottom-right": "right"
4427
+ };
4428
+ function ToastItem({
4429
+ record,
4430
+ duration,
4431
+ closeButton
4432
+ }) {
4433
+ const variant = record.variant ?? "default";
4434
+ const icon = record.icon === null ? null : record.icon ?? VARIANT_ICON[variant];
4435
+ const showClose = record.dismissible ?? closeButton;
4436
+ const d = record.duration ?? (variant === "loading" ? Number.POSITIVE_INFINITY : duration);
4437
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4438
+ radixUi.Toast.Root,
4439
+ {
4440
+ "data-slot": "toast",
4441
+ "data-variant": variant,
4442
+ className: "orynn-toast",
4443
+ duration: Number.isFinite(d) ? d : 1e9,
4444
+ onOpenChange: (open) => {
4445
+ record.onOpenChange?.(open);
4446
+ if (!open) dismissToast(record.id);
4447
+ },
4448
+ children: [
4449
+ icon != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-toast__icon", "data-slot": "toast-icon", "aria-hidden": "true", children: icon }),
4450
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orynn-toast__content", children: [
4451
+ record.title != null && /* @__PURE__ */ jsxRuntime.jsx(radixUi.Toast.Title, { className: "orynn-toast__title", children: record.title }),
4452
+ record.description != null && /* @__PURE__ */ jsxRuntime.jsx(radixUi.Toast.Description, { className: "orynn-toast__description", children: record.description })
4453
+ ] }),
4454
+ record.action && /* @__PURE__ */ jsxRuntime.jsx(
4455
+ radixUi.Toast.Action,
4456
+ {
4457
+ className: "orynn-toast__action",
4458
+ altText: record.action.altText ?? (typeof record.action.label === "string" ? record.action.label : "Action"),
4459
+ onClick: record.action.onClick,
4460
+ children: record.action.label
4461
+ }
4462
+ ),
4463
+ showClose && /* @__PURE__ */ jsxRuntime.jsx(
4464
+ radixUi.Toast.Close,
4465
+ {
4466
+ className: "orynn-toast__close",
4467
+ "aria-label": "Dismiss",
4468
+ "data-slot": "toast-close",
4469
+ children: /* @__PURE__ */ jsxRuntime.jsx(XIcon, {})
4470
+ }
4471
+ )
4472
+ ]
4473
+ }
4474
+ );
4475
+ }
4476
+ function Toaster({
4477
+ position = "bottom-right",
4478
+ duration = 4e3,
4479
+ visibleToasts = 4,
4480
+ closeButton = true,
4481
+ richColors = false,
4482
+ gap = 12,
4483
+ offset = 24,
4484
+ className
4485
+ }) {
4486
+ const records = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
4487
+ const shown = records.slice(-visibleToasts);
4488
+ const [side] = position.split("-");
4489
+ return /* @__PURE__ */ jsxRuntime.jsxs(radixUi.Toast.Provider, { swipeDirection: SWIPE[position], duration, children: [
4490
+ shown.map((record) => /* @__PURE__ */ jsxRuntime.jsx(ToastItem, { record, duration, closeButton }, record.id)),
4491
+ /* @__PURE__ */ jsxRuntime.jsx(
4492
+ radixUi.Toast.Viewport,
4493
+ {
4494
+ "data-slot": "toaster",
4495
+ "data-position": position,
4496
+ "data-rich-colors": richColors || void 0,
4497
+ className: cx("orynn-toaster", className),
4498
+ style: {
4499
+ "--orynn-toaster-gap": `${gap}px`,
4500
+ "--orynn-toaster-offset": `${offset}px`,
4501
+ [side]: `${offset}px`
4502
+ }
4503
+ }
4504
+ )
4505
+ ] });
4506
+ }
4507
+ function useToast() {
4508
+ const toasts2 = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
4509
+ return { toast, dismiss: dismissToast, toasts: toasts2 };
4510
+ }
4511
+
4512
+ // src/primitives/Pagination/use-pagination.ts
4513
+ var range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, i) => start + i);
4514
+ function usePagination({
4515
+ page,
4516
+ count,
4517
+ total,
4518
+ pageSize = 10,
4519
+ siblingCount = 1,
4520
+ boundaryCount = 1
4521
+ }) {
4522
+ const pageCount = Math.max(
4523
+ 1,
4524
+ count ?? (total != null ? Math.ceil(total / Math.max(1, pageSize)) : 1)
4525
+ );
4526
+ const current = Math.min(Math.max(1, page), pageCount);
4527
+ const startPages = range(1, Math.min(boundaryCount, pageCount));
4528
+ const endPages = range(Math.max(pageCount - boundaryCount + 1, boundaryCount + 1), pageCount);
4529
+ const siblingsStart = Math.max(
4530
+ Math.min(current - siblingCount, pageCount - boundaryCount - siblingCount * 2 - 1),
4531
+ boundaryCount + 2
4532
+ );
4533
+ const siblingsEnd = Math.min(
4534
+ Math.max(current + siblingCount, boundaryCount + siblingCount * 2 + 2),
4535
+ endPages.length > 0 ? endPages[0] - 2 : pageCount - 1
4536
+ );
4537
+ const slots = [
4538
+ ...startPages,
4539
+ ...siblingsStart > boundaryCount + 2 ? ["ellipsis-start"] : boundaryCount + 1 < pageCount - boundaryCount ? [boundaryCount + 1] : [],
4540
+ ...range(siblingsStart, siblingsEnd),
4541
+ ...siblingsEnd < pageCount - boundaryCount - 1 ? ["ellipsis-end"] : pageCount - boundaryCount > boundaryCount ? [pageCount - boundaryCount] : [],
4542
+ ...endPages
4543
+ ];
4544
+ return {
4545
+ pageCount,
4546
+ page: current,
4547
+ hasPrev: current > 1,
4548
+ hasNext: current < pageCount,
4549
+ slots
4550
+ };
4551
+ }
4552
+ var PaginationContent = /* @__PURE__ */ react.forwardRef(
4553
+ function PaginationContent2({ className, ...props }, ref) {
4554
+ return /* @__PURE__ */ jsxRuntime.jsx(
4555
+ "ul",
4556
+ {
4557
+ ref,
4558
+ "data-slot": "pagination-content",
4559
+ className: cx("orynn-pagination__list", className),
4560
+ ...props
4561
+ }
4562
+ );
4563
+ }
4564
+ );
4565
+ var PaginationItem = /* @__PURE__ */ react.forwardRef(
4566
+ function PaginationItem2({ className, ...props }, ref) {
4567
+ return /* @__PURE__ */ jsxRuntime.jsx(
4568
+ "li",
4569
+ {
4570
+ ref,
4571
+ "data-slot": "pagination-item",
4572
+ className: cx("orynn-pagination__item", className),
4573
+ ...props
4574
+ }
4575
+ );
4576
+ }
4577
+ );
4578
+ var PaginationLink = /* @__PURE__ */ react.forwardRef(
4579
+ function PaginationLink2({ className, isActive, size = "md", type, ...props }, ref) {
4580
+ return /* @__PURE__ */ jsxRuntime.jsx(
4581
+ "button",
4582
+ {
4583
+ ref,
4584
+ type: type ?? "button",
4585
+ "data-slot": "pagination-link",
4586
+ "data-active": isActive || void 0,
4587
+ "data-size": size,
4588
+ "aria-current": isActive ? "page" : void 0,
4589
+ className: cx("orynn-pagination__link", className),
4590
+ ...props
4591
+ }
4592
+ );
4593
+ }
4594
+ );
4595
+ var PaginationEllipsis = /* @__PURE__ */ react.forwardRef(function PaginationEllipsis2({ className, children, ...props }, ref) {
4596
+ return /* @__PURE__ */ jsxRuntime.jsx(
4597
+ "span",
4598
+ {
4599
+ ref,
4600
+ "aria-hidden": "true",
4601
+ "data-slot": "pagination-ellipsis",
4602
+ className: cx("orynn-pagination__ellipsis", className),
4603
+ ...props,
4604
+ children: children ?? "\u2026"
4605
+ }
4606
+ );
4607
+ });
4608
+ var Pagination = /* @__PURE__ */ react.forwardRef(
4609
+ function Pagination2({
4610
+ className,
4611
+ page,
4612
+ count,
4613
+ total,
4614
+ pageSize,
4615
+ siblingCount,
4616
+ boundaryCount,
4617
+ onPageChange,
4618
+ showFirstLast = false,
4619
+ showPrevNext = true,
4620
+ iconOnly = false,
4621
+ size = "md",
4622
+ variant = "outline",
4623
+ disabled = false,
4624
+ labels,
4625
+ prevIcon,
4626
+ nextIcon,
4627
+ ...props
4628
+ }, ref) {
4629
+ const model = usePagination({ page, count, total, pageSize, siblingCount, boundaryCount });
4630
+ const L = {
4631
+ previous: labels?.previous ?? "Previous",
4632
+ next: labels?.next ?? "Next",
4633
+ first: labels?.first ?? "First page",
4634
+ last: labels?.last ?? "Last page",
4635
+ ariaLabel: labels?.ariaLabel ?? "Pagination",
4636
+ page: labels?.page ?? ((n) => `Page ${n}`)
4637
+ };
4638
+ const go = (p) => {
4639
+ if (disabled) return;
4640
+ const next = Math.min(Math.max(1, p), model.pageCount);
4641
+ if (next !== model.page) onPageChange(next);
4642
+ };
4643
+ return /* @__PURE__ */ jsxRuntime.jsx(
4644
+ "nav",
4645
+ {
4646
+ ref,
4647
+ "aria-label": L.ariaLabel,
4648
+ "data-slot": "pagination",
4649
+ "data-size": size,
4650
+ "data-variant": variant,
4651
+ "data-disabled": disabled || void 0,
4652
+ className: cx("orynn-pagination", className),
4653
+ ...props,
4654
+ children: /* @__PURE__ */ jsxRuntime.jsxs(PaginationContent, { children: [
4655
+ showFirstLast && /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4656
+ PaginationLink,
4657
+ {
4658
+ size,
4659
+ "aria-label": L.first,
4660
+ disabled: disabled || !model.hasPrev,
4661
+ onClick: () => go(1),
4662
+ children: [
4663
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}),
4664
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, { style: { marginInlineStart: "-0.65em" } })
4665
+ ]
4666
+ }
4667
+ ) }),
4668
+ showPrevNext && /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4669
+ PaginationLink,
4670
+ {
4671
+ size,
4672
+ "aria-label": L.previous,
4673
+ disabled: disabled || !model.hasPrev,
4674
+ className: "orynn-pagination__nav",
4675
+ onClick: () => go(model.page - 1),
4676
+ children: [
4677
+ prevIcon ?? /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}),
4678
+ !iconOnly && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-pagination__nav-label", children: L.previous })
4679
+ ]
4680
+ }
4681
+ ) }),
4682
+ model.slots.map(
4683
+ (slot) => typeof slot === "number" ? /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
4684
+ PaginationLink,
4685
+ {
4686
+ size,
4687
+ isActive: slot === model.page,
4688
+ "aria-label": L.page(slot),
4689
+ disabled,
4690
+ onClick: () => go(slot),
4691
+ children: slot
4692
+ }
4693
+ ) }, slot) : /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsx(PaginationEllipsis, {}) }, slot)
4694
+ ),
4695
+ showPrevNext && /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4696
+ PaginationLink,
4697
+ {
4698
+ size,
4699
+ "aria-label": L.next,
4700
+ disabled: disabled || !model.hasNext,
4701
+ className: "orynn-pagination__nav",
4702
+ onClick: () => go(model.page + 1),
4703
+ children: [
4704
+ !iconOnly && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "orynn-pagination__nav-label", children: L.next }),
4705
+ nextIcon ?? /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {})
4706
+ ]
4707
+ }
4708
+ ) }),
4709
+ showFirstLast && /* @__PURE__ */ jsxRuntime.jsx(PaginationItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4710
+ PaginationLink,
4711
+ {
4712
+ size,
4713
+ "aria-label": L.last,
4714
+ disabled: disabled || !model.hasNext,
4715
+ onClick: () => go(model.pageCount),
4716
+ children: [
4717
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}),
4718
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, { style: { marginInlineStart: "-0.65em" } })
4719
+ ]
4720
+ }
4721
+ ) })
4722
+ ] })
4723
+ }
4724
+ );
4725
+ }
4726
+ );
4056
4727
  var Label = /* @__PURE__ */ react.forwardRef(function Label2({ className, required, optional, children, ...props }, ref) {
4057
4728
  return /* @__PURE__ */ jsxRuntime.jsxs(
4058
4729
  radixUi.Label.Root,
@@ -4796,6 +5467,10 @@ function standardSchemaResolver(schema) {
4796
5467
  };
4797
5468
  }
4798
5469
 
5470
+ exports.Accordion = Accordion;
5471
+ exports.AccordionContent = AccordionContent;
5472
+ exports.AccordionItem = AccordionItem;
5473
+ exports.AccordionTrigger = AccordionTrigger;
4799
5474
  exports.Alert = Alert;
4800
5475
  exports.AlertDescription = AlertDescription;
4801
5476
  exports.AlertTitle = AlertTitle;
@@ -4846,16 +5521,23 @@ exports.Input = Input;
4846
5521
  exports.Label = Label;
4847
5522
  exports.NumberField = NumberField;
4848
5523
  exports.OrynnProvider = OrynnProvider;
5524
+ exports.Pagination = Pagination;
5525
+ exports.PaginationContent = PaginationContent;
5526
+ exports.PaginationEllipsis = PaginationEllipsis;
5527
+ exports.PaginationItem = PaginationItem;
5528
+ exports.PaginationLink = PaginationLink;
4849
5529
  exports.Popover = Popover2;
4850
5530
  exports.PopoverAnchor = PopoverAnchor;
4851
5531
  exports.PopoverArrow = PopoverArrow;
4852
5532
  exports.PopoverClose = PopoverClose;
4853
5533
  exports.PopoverContent = PopoverContent;
4854
5534
  exports.PopoverTrigger = PopoverTrigger;
5535
+ exports.Progress = Progress;
4855
5536
  exports.Radio = Radio;
4856
5537
  exports.RadioGroup = RadioGroup;
4857
5538
  exports.Select = Dropdown;
4858
5539
  exports.Separator = Separator;
5540
+ exports.Slider = Slider;
4859
5541
  exports.Switch = Switch;
4860
5542
  exports.Table = Table;
4861
5543
  exports.TableBody = TableBody;
@@ -4870,6 +5552,7 @@ exports.TabsContent = TabsContent;
4870
5552
  exports.TabsList = TabsList;
4871
5553
  exports.TabsTrigger = TabsTrigger;
4872
5554
  exports.Textarea = Textarea;
5555
+ exports.Toaster = Toaster;
4873
5556
  exports.Tooltip = Tooltip;
4874
5557
  exports.TooltipContent = TooltipContent;
4875
5558
  exports.TooltipProvider = TooltipProvider;
@@ -4886,8 +5569,11 @@ exports.registerField = registerField;
4886
5569
  exports.registerRule = registerRule;
4887
5570
  exports.resolveThemeVars = resolveThemeVars;
4888
5571
  exports.standardSchemaResolver = standardSchemaResolver;
5572
+ exports.toast = toast;
4889
5573
  exports.useFieldsetState = useFieldsetState;
4890
5574
  exports.useOrynnTheme = useOrynnTheme;
5575
+ exports.usePagination = usePagination;
4891
5576
  exports.usePortalContainer = usePortalContainer;
5577
+ exports.useToast = useToast;
4892
5578
  //# sourceMappingURL=index.cjs.map
4893
5579
  //# sourceMappingURL=index.cjs.map