@soppiya/app-bridge 1.2.7 → 1.2.9
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/components/variants-picker/ui/VariantsPicker.d.ts +2 -1
- package/dist/components/variants-picker/ui/VariantsPicker.js +7 -3
- package/dist/components/variants-picker/ui/VariantsPicker.stories.d.ts +2 -1
- package/dist/hooks/useSoppiyaBridge.d.ts +1 -1
- package/dist/hooks/useSoppiyaBridge.js +1 -3
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type Props = {
|
|
2
2
|
title?: string;
|
|
3
|
+
selectedVariantIds?: string[];
|
|
3
4
|
initialIds?: string[];
|
|
4
5
|
limit?: number;
|
|
5
6
|
okButtonLoading?: boolean;
|
|
@@ -7,5 +8,5 @@ type Props = {
|
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (variants: string[]) => void;
|
|
9
10
|
};
|
|
10
|
-
declare const VariantsPicker: ({ title, initialIds, limit, okButtonLoading, buttonText, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const VariantsPicker: ({ title, selectedVariantIds, initialIds, limit, okButtonLoading, buttonText, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default VariantsPicker;
|
|
@@ -4,9 +4,9 @@ import { useFilterQuery } from "../../../shared/lib/index.js";
|
|
|
4
4
|
import { Badge, BlockStack, Box, Button, Checkbox, Image, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import lodash from "lodash";
|
|
7
|
-
import { useState } from "react";
|
|
7
|
+
import { useMemo, useState } from "react";
|
|
8
8
|
import { useVariants } from "../model/useVariants.js";
|
|
9
|
-
const VariantsPicker = ({ title = "Variants", initialIds = [], limit = 1 / 0, okButtonLoading, buttonText = "Add", onClose, onOk })=>{
|
|
9
|
+
const VariantsPicker = ({ title = "Variants", selectedVariantIds = [], initialIds = [], limit = 1 / 0, okButtonLoading, buttonText = "Add", onClose, onOk })=>{
|
|
10
10
|
const [selectedVariant, setSelectedVariant] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { variants, pageInfo, isLoadingVariants, fetchMoreVariants } = useVariants({
|
|
@@ -26,6 +26,10 @@ const VariantsPicker = ({ title = "Variants", initialIds = [], limit = 1 / 0, ok
|
|
|
26
26
|
const handleOk = ()=>{
|
|
27
27
|
if (lodash.isFunction(onOk)) onOk(selectedVariant);
|
|
28
28
|
};
|
|
29
|
+
const filteredVariants = useMemo(()=>variants?.filter((variant)=>!selectedVariantIds.includes(String(variant._id))), [
|
|
30
|
+
variants,
|
|
31
|
+
selectedVariantIds
|
|
32
|
+
]);
|
|
29
33
|
const buttonsJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
30
34
|
gap: 50,
|
|
31
35
|
justifyContent: "end",
|
|
@@ -61,7 +65,7 @@ const VariantsPicker = ({ title = "Variants", initialIds = [], limit = 1 / 0, ok
|
|
|
61
65
|
})
|
|
62
66
|
}) : /*#__PURE__*/ jsxs(BlockStack, {
|
|
63
67
|
children: [
|
|
64
|
-
|
|
68
|
+
filteredVariants?.map((variant)=>/*#__PURE__*/ jsxs(InlineStack, {
|
|
65
69
|
stack: "full",
|
|
66
70
|
className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
|
|
67
71
|
'bg-[#f1f1f1ab] cursor-default!': !selectedVariant.includes(variant._id) && isReached
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, okButtonLoading, buttonText, onClose, onOk }: {
|
|
3
|
+
component: ({ title, selectedVariantIds, initialIds, limit, okButtonLoading, buttonText, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
|
+
selectedVariantIds?: string[];
|
|
5
6
|
initialIds?: string[];
|
|
6
7
|
limit?: number;
|
|
7
8
|
okButtonLoading?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soppiya/app-bridge",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@apollo/client": "^4.0.7",
|
|
63
|
-
"@soppiya/elementus": "^1.2
|
|
63
|
+
"@soppiya/elementus": "^1.4.2",
|
|
64
64
|
"@uidotdev/usehooks": "^2.4.1",
|
|
65
65
|
"classnames": "^2.5.1",
|
|
66
66
|
"lodash": "^4.17.21",
|