@ludo.ninja/components 2.4.2 → 2.4.3

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.
@@ -6,6 +6,7 @@ interface Props {
6
6
  onChangeHandler: (fieldName: keyof ICreationFilterInput & keyof ICollectionFilterInput, fieldValue: string) => Promise<void>;
7
7
  name: string;
8
8
  isError: boolean;
9
+ disabled?: boolean;
9
10
  menuPortalTarget?: HTMLElement;
10
11
  }
11
12
  declare const BlockChainSelect: React.FC<Props>;
@@ -155,9 +155,10 @@ const Option = (props) => {
155
155
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_select_1.components.Option, { ...props, children: (0, jsx_runtime_1.jsxs)(OptionWrapper, { children: [(0, jsx_runtime_1.jsx)(StyledImg, { width: 20, height: 20, src: props.data.icon, alt: props.label }), props.label] }) }) }));
156
156
  };
157
157
  const SingleValue = ({ children, ...props }) => ((0, jsx_runtime_1.jsx)(react_select_1.components.SingleValue, { ...props, children: (0, jsx_runtime_1.jsxs)(SingleValueWrapper, { children: [(0, jsx_runtime_1.jsx)(StyledImg, { width: 20, height: 20, src: props.data.icon, alt: props.data.label }), children] }) }));
