@underverse-ui/underverse 2.0.7 → 2.0.8

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 257,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -10357,6 +10357,7 @@ var Input = (0, import_react4.forwardRef)(
10357
10357
  value,
10358
10358
  maxLength,
10359
10359
  rightAddon,
10360
+ rightSection,
10360
10361
  borderMode,
10361
10362
  ...rest
10362
10363
  }, ref) => {
@@ -10528,7 +10529,7 @@ var Input = (0, import_react4.forwardRef)(
10528
10529
  radiusClass,
10529
10530
  // Icon padding adjustments
10530
10531
  LeftIcon && "pl-10",
10531
- (RightIcon || showPasswordToggle || clearable || loading2 || success || errMsg) && "pr-10",
10532
+ (RightIcon || showPasswordToggle || clearable || loading2 || success || errMsg || rightSection) && "pr-10",
10532
10533
  // Variant styles
10533
10534
  variantStyles6[variant].container,
10534
10535
  errMsg ? variantStyles6[variant].error : variantStyles6[variant].focus,
@@ -10541,45 +10542,57 @@ var Input = (0, import_react4.forwardRef)(
10541
10542
  ...restInput
10542
10543
  }
10543
10544
  ),
10544
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1", children: [
10545
- getStatusIcon(),
10546
- RightIcon && !loading2 && !success && !errMsg && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RightIcon, { className: cn("text-muted-foreground", sizeStyles8[size].icon) }),
10547
- clearable && hasValue && !loading2 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10548
- "button",
10549
- {
10550
- type: "button",
10551
- onClick: () => {
10552
- if (onClear) return onClear();
10553
- rest.onChange?.({ target: { value: "" } });
10554
- },
10555
- className: cn(
10556
- "flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors rounded-md",
10557
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
10558
- "active:bg-accent active:text-accent-foreground",
10559
- sizeStyles8[size].iconButton
10560
- ),
10561
- tabIndex: 0,
10562
- "aria-label": gi18n.clearInput ?? "Clear input",
10563
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.X, { className: sizeStyles8[size].icon })
10564
- }
10565
- ),
10566
- showPasswordToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10567
- "button",
10568
- {
10569
- type: "button",
10570
- onClick: () => setShowPassword(!showPassword),
10571
- className: cn(
10572
- "flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors rounded-full",
10573
- "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring/40",
10574
- "active:bg-accent/50 active:text-accent-foreground",
10575
- sizeStyles8[size].iconButton
10576
- ),
10577
- tabIndex: 0,
10578
- "aria-label": showPassword ? gi18n.hidePassword ?? "Hide password" : gi18n.showPassword ?? "Show password",
10579
- children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.EyeOff, { className: sizeStyles8[size].icon }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.Eye, { className: sizeStyles8[size].icon })
10580
- }
10581
- )
10582
- ] }),
10545
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
10546
+ "div",
10547
+ {
10548
+ className: cn(
10549
+ "absolute z-10 flex items-center gap-1",
10550
+ rightSection ? "inset-y-0 right-0" : "right-3 top-1/2 -translate-y-1/2"
10551
+ ),
10552
+ children: [
10553
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex items-center gap-1", rightSection && "px-1"), children: [
10554
+ getStatusIcon(),
10555
+ RightIcon && !loading2 && !success && !errMsg && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RightIcon, { className: cn("text-muted-foreground", sizeStyles8[size].icon) }),
10556
+ clearable && hasValue && !loading2 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10557
+ "button",
10558
+ {
10559
+ type: "button",
10560
+ onClick: () => {
10561
+ if (onClear) return onClear();
10562
+ rest.onChange?.({ target: { value: "" } });
10563
+ },
10564
+ className: cn(
10565
+ "flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors rounded-md",
10566
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
10567
+ "active:bg-accent active:text-accent-foreground",
10568
+ sizeStyles8[size].iconButton
10569
+ ),
10570
+ tabIndex: 0,
10571
+ "aria-label": gi18n.clearInput ?? "Clear input",
10572
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.X, { className: sizeStyles8[size].icon })
10573
+ }
10574
+ ),
10575
+ showPasswordToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10576
+ "button",
10577
+ {
10578
+ type: "button",
10579
+ onClick: () => setShowPassword(!showPassword),
10580
+ className: cn(
10581
+ "flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors rounded-full",
10582
+ "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring/40",
10583
+ "active:bg-accent/50 active:text-accent-foreground",
10584
+ sizeStyles8[size].iconButton
10585
+ ),
10586
+ tabIndex: 0,
10587
+ "aria-label": showPassword ? gi18n.hidePassword ?? "Hide password" : gi18n.showPassword ?? "Show password",
10588
+ children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.EyeOff, { className: sizeStyles8[size].icon }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.Eye, { className: sizeStyles8[size].icon })
10589
+ }
10590
+ )
10591
+ ] }),
10592
+ rightSection
10593
+ ]
10594
+ }
10595
+ ),
10583
10596
  rightAddon,
