@abdellatifui/react 3.2.89 → 3.2.91

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/nextgen.d.ts CHANGED
@@ -211,6 +211,7 @@ export declare interface CheckboxItemProps {
211
211
  onChecked?: (ref: default_2.RefObject<any>, state: boolean) => void;
212
212
  onUnChecked?: (ref: default_2.RefObject<any>, state: boolean) => void;
213
213
  defaultChecked?: boolean;
214
+ checked?: boolean;
214
215
  variant?: 'primary' | 'secondary';
215
216
  border?: boolean | 'ghost';
216
217
  checkboxProps?: any;
package/dist/nextgen.js CHANGED
@@ -6463,7 +6463,6 @@ const ModelComponent = forwardRef((props, ref) => {
6463
6463
  animationDuration = 0.2
6464
6464
  } = props;
6465
6465
  const handleClose = useCallback((event) => {
6466
- console.log(event);
6467
6466
  onClose({ open, ref, container, children, props, _children, id, event });
6468
6467
  setTimeout(() => {
6469
6468
  $(ref3.current).addClass("opacity-0");
@@ -19769,7 +19768,7 @@ const Tooltip = ({
19769
19768
  alignOffset: xOffset,
19770
19769
  sideOffset: yOffset,
19771
19770
  className: cn(
19772
- "p-2 border shadow rounded-xs font-aptos text-sm",
19771
+ "p-2 border shadow rounded-xs font-aptos text-sm z-501",
19773
19772
  variant == "primary" && "bg-white text-gray-700 ",
19774
19773
  variant == "secondary" && "bg-accent border-2 text-accent-foreground",
19775
19774
  variant == "outline" && "bg-white text-gray-700 border-2 border-gray-300 shadow-none",
@@ -29016,26 +29015,30 @@ const ToggleItem = (props) => {
29016
29015
  toggleProps = {},
29017
29016
  onContextMenu,
29018
29017
  disabled,
29019
- value
29018
+ value,
29019
+ pressed: controlledPressed
29020
+ // Added
29020
29021
  } = props;
29021
- const [pressed, setPressed] = useState(false);
29022
+ const [internalPressed, setInternalPressed] = useState(defaultChecked);
29023
+ const pressed = controlledPressed !== void 0 ? controlledPressed : internalPressed;
29022
29024
  const api = useMemo(() => {
29023
29025
  return {
29024
29026
  id,
29025
29027
  ref: ref2,
29026
29028
  state: !pressed,
29027
- setPressedState: setPressed,
29029
+ setPressedState: setInternalPressed,
29028
29030
  props,
29029
29031
  data,
29030
29032
  value
29031
29033
  };
29032
29034
  }, [id, ref2.current, pressed, data]);
29033
29035
  const handleOnChange = useCallback((state) => {
29034
- if (disabled) return;
29036
+ if (controlledPressed === void 0) {
29037
+ setInternalPressed(state);
29038
+ }
29035
29039
  if (api_groupChange) {
29036
- api_groupChange(api);
29040
+ api_groupChange({ ...api, state });
29037
29041
  }
29038
- setPressed(state);
29039
29042
  onChange(ref2, state);
29040
29043
  if (state) {
29041
29044
  onPressed(ref2, state);
@@ -29043,12 +29046,12 @@ const ToggleItem = (props) => {
29043
29046
  if (!state) {
29044
29047
  onUnPressed(ref2, state);
29045
29048
  }
29046
- }, [pressed, id]);
29049
+ }, [controlledPressed, api_groupChange, api, onChange, onPressed, onUnPressed]);
29047
29050
  useEffect(() => {
29048
- if (defaultChecked) {
29049
- handleOnChange(true);
29051
+ if (defaultChecked && api_groupChange) {
29052
+ api_groupChange({ ...api, state: true });
29050
29053
  }
29051
- }, [defaultChecked]);
29054
+ }, []);
29052
29055
  useEffect(() => {
29053
29056
  if (ref2.current && rootref && id) {
29054
29057
  itemsRef?.current?.items.push(api);
@@ -29142,27 +29145,30 @@ const CheckboxItem = (props) => {
29142
29145
  onUnChecked = () => {
29143
29146
  },
29144
29147
  defaultChecked = false,
29148
+ checked: controlledChecked,
29145
29149
  variant = "primary",
29146
29150
  checkboxProps = {},
29147
29151
  disabled,
29148
29152
  value,
29149
29153
  checkboxClassName
29150
29154
  } = props;
29151
- const [checked, setChecked] = useState(false);
29155
+ const [internalChecked, setInternalChecked] = useState(defaultChecked || false);
29156
+ const checked = controlledChecked !== void 0 ? controlledChecked : internalChecked;
29152
29157
  const api = useMemo(() => {
29153
29158
  return {
29154
29159
  id,
29155
29160
  ref: ref2,
29156
29161
  state: checked,
29157
- setCheckedState: setChecked,
29162
+ setCheckedState: setInternalChecked,
29158
29163
  props,
29159
29164
  data,
29160
29165
  value
29161
29166
  };
29162
29167
  }, [id, ref2.current, checked, data, props, value]);
29163
29168
  const handleOnChange = useCallback((state) => {
29164
- if (disabled) return;
29165
- setChecked(state);
29169
+ if (controlledChecked === void 0) {
29170
+ setInternalChecked(state);
29171
+ }
29166
29172
  if (api_groupChange) {
29167
29173
  api_groupChange({ ...api, state });
29168
29174
  }
@@ -29172,10 +29178,10 @@ const CheckboxItem = (props) => {
29172
29178
  } else {
29173
29179
  onUnChecked(ref2, state);
29174
29180
  }
29175
- }, [disabled, api_groupChange, api, onChange, onChecked, onUnChecked]);
29181
+ }, [controlledChecked, api_groupChange, api, onChange, onChecked, onUnChecked]);
29176
29182
  useEffect(() => {
29177
- if (defaultChecked) {
29178
- handleOnChange(true);
29183
+ if (defaultChecked && api_groupChange) {
29184
+ api_groupChange({ ...api, state: true });
29179
29185
  }
29180
29186
  }, []);
29181
29187
  useEffect(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abdellatifui/react",
3
3
  "private": false,
4
- "version": "3.2.89",
4
+ "version": "3.2.91",
5
5
  "type": "module",
6
6
  "types": "dist/nextgen.d.ts",
7
7
  "files": [