158
- const BlockChainSelect = ({ menuPortalTarget, isLoading, isError, onChangeHandler, defaultOptionValue, name, }) => {
158
+ const BlockChainSelect = ({ menuPortalTarget, isLoading, isError, disabled, onChangeHandler, defaultOptionValue, name, }) => {
159
159
  const getStaticENVDomain = (0, env_1.useEnvStore)((state) => state.getStaticDomain);
160
- return ((0, jsx_runtime_1.jsx)(StyledSelect, { isError: isError, options: getBlockchainOptions(getStaticENVDomain()), isLoading: isLoading, isSearchable: true, onChangeHandler: onChangeHandler, name: name, customComponents: { Option, SingleValue }, ...(menuPortalTarget
160
+ const options = getBlockchainOptions(getStaticENVDomain());
161
+ return ((0, jsx_runtime_1.jsx)(StyledSelect, { disabled: disabled, isError: isError, options: options, isLoading: isLoading, isSearchable: true, onChangeHandler: onChangeHandler, name: name, customComponents: { Option, SingleValue }, ...(menuPortalTarget
161
162
  ? {
162
163
  styles: {
163
164
  menuPortal: (base) => ({
@@ -1,5 +1,6 @@
1
- declare const SubmitNewProjectForm: ({ blockchain, contractAddress }: {
1
+ declare const SubmitNewProjectForm: ({ blockchain, contractAddress, disabledBlockchainSelect }: {
2
2
  blockchain?: string;
3
3
  contractAddress?: string;
4
+ disabledBlockchainSelect?: boolean;
4
5
  }) => import("react/jsx-runtime").JSX.Element;
5
6
  export default SubmitNewProjectForm;
@@ -105,7 +105,7 @@ const StyledCreateForm = styled_components_1.default.div `
105
105
  }
106
106
  }
107
107
  `;
108
- const SubmitNewProjectForm = ({ blockchain, contractAddress }) => {
108
+ const SubmitNewProjectForm = ({ blockchain, contractAddress, disabledBlockchainSelect }) => {
109
109
  const { control, register, handleSubmit, formState: { errors }, setError, setFocus, watch, } = (0, react_hook_form_1.useForm)({
110
110
  mode: 'all',
111
111
  defaultValues: {
@@ -171,7 +171,7 @@ const SubmitNewProjectForm = ({ blockchain, contractAddress }) => {
171
171
  };
172
172
  return ((0, jsx_runtime_1.jsxs)(StyledCreateForm, { children: [(0, jsx_runtime_1.jsxs)("div", { className: 'head', children: [(0, jsx_runtime_1.jsx)("h3", { className: 'tittle', children: 'Submit New Project' }), (0, jsx_runtime_1.jsx)(Text_1.MainText, { color: colors_1.TextGrayColor, children: "Add your favorite project to follow up it on Ludo" })] }), (0, jsx_runtime_1.jsxs)("form", { onSubmit: handleSubmit(onSubmit), children: [(0, jsx_runtime_1.jsxs)("div", { className: 'content', children: [(0, jsx_runtime_1.jsx)("div", { className: "input_group", children: (0, jsx_runtime_1.jsx)(Forms_1.Input, { register: registerContract, error: errorContract, data: dataForContract }) }), (0, jsx_runtime_1.jsx)("div", { className: "input_group", children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: "blockchain", control: control, rules: {
173
173
  required: { message: 'Blockchain is required', value: true },
174
- }, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(blockchainSelect_1.default, { isError: Boolean(errors.blockchain), isLoading: false, onChangeHandler: async (fieldName, fieldValue) => field.onChange(fieldValue), name: field.name }), errors.blockchain && ((0, jsx_runtime_1.jsx)(Forms_1.BasicErrorLabel, { children: errors.blockchain.message }))] })) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "btns", children: [(0, jsx_runtime_1.jsx)(MainButton_1.default, { text: 'Add', type: 'submit', variant: "primaryM", disabled: loading, onClick: () => null }), (0, jsx_runtime_1.jsx)(MainButton_1.default, { text: 'Cancel', variant: "outline", onClick: () => {
174
+ }, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(blockchainSelect_1.default, { defaultOptionValue: blockchain, disabled: disabledBlockchainSelect, isError: Boolean(errors.blockchain), isLoading: false, onChangeHandler: async (fieldName, fieldValue) => field.onChange(fieldValue), name: field.name }), errors.blockchain && ((0, jsx_runtime_1.jsx)(Forms_1.BasicErrorLabel, { children: errors.blockchain.message }))] })) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "btns", children: [(0, jsx_runtime_1.jsx)(MainButton_1.default, { text: 'Add', type: 'submit', variant: "primaryM", disabled: loading, onClick: () => null }), (0, jsx_runtime_1.jsx)(MainButton_1.default, { text: 'Cancel', variant: "outline", onClick: () => {
175
175
  closeModalSidebarPortal();
176
176
  } })] })] })] }));
177
177
  };
@@ -8,6 +8,7 @@ interface Props {
8
8
  defaultOptionValue?: string;
9
9
  isLoading?: boolean;
10
10
  isSearchable?: boolean;
11
+ disabled?: boolean;
11
12
  onChangeHandler: (fieldName: keyof ICreationFilterInput & keyof ICollectionFilterInput, fieldValue: string) => Promise<void>;
12
13
  name: string;
13
14
  customComponents?: Partial<SelectComponents<unknown, boolean, GroupBase<unknown>>>;
@@ -51,6 +51,7 @@ const SelectElement = (0, styled_components_1.default)(react_select_1.default) `
51
51
  border-radius: 6px;
52
52
  box-shadow: none;
53
53
  min-height: ${(props) => `${props.minHeight}px`};
54
+ opacity: ${(props) => props.isDisabled ? 0.5 : 1};
54
55
  cursor: pointer;
55
56
 
56
57
  &:hover,
@@ -108,7 +109,7 @@ const SelectElement = (0, styled_components_1.default)(react_select_1.default) `
108
109
  cursor: pointer;
109
110
  }
110
111
 
111
- ${ScreenWidth_1.mediaQuery.minWidthFourK} {
112
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
112
113
  .react-select__value-container {
113
114
  padding: 0 0 0 ${(0, _4k_1.adaptiveValueCalc)(20)};
114
115
  }
@@ -149,7 +150,7 @@ const DropdownIndicator = (props) => {
149
150
  transform: props.selectProps.menuIsOpen ? "rotate(180deg)" : "rotate(0)",
150
151
  }, width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M16 11L12 15L8 11", stroke: "#696F91", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }));
151
152
  };
152
- const DesktopSelect = ({ options, isLoading, onChangeHandler, defaultOptionValue, name, customComponents, isSearchable, ...props }) => {
153
+ const DesktopSelect = ({ options, isLoading, onChangeHandler, defaultOptionValue, name, customComponents, isSearchable, disabled, ...props }) => {
153
154
  const [selectedOption, setSelectedOption] = (0, react_1.useState)(options.find((option) => {
154
155
  return defaultOptionValue === option.id;
155
156
  }) || null);
@@ -158,7 +159,7 @@ const DesktopSelect = ({ options, isLoading, onChangeHandler, defaultOptionValue
158
159
  return defaultOptionValue === option.id;
159
160
  });
160
161
  setSelectedOption(findOption || null);
161
- }, [defaultOptionValue]);
162
+ }, [defaultOptionValue, options]);
162
163
  const handleChangeOption = async (option) => {
163
164
  await onChangeHandler(name, option.id);
164
165
  setSelectedOption(option);
@@ -172,7 +173,7 @@ const DesktopSelect = ({ options, isLoading, onChangeHandler, defaultOptionValue
172
173
  const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
173
174
  if (isLoading)
174
175
  return (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { height: `${minHeight}px`, width: "154px" });
175
- return ((0, jsx_runtime_1.jsx)(SelectElement, { id: String(Math.random()), minHeight: minHeight, scale: (0, scale_1.getAdaptiveScale)({ windowDimensions, currentSize: 1 }), classNamePrefix: "react-select", name: name, getOptionLabel: (option) => getOptionLabel(option), getOptionValue: (option) => getOptionValue(option), options: options, value: selectedOption, defaultValue: selectedOption, onChange: (option) => handleChangeOption(option), isSearchable: isSearchable, components: {
176
+ return ((0, jsx_runtime_1.jsx)(SelectElement, { id: String(Math.random()), minHeight: minHeight, scale: (0, scale_1.getAdaptiveScale)({ windowDimensions, currentSize: 1 }), classNamePrefix: "react-select", name: name, getOptionLabel: (option) => getOptionLabel(option), getOptionValue: (option) => getOptionValue(option), options: options, value: selectedOption, defaultValue: selectedOption, onChange: (option) => handleChangeOption(option), isSearchable: isSearchable, isDisabled: disabled, components: {
176
177
  DropdownIndicator,
177
178
  IndicatorSeparator: () => null,
178
179
  ...customComponents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",