10584
10597
  variant === "minimal" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10585
10598
  "div",
@@ -10614,27 +10627,128 @@ var Input = (0, import_react4.forwardRef)(
10614
10627
  }
10615
10628
  );
10616
10629
  Input.displayName = "Input";
10630
+ var searchButtonWidthStyles = {
10631
+ xs: "w-6",
10632
+ sm: "w-8",
10633
+ md: "w-10",
10634
+ lg: "w-12",
10635
+ xl: "w-14"
10636
+ };
10637
+ var searchButtonPaddingStyles = {
10638
+ xs: "pr-14",
10639
+ sm: "pr-18",
10640
+ md: "pr-20",
10641
+ lg: "pr-24",
10642
+ xl: "pr-28"
10643
+ };
10644
+ var searchButtonRadiusStyles = {
10645
+ none: "rounded-r-none",
10646
+ sm: "rounded-r-sm",
10647
+ md: "rounded-r-md",
10648
+ lg: "rounded-r-lg",
10649
+ xl: "rounded-r-xl",
10650
+ "2xl": "rounded-r-2xl",
10651
+ "3xl": "rounded-r-3xl",
10652
+ full: "rounded-r-full",
10653
+ daewoo: "rounded-r",
10654
+ infiniq: "rounded-r-full"
10655
+ };
10617
10656
  var SearchInput = (0, import_react4.forwardRef)(
10618
- ({ onSearch, searchDelay = 300, placeholder = "Search\u2026", ...props }, ref) => {
10619
- const [searchValue, setSearchValue] = (0, import_react4.useState)(props.value || "");
10657
+ ({
10658
+ mode = "default",
10659
+ onSearch,
10660
+ searchDelay = 300,
10661
+ searchButtonLabel = "Search",
10662
+ placeholder = "Search\u2026",
10663
+ value,
10664
+ defaultValue,
10665
+ onChange,
10666
+ onClear,
10667
+ onKeyDown,
10668
+ clearable = true,
10669
+ size = "md",
10670
+ className,
10671
+ disabled,
10672
+ loading: loading2 = false,
10673
+ rightSection,
10674
+ borderMode,
10675
+ ...props
10676
+ }, ref) => {
10677
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react4.useState)(defaultValue ?? "");
10678
+ const isControlled = value !== void 0;
10679
+ const searchValue = isControlled ? value : uncontrolledValue;
10680
+ const searchText = String(searchValue ?? "");
10681
+ const globalConfig = useUnderverseUIConfig();
10682
+ const resolvedBorderMode = borderMode ?? globalConfig.input?.borderMode ?? globalConfig.borderMode ?? "full";
10683
+ const searchButtonRadiusClass = searchButtonRadiusStyles[resolvedBorderMode] ?? getBorderRadiusClass(resolvedBorderMode);
10684
+ const triggerSearch = (0, import_react4.useCallback)(() => {
10685
+ onSearch?.(searchText);
10686
+ }, [onSearch, searchText]);
10620
10687
  import_react4.default.useEffect(() => {
10621
- if (!onSearch) return;
10688
+ if (!onSearch || mode !== "default") return;
10622
10689
  const timer = setTimeout(() => {
10623
- onSearch(searchValue);
10690
+ onSearch(searchText);
10624
10691
  }, searchDelay);
10625
10692
  return () => clearTimeout(timer);
10626
- }, [searchValue, onSearch, searchDelay]);
10693
+ }, [mode, onSearch, searchDelay, searchText]);
10694
+ const searchButton = mode === "button" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10695
+ "button",
10696
+ {
10697
+ type: "button",
10698
+ onClick: triggerSearch,
10699
+ disabled: disabled || loading2,
10700
+ className: cn(
10701
+ "flex h-full shrink-0 cursor-pointer items-center justify-center border-l border-border bg-transparent text-foreground",
10702
+ "transition-colors hover:bg-accent hover:text-accent-foreground",
10703
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
10704
+ "disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",
10705
+ searchButtonWidthStyles[size],
10706
+ searchButtonRadiusClass
10707
+ ),
10708
+ "aria-label": searchButtonLabel,
10709
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.Search, { className: formControlSizeStyles[size].icon, "aria-hidden": "true" })
10710
+ }
10711
+ ) : null;
10627
10712
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10628
10713
  Input,
10629
10714
  {
10630
10715
  ref,
10631
10716
  type: "search",
10632
- leftIcon: import_lucide_react3.Search,
10717
+ leftIcon: mode === "default" ? import_lucide_react3.Search : void 0,
10633
10718
  placeholder,
10634
- clearable: true,
10719
+ clearable,
10635
10720
  value: searchValue,
10636
- onChange: (e) => setSearchValue(e.target.value),
10637
- onClear: () => setSearchValue(""),
10721
+ onChange: (event) => {
10722
+ if (!isControlled) setUncontrolledValue(event.target.value);
10723
+ onChange?.(event);
10724
+ },
10725
+ onClear: () => {
10726
+ if (!isControlled) {
10727
+ setUncontrolledValue("");
10728
+ } else if (!onClear && onChange) {
10729
+ onChange({ target: { value: "" }, currentTarget: { value: "" } });
10730
+ }
10731
+ onClear?.();
10732
+ },
10733
+ onKeyDown: (event) => {
10734
+ onKeyDown?.(event);
10735
+ if (mode === "button" && event.key === "Enter" && !event.defaultPrevented && !event.nativeEvent.isComposing) {
10736
+ triggerSearch();
10737
+ }
10738
+ },
10739
+ size,
10740
+ className: cn(
10741
+ "[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none",
10742
+ mode === "button" && searchButtonPaddingStyles[size],
10743
+ className
10744
+ ),
10745
+ disabled,
10746
+ loading: loading2,
10747
+ rightSection: mode === "button" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
10748
+ rightSection,
10749
+ searchButton
10750
+ ] }) : rightSection,
10751
+ borderMode,
10638
10752
  ...props
10639
10753
  }
10640
10754
  );
