foxit-component 1.0.2 → 1.0.3-alpha.2

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.
@@ -13,6 +13,7 @@ interface FormItemProps {
13
13
  }[];
14
14
  children: ReactNode;
15
15
  className?: string;
16
+ layout?: 'horizontal' | 'horizontal-embed';
16
17
  }
17
18
  declare const FormItem: React.FC<FormItemProps>;
18
19
  export default FormItem;
@@ -6,8 +6,9 @@ import classNames from 'classnames';
6
6
 
7
7
  var FormItem = function (_a) {
8
8
  var _b, _c, _d;
9
- var name = _a.name, label = _a.label, extra = _a.extra, _e = _a.rules, rules = _e === void 0 ? [] : _e, children = _a.children, className = _a.className;
10
- var _f = useContext(FormContext), form = _f.form, formFields = _f.formFields, layout = _f.layout;
9
+ var name = _a.name, label = _a.label, extra = _a.extra, _e = _a.rules, rules = _e === void 0 ? [] : _e, children = _a.children, className = _a.className, layout = _a.layout;
10
+ var _f = useContext(FormContext), form = _f.form, formFields = _f.formFields, globalLayout = _f.layout;
11
+ var currentLayout = layout || globalLayout;
11
12
  var rulesRef = useRef(rules);
12
13
  // Register field when component mounts
13
14
  useEffect(function () {
@@ -32,8 +33,10 @@ var FormItem = function (_a) {
32
33
  var newValue = ((_b = e === null || e === void 0 ? void 0 : e.target) === null || _b === void 0 ? void 0 : _b.value) !== undefined ? e.target.value : e;
33
34
  form.setFieldsValue((_a = {}, _a[name] = newValue, _a));
34
35
  }, [form, name]);
35
- return (jsxs("div", __assign({ className: classNames('foxit-form-item', className), style: __assign(__assign({}, (error || warning ? { marginBottom: 0 } : {})), (layout === 'horizontal-embed' ? { marginTop: '-18px' } : {}) // 减少 18px
36
- ) }, { children: [label && (jsxs("label", __assign({ className: classNames({ 'foxit-form-item-embedlabel': layout === 'horizontal-embed' }) }, { children: [label, rules.some(function (rule) { return rule.required; }) && jsx("span", __assign({ className: "foxit-form-required" }, { children: "*" })), extra && jsx(Fragment, { children: extra })] }))), jsx("span", __assign({ className: "".concat(error ? 'foxit-form-error-component' : warning ? 'foxit-form-warning-component' : '') }, { children: React.Children.map(children, function (child) {
36
+ return (jsxs("div", __assign({ className: classNames('foxit-form-item', className), style: __assign(__assign({}, (error || warning ? { marginBottom: 0 } : {})), (currentLayout === 'horizontal-embed' ? { marginTop: '-18px' } : {}) // 减少 18px
37
+ ) }, { children: [label && (jsxs("label", __assign({ className: classNames({
38
+ 'foxit-form-item-embedlabel': currentLayout === 'horizontal-embed'
39
+ }) }, { children: [label, rules.some(function (rule) { return rule.required; }) && jsx("span", __assign({ className: "foxit-form-required" }, { children: "*" })), extra && jsx(Fragment, { children: extra })] }))), jsx("span", __assign({ className: "".concat(error ? 'foxit-form-error-component' : warning ? 'foxit-form-warning-component' : '') }, { children: React.Children.map(children, function (child) {
37
40
  return React.cloneElement(child, {
38
41
  value: value,
39
42
  onChange: handleChange
@@ -5,6 +5,8 @@ interface QuantityProps {
5
5
  onChange?: (value: number) => void;
6
6
  min?: number;
7
7
  max?: number;
8
+ className?: string;
9
+ [key: string]: unknown;
8
10
  }
9
11
  declare const Quantity: React.FC<QuantityProps>;
10
12
  export { Quantity };
@@ -1,9 +1,10 @@
1
- import { __assign } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __rest, __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
+ import classNames from 'classnames';
4
5
 
5
6
  var Quantity = function (_a) {
6
- var value = _a.value, onChange = _a.onChange, min = _a.min, max = _a.max;
7
+ var value = _a.value, onChange = _a.onChange, min = _a.min, max = _a.max, className = _a.className, props = __rest(_a, ["value", "onChange", "min", "max", "className"]);
7
8
  var _b = useState(value || min || 0), internalValue = _b[0], setInternalValue = _b[1];
8
9
  var currentValue = value !== undefined ? value : internalValue;
9
10
  var handleIncrement = function () {
@@ -37,9 +38,9 @@ var Quantity = function (_a) {
37
38
  }
38
39
  setInternalValue(newValue);
39
40
  };
40
- return (jsxs("div", __assign({ className: "foxit-quantity" }, { children: [jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleDecrement, disabled: min !== undefined && currentValue <= min }, { children: jsx("div", { children: "-" }) })), jsx("input", {
41
+ return (jsxs("div", __assign({ className: classNames('foxit-quantity', className) }, { children: [jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleDecrement, disabled: min !== undefined && currentValue <= min }, { children: jsx("div", { children: "-" }) })), jsx("input", __assign({
41
42
  // type="number"
42
- value: currentValue, onChange: handleChange, min: min, max: max, className: "foxit-quantity-number" }), jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleIncrement, disabled: max !== undefined && currentValue >= max }, { children: jsx("div", { children: "+" }) }))] })));
43
+ value: currentValue, onChange: handleChange, min: min, max: max, className: "foxit-quantity-number" }, props)), jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleIncrement, disabled: max !== undefined && currentValue >= max }, { children: jsx("div", { children: "+" }) }))] })));
43
44
  };
44
45
 
45
46
  export { Quantity };
@@ -14,6 +14,7 @@ export interface SelectProps {
14
14
  preIcon?: React.ReactNode;
15
15
  value?: string | number | CustomOption | null;
16
16
  onChange?: (v: unknown) => void;
17
+ controlStyles?: React.CSSProperties;
17
18
  [key: string]: unknown;
18
19
  }
19
20
  interface CustomOption {
@@ -5,17 +5,17 @@ import classNames from 'classnames';
5
5
  import { Icon } from '../Icon/index.js';
6
6
 
7
7
  var Select = function (_a) {
8
- var options = _a.options, className = _a.className, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, isClearable = _a.isClearable, isSearchable = _a.isSearchable, isMulti = _a.isMulti, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select...' : _b, preIcon = _a.preIcon, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["options", "className", "defaultValue", "isDisabled", "isClearable", "isSearchable", "isMulti", "placeholder", "preIcon", "value", "onChange"]);
8
+ var options = _a.options, className = _a.className, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, isClearable = _a.isClearable, isSearchable = _a.isSearchable, isMulti = _a.isMulti, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select...' : _b, preIcon = _a.preIcon, value = _a.value, onChange = _a.onChange, controlStyles = _a.controlStyles, rest = __rest(_a, ["options", "className", "defaultValue", "isDisabled", "isClearable", "isSearchable", "isMulti", "placeholder", "preIcon", "value", "onChange", "controlStyles"]);
9
9
  var customStyles = {
10
10
  control: function (styles, _a) {
11
11
  var isDisabled = _a.isDisabled;
12
- return (__assign(__assign({}, styles), { backgroundColor: isDisabled ? '#f8f8f8' : 'white',
12
+ return (__assign(__assign(__assign({}, styles), { backgroundColor: isDisabled ? '#f8f8f8' : 'white',
13
13
  // minWidth: 200,
14
14
  height: 48, paddingLeft: 8, borderRadius: 10, fontSize: 14, boxShadow: 'none', border: '1px solid #D9D9D9', ':hover': {
15
15
  border: '1px solid #757575'
16
16
  }, ':focus-within': {
17
17
  border: '1px solid #FF5F00'
18
- } }));
18
+ } }), controlStyles));
19
19
  },
20
20
  menuPortal: function (base) { return (__assign(__assign({}, base), { zIndex: 99999 })); },
21
21
  option: function (styles, _a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxit-component",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-alpha.2",
4
4
  "author": {
5
5
  "name": "linye",
6
6
  "email": "869675630@qq.com"