@firecms/ui 3.4.0-canary.f6a889a → 3.4.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.
@@ -3,6 +3,13 @@ interface SearchBarProps {
3
3
  onClick?: () => void;
4
4
  onTextSearch?: (searchString?: string) => void;
5
5
  placeholder?: string;
6
+ /**
7
+ * Text the input is initialised with. Use it when the search term is restored from
8
+ * somewhere else, e.g. a URL query parameter, so that the input reflects the search
9
+ * that is actually being applied. Only read when the component mounts; the search bar
10
+ * owns the text from then on.
11
+ */
12
+ initialValue?: string;
6
13
  expandable?: boolean;
7
14
  /**
8
15
  * Size of the search bar.
@@ -22,5 +29,5 @@ interface SearchBarProps {
22
29
  loading?: boolean;
23
30
  inputRef?: React.Ref<HTMLInputElement>;
24
31
  }
25
- export declare function SearchBar({ onClick, onTextSearch, placeholder, expandable, size, large, innerClassName, className, autoFocus, disabled, loading, inputRef }: SearchBarProps): React.JSX.Element;
32
+ export declare function SearchBar({ onClick, onTextSearch, placeholder, initialValue, expandable, size, large, innerClassName, className, autoFocus, disabled, loading, inputRef }: SearchBarProps): React.JSX.Element;
26
33
  export {};
package/dist/index.es.js CHANGED
@@ -34,7 +34,7 @@ const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-surface-700
34
34
  const defaultBorderMixin = "border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40 ";
35
35
  const paperMixin = "bg-white rounded-md dark:bg-surface-950 border border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40";
36
36
  const cardMixin = "bg-white dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40 m-1 -p-1";
37
- const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 ";
37
+ const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ";
38
38
  const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 bg-primary-bg/30 dark:bg-opacity-10 dark:bg-primary-bg/10 ring-1 ring-primary ring-opacity-75 ring-primary/75 bg-primary/10 dark:bg-primary/10 ring-1 ring-primary/75";
39
39
  function cls(...classes) {
40
40
  return twMerge(clsx(classes));
@@ -1101,10 +1101,11 @@ const ButtonInner = React__default.memo(React__default.forwardRef((t0, ref) => {
1101
1101
  ButtonInner.displayName = "Button";
1102
1102
  const Button = ButtonInner;
1103
1103
  const Card = React__default.forwardRef((t0, ref) => {
1104
- const $ = c(21);
1104
+ const $ = c(23);
1105
1105
  let children;
1106
1106
  let className;
1107
1107
  let onClick;
1108
+ let onKeyDownProp;
1108
1109
  let props;
1109
1110
  let style;
1110
1111
  if ($[0] !== t0) {
@@ -1113,61 +1114,73 @@ const Card = React__default.forwardRef((t0, ref) => {
1113
1114
  className,
1114
1115
  onClick,
1115
1116
  style,
1117
+ onKeyDown: onKeyDownProp,
1116
1118
  ...props
1117
1119
  } = t0);
1118
1120
  $[0] = t0;
1119
1121
  $[1] = children;
1120
1122
  $[2] = className;
1121
1123
  $[3] = onClick;
1122
- $[4] = props;
1123
- $[5] = style;
1124
+ $[4] = onKeyDownProp;
1125
+ $[5] = props;
1126
+ $[6] = style;
1124
1127
  } else {
1125
1128
  children = $[1];
1126
1129
  className = $[2];
1127
1130
  onClick = $[3];
1128
- props = $[4];
1129
- style = $[5];
1131
+ onKeyDownProp = $[4];
1132
+ props = $[5];
1133
+ style = $[6];
1130
1134
  }
1131
1135
  let t1;
1132
- if ($[6] !== onClick) {
1136
+ if ($[7] !== onClick || $[8] !== onKeyDownProp) {
1133
1137
  t1 = (e) => {
1138
+ onKeyDownProp?.(e);
1139
+ if (!onClick || e.defaultPrevented) {
1140
+ return;
1141
+ }
1142
+ if (e.target !== e.currentTarget) {
1143
+ return;
1144
+ }
1134
1145
  if (e.key === "Enter" || e.key === " ") {
1135
- onClick?.();
1146
+ e.preventDefault();
1147
+ onClick();
1136
1148
  }
1137
1149
  };
1138
- $[6] = onClick;
1139
- $[7] = t1;
1150
+ $[7] = onClick;
1151
+ $[8] = onKeyDownProp;
1152
+ $[9] = t1;
1140
1153
  } else {
1141
- t1 = $[7];
1154
+ t1 = $[9];
1142
1155
  }
1143
- const onKeyPress = t1;
1156
+ const onKeyDown = t1;
1144
1157
  const t2 = onClick ? "button" : void 0;
1145
1158
  const t3 = onClick ? 0 : void 0;
1146
1159
  const t4 = onClick && cardClickableMixin;
1147
1160
  let t5;
1148
- if ($[8] !== className || $[9] !== t4) {
1161
+ if ($[10] !== className || $[11] !== t4) {
1149
1162
  t5 = cls(cardMixin, t4, className);
1150
- $[8] = className;
1151
- $[9] = t4;
1152
- $[10] = t5;
1163
+ $[10] = className;
1164
+ $[11] = t4;
1165
+ $[12] = t5;
1153
1166
  } else {
1154
- t5 = $[10];
1167
+ t5 = $[12];
1155
1168
  }
1156
1169
  let t6;
1157
- if ($[11] !== children || $[12] !== onClick || $[13] !== onKeyPress || $[14] !== props || $[15] !== ref || $[16] !== style || $[17] !== t2 || $[18] !== t3 || $[19] !== t5) {
1158
- t6 = /* @__PURE__ */ jsx("div", { ref, onKeyPress, role: t2, tabIndex: t3, onClick, className: t5, style, ...props, children });
1159
- $[11] = children;
1160
- $[12] = onClick;
1161
- $[13] = onKeyPress;
1162
- $[14] = props;
1163
- $[15] = ref;
1164
- $[16] = style;
1165
- $[17] = t2;
1166
- $[18] = t3;
1167
- $[19] = t5;
1168
- $[20] = t6;
1170
+ if ($[13] !== children || $[14] !== onClick || $[15] !== onKeyDown || $[16] !== props || $[17] !== ref || $[18] !== style || $[19] !== t2 || $[20] !== t3 || $[21] !== t5) {
1171
+ t6 = /* @__PURE__ */ jsx("div", { ref, onKeyDown, role: t2, tabIndex: t3, onClick, className: t5, style, ...props, children });
1172
+ $[13] = children;
1173
+ $[14] = onClick;
1174
+ $[15] = onKeyDown;
1175
+ $[16] = props;
1176
+ $[17] = ref;
1177
+ $[18] = style;
1178
+ $[19] = t2;
1179
+ $[20] = t3;
1180
+ $[21] = t5;
1181
+ $[22] = t6;
1169
1182
  } else {
1170
- t6 = $[20];
1183
+ t6 = $[22];
1171
1184
  }
1172
1185
  return t6;
1173
1186
  });
@@ -36144,6 +36157,7 @@ function SearchBar(t0) {
36144
36157
  onClick,
36145
36158
  onTextSearch,
36146
36159
  placeholder: t1,
36160
+ initialValue,
36147
36161
  expandable: t2,
36148
36162
  size: t3,
36149
36163
  innerClassName,
@@ -36156,7 +36170,7 @@ function SearchBar(t0) {
36156
36170
  const placeholder = t1 === void 0 ? "Search" : t1;
36157
36171
  const expandable = t2 === void 0 ? false : t2;
36158
36172
  const size = t3 === void 0 ? "medium" : t3;
36159
- const [searchText, setSearchText] = useState("");
36173
+ const [searchText, setSearchText] = useState(initialValue ?? "");
36160
36174
  const [active, setActive] = useState(false);
36161
36175
  const deferredValues = useDebounceValue(searchText, 200);
36162
36176
  let t4;