@@ -40587,7 +40701,7 @@ function surrogateLow(ch) {
40587
40701
  function surrogateHigh(ch) {
40588
40702
  return ch >= 55296 && ch < 56320;
40589
40703
  }
40590
- var Fragment30 = class _Fragment {
40704
+ var Fragment31 = class _Fragment {
40591
40705
  /**
40592
40706
  @internal
40593
40707
  */
@@ -40879,7 +40993,7 @@ var Fragment30 = class _Fragment {
40879
40993
  throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
40880
40994
  }
40881
40995
  };
40882
- Fragment30.empty = new Fragment30([], 0);
40996
+ Fragment31.empty = new Fragment31([], 0);
40883
40997
  var found = { index: 0, offset: 0 };
40884
40998
  function retIndex(index, offset) {
40885
40999
  found.index = index;
@@ -41104,7 +41218,7 @@ var Slice = class _Slice {
41104
41218
  let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
41105
41219
  if (typeof openStart != "number" || typeof openEnd != "number")
41106
41220
  throw new RangeError("Invalid input for Slice.fromJSON");
41107
- return new _Slice(Fragment30.fromJSON(schema, json.content), openStart, openEnd);
41221
+ return new _Slice(Fragment31.fromJSON(schema, json.content), openStart, openEnd);
41108
41222
  }
41109
41223
  /**
41110
41224
  Create a slice from a fragment by taking the maximum possible
@@ -41119,7 +41233,7 @@ var Slice = class _Slice {
41119
41233
  return new _Slice(fragment, openStart, openEnd);
41120
41234
  }
41121
41235
  };
41122
- Slice.empty = new Slice(Fragment30.empty, 0, 0);
41236
+ Slice.empty = new Slice(Fragment31.empty, 0, 0);
41123
41237
  function removeRange(content, from, to) {
41124
41238
  let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
41125
41239
  let { index: indexTo, offset: offsetTo } = content.findIndex(to);
@@ -41218,7 +41332,7 @@ function replaceThreeWay($from, $start, $end, $to, depth) {
41218
41332
  addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);
41219
41333
  }
41220
41334
  addRange($to, null, depth, content);
41221
- return new Fragment30(content);
41335
+ return new Fragment31(content);
41222
41336
  }
41223
41337
  function replaceTwoWay($from, $to, depth) {
41224
41338
  let content = [];
@@ -41228,13 +41342,13 @@ function replaceTwoWay($from, $to, depth) {
41228
41342
  addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
41229
41343
  }
41230
41344
  addRange($to, null, depth, content);
41231
- return new Fragment30(content);
41345
+ return new Fragment31(content);
41232
41346
  }
41233
41347
  function prepareSliceForReplace(slice, $along) {
41234
41348
  let extra = $along.depth - slice.openStart, parent = $along.node(extra);
41235
41349
  let node = parent.copy(slice.content);
41236
41350
  for (let i = extra - 1; i >= 0; i--)
41237
- node = $along.node(i).copy(Fragment30.from(node));
41351
+ node = $along.node(i).copy(Fragment31.from(node));
41238
41352
  return {
41239
41353
  start: node.resolveNoCache(slice.openStart + extra),
41240
41354
  end: node.resolveNoCache(node.content.size - slice.openEnd - extra)
@@ -41573,7 +41687,7 @@ var Node7 = class _Node {
41573
41687
  this.type = type;
41574
41688
  this.attrs = attrs;
41575
41689
  this.marks = marks;
41576
- this.content = content || Fragment30.empty;
41690
+ this.content = content || Fragment31.empty;
41577
41691
  }
41578
41692
  /**
41579
41693
  The array of this node's child nodes.
@@ -41879,7 +41993,7 @@ var Node7 = class _Node {
41879
41993
  can optionally pass `start` and `end` indices into the
41880
41994
  replacement fragment.
41881
41995
  */
41882
- canReplace(from, to, replacement = Fragment30.empty, start = 0, end = replacement.childCount) {
41996
+ canReplace(from, to, replacement = Fragment31.empty, start = 0, end = replacement.childCount) {
41883
41997
  let one = this.contentMatchAt(from).matchFragment(replacement, start, end);
41884
41998
  let two = one && one.matchFragment(this.content, to);
41885
41999
  if (!two || !two.validEnd)
@@ -41961,7 +42075,7 @@ var Node7 = class _Node {
41961
42075
  throw new RangeError("Invalid text node in JSON");
41962
42076
  return schema.text(json.text, marks);
41963
42077
  }
41964
- let content = Fragment30.fromJSON(schema, json.content);
42078
+ let content = Fragment31.fromJSON(schema, json.content);
41965
42079
  let node = schema.nodeType(json.type).create(json.attrs, content, marks);
41966
42080
  node.type.checkAttrs(node.attrs);
41967
42081
  return node;
@@ -42057,7 +42171,7 @@ var ContentMatch = class _ContentMatch {
42057
42171
  function search(match, types) {
42058
42172
  let finished = match.matchFragment(after, startIndex);
42059
42173
  if (finished && (!toEnd || finished.validEnd))
42060
- return Fragment30.from(types.map((tp) => tp.createAndFill()));
42174
+ return Fragment31.from(types.map((tp) => tp.createAndFill()));
42061
42175
  for (let i = 0; i < match.next.length; i++) {
42062
42176
  let { type, next } = match.next[i];
42063
42177
  if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
@@ -42625,7 +42739,7 @@ function mapFragment(fragment, f, parent) {
42625
42739
  child = f(child, parent, i);
42626
42740
  mapped.push(child);
42627
42741
  }
42628
- return Fragment30.fromArray(mapped);
42742
+ return Fragment31.fromArray(mapped);
42629
42743
  }
42630
42744
  var AddMarkStep = class _AddMarkStep extends Step {
42631
42745
  /**
@@ -42742,7 +42856,7 @@ var AddNodeMarkStep = class _AddNodeMarkStep extends Step {
42742
42856
  if (!node)
42743
42857
  return StepResult.fail("No node at mark step's position");
42744
42858
  let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
42745
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
42859
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
42746
42860
  }
42747
42861
  invert(doc) {
42748
42862
  let node = doc.nodeAt(this.pos);
@@ -42788,7 +42902,7 @@ var RemoveNodeMarkStep = class _RemoveNodeMarkStep extends Step {
42788
42902
  if (!node)
42789
42903
  return StepResult.fail("No node at mark step's position");
42790
42904
  let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
42791
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
42905
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
42792
42906
  }
42793
42907
  invert(doc) {
42794
42908
  let node = doc.nodeAt(this.pos);
@@ -42991,7 +43105,7 @@ var AttrStep = class _AttrStep extends Step {
42991
43105
  attrs[name] = node.attrs[name];
42992
43106
  attrs[this.attr] = this.value;
42993
43107
  let updated = node.type.create(attrs, null, node.marks);
42994
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
43108
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
42995
43109
  }
42996
43110
  getMap() {
42997
43111
  return StepMap.empty;
@@ -43375,7 +43489,7 @@ var NodeSelection2 = class _NodeSelection extends Selection {
43375
43489
  return new _NodeSelection($pos);
43376
43490
  }
43377
43491
  content() {
43378
- return new Slice(Fragment30.from(this.node), 0, 0);
43492
+ return new Slice(Fragment31.from(this.node), 0, 0);
43379
43493
  }
43380
43494
  eq(other) {
43381
43495
  return other instanceof _NodeSelection && other.anchor == this.anchor;
@@ -44103,10 +44217,10 @@ var CellSelection2 = class CellSelection3 extends Selection {
44103
44217
  }
44104
44218
  rowContent.push(cell);
44105
44219
  }
44106
- rows.push(table.child(row).copy(Fragment30.from(rowContent)));
44220
+ rows.push(table.child(row).copy(Fragment31.from(rowContent)));
44107
44221
  }
44108
44222
  const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
44109
- return new Slice(Fragment30.from(fragment), 1, 1);
44223
+ return new Slice(Fragment31.from(fragment), 1, 1);
44110
44224
  }
44111
44225
  replace(tr, content = Slice.empty) {
44112
44226
  const mapFrom = tr.steps.length, ranges = this.ranges;
@@ -44118,7 +44232,7 @@ var CellSelection2 = class CellSelection3 extends Selection {
44118
44232
  if (sel) tr.setSelection(sel);
44119
44233
  }
44120
44234
  replaceWith(tr, node) {
44121
- this.replace(tr, new Slice(Fragment30.from(node), 0, 0));
44235
+ this.replace(tr, new Slice(Fragment31.from(node), 0, 0));
44122
44236
  }
44123
44237
  forEachCell(f) {
44124
44238
  const table = this.$anchorCell.node(-1);