@sheinx/base 3.0.0-rc.4 → 3.0.0-rc.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["checkbox.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqFhD,QAAA,MAAM,mBAAmB,6CAIxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["checkbox.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2FhD,QAAA,MAAM,mBAAmB,6CAIxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -33,6 +33,10 @@ var Checkbox = function Checkbox(props) {
33
33
  inputable = props.inputable,
34
34
  rest = _objectWithoutProperties(props, _excluded);
35
35
  var checkboxStyle = jssStyle === null || jssStyle === void 0 || (_jssStyle$checkbox = jssStyle.checkbox) === null || _jssStyle$checkbox === void 0 ? void 0 : _jssStyle$checkbox.call(jssStyle);
36
+ var disabled = props.disabled;
37
+ if (htmlValue !== undefined && typeof disabled === 'function') {
38
+ disabled = disabled(htmlValue);
39
+ }
36
40
  var _useInputAble = (0, _hooks.useInputAble)({
37
41
  value: valuePo,
38
42
  defaultValue: defaultValuePo,
@@ -77,6 +81,7 @@ var Checkbox = function Checkbox(props) {
77
81
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_simpleCheckbox.default, _objectSpread(_objectSpread({
78
82
  jssStyle: jssStyle
79
83
  }, rest), {}, {
84
+ disabled: disabled,
80
85
  checked: getChecked(),
81
86
  onChange: handleChange,
82
87
  renderFooter: function renderFooter(c) {
@@ -1,5 +1,5 @@
1
1
  import { CheckboxProps } from './checkbox.type';
2
- declare const useCheckboxInputable: <T>(props: Pick<CheckboxProps<T>, "onChange" | "value" | "checked" | "inputable">) => {
2
+ declare const useCheckboxInputable: <T>(props: Pick<CheckboxProps<T>, "value" | "onChange" | "checked" | "inputable">) => {
3
3
  checked: boolean | "indeterminate" | ((d: T) => boolean | "indeterminate") | undefined;
4
4
  onInputableCheckboxChange: (c: boolean) => void;
5
5
  onInputChange: (value?: string) => void;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  declare const config: {
2
3
  alert: {
3
4
  Close: JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.tsx"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIX,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,KAAK,cAAc,GAAG,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;AAGjD,eAAO,MAAM,QAAQ,cAAe,cAAc,SAYjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.tsx"],"names":[],"mappings":";AACA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIX,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,KAAK,cAAc,GAAG,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;AAGjD,eAAO,MAAM,QAAQ,cAAe,cAAc,SAYjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { InputCommonProps } from './input.type';
3
- declare const useInputCommon: <Value, Props extends InputCommonProps<Value>>(props0: Props) => Omit<Props, "error" | "onChange" | "value" | "htmlName" | "disabled" | "style" | "status" | "defaultValue" | "onBlur" | "info" | "size" | "width" | "delay" | "innerTitle" | "placeTitle" | "popover" | "tip" | "clearable" | "beforeChange" | "popoverProps" | "suffix" | "forwardRef" | "clearToUndefined"> & {
3
+ declare const useInputCommon: <Value, Props extends InputCommonProps<Value>>(props0: Props) => Omit<Props, "error" | "info" | "style" | "status" | "size" | "innerTitle" | "placeTitle" | "tip" | "value" | "onChange" | "disabled" | "width" | "defaultValue" | "popover" | "beforeChange" | "delay" | "onBlur" | "clearable" | "popoverProps" | "suffix" | "forwardRef" | "htmlName" | "clearToUndefined"> & {
4
4
  name: string | undefined;
5
5
  style: React.CSSProperties;
6
6
  suffix: JSX.Element;
7
7
  status: "error" | undefined;
8
8
  disabled: boolean | undefined;
9
- size: "default" | "small" | "large" | undefined;
9
+ size: "small" | "large" | "default" | undefined;
10
10
  rootRef: React.RefObject<HTMLElement>;
11
11
  inputRef: React.Ref<HTMLInputElement> | undefined;
12
12
  renderInput: (el: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["result.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ5C,QAAA,MAAM,MAAM,uEA4WX,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["result.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ5C,QAAA,MAAM,MAAM,uEA6WX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -250,6 +250,7 @@ var Result = function Result(props) {
250
250
  var renderMultipleResultMore = /*#__PURE__*/(0, _jsxRuntime.jsx)(_resultMore.default, {
251
251
  keygen: keygen,
252
252
  classes: props.classes,
253
+ jssStyle: props.jssStyle,
253
254
  data: result,
254
255
  size: size,
255
256
  more: moreNumber,
@@ -1 +1 @@
1
- {"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["sticky.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsB5C,QAAA,MAAM,MAAM,UAAW,WAAW,gBA0OjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["sticky.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsB5C,QAAA,MAAM,MAAM,UAAW,WAAW,gBAmPjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -25,28 +25,29 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
25
  var cssSupport = _hooks.util.cssSupport;
26
26
  var supportSticky = cssSupport('position', 'sticky');
27
27
  var defaultZIndex = 900;
28
- var getFirstScrollParent = function getFirstScrollParent(el) {
29
- var parent = el.parentNode;
30
- while (parent) {
31
- if (parent === document.body || parent === document.documentElement) {
32
- parent = document.body;
33
- break;
34
- }
35
- var _window$getComputedSt = window.getComputedStyle(parent),
36
- overflowY = _window$getComputedSt.overflowY;
37
- if (overflowY === 'scroll' || overflowY === 'auto') {
38
- break;
39
- }
40
- parent = parent.parentNode;
41
- }
42
- return parent;
43
- };
28
+
29
+ // const getFirstScrollParent = (el: HTMLElement) => {
30
+ // let parent = el.parentNode as HTMLElement;
31
+ // while (parent) {
32
+ // if (parent === document.body || parent === document.documentElement) {
33
+ // parent = document.body;
34
+ // break;
35
+ // }
36
+ // const { overflowY } = window.getComputedStyle(parent);
37
+ // if (overflowY === 'scroll' || overflowY === 'auto') {
38
+ // break;
39
+ // }
40
+ // parent = parent.parentNode as HTMLElement;
41
+ // }
42
+ // return parent;
43
+ // };
44
+
44
45
  var Sticky = function Sticky(props) {
45
46
  var _props$style;
46
- var css = props.css,
47
- children = props.children,
47
+ var children = props.children,
48
48
  top = props.top,
49
49
  bottom = props.bottom;
50
+ var css = props.css || props.target;
50
51
  var _useRef = (0, _react.useRef)({
51
52
  target: null,
52
53
  div: null,
@@ -74,15 +75,15 @@ var Sticky = function Sticky(props) {
74
75
  timer: 0
75
76
  });
76
77
  var getTarget = function getTarget() {
77
- var target = props.target;
78
- if (typeof props.target === 'string') {
79
- target = document.querySelector(props.target);
78
+ var scrollContainer = props.scrollContainer;
79
+ if (typeof scrollContainer === 'string') {
80
+ scrollContainer = document.querySelector(scrollContainer);
80
81
  }
81
82
  // 判断是否是dom元素
82
- if (target && target.nodeType === 1) {
83
- return target;
83
+ if (scrollContainer && scrollContainer.nodeType === 1) {
84
+ return scrollContainer;
84
85
  }
85
- return getFirstScrollParent(elementRef.current);
86
+ return document.body;
86
87
  };
87
88
  var updateStyle = (0, _hooks.usePersistFn)(function () {
88
89
  if (context.div && !context.isTop && show) {
@@ -178,7 +179,7 @@ var Sticky = function Sticky(props) {
178
179
  };
179
180
  var createObserver = function createObserver() {
180
181
  var target = getTarget();
181
- if (!context.div) {
182
+ if (!context.div && target !== document.body) {
182
183
  context.div = document.createElement('div');
183
184
  context.div.style.position = 'relative';
184
185
  }
@@ -186,18 +187,21 @@ var Sticky = function Sticky(props) {
186
187
  forceRender();
187
188
  context.target = target;
188
189
  cleanEvents();
189
- if (target === document.body) {
190
- document.body.appendChild(context.div);
191
- } else {
192
- target.parentNode.insertBefore(context.div, target);
193
- }
194
- var _style4 = window.getComputedStyle(target);
195
- if (_style4.position === 'absolute' || _style4.position === 'fixed') {
196
- context.div.style.position = _style4.position;
197
- context.div.style.top = _style4.top;
198
- context.div.style.left = _style4.left;
199
- context.div.style.right = _style4.right;
200
- context.div.style.bottom = _style4.bottom;
190
+ if (context.div) {
191
+ // append div
192
+ if (target === document.body) {
193
+ document.body.appendChild(context.div);
194
+ } else {
195
+ target.parentNode.insertBefore(context.div, target);
196
+ }
197
+ var _style4 = window.getComputedStyle(target);
198
+ if (_style4.position === 'absolute' || _style4.position === 'fixed') {
199
+ context.div.style.position = _style4.position;
200
+ context.div.style.top = _style4.top;
201
+ context.div.style.left = _style4.left;
202
+ context.div.style.right = _style4.right;
203
+ context.div.style.bottom = _style4.bottom;
204
+ }
201
205
  }
202
206
  if (window.IntersectionObserver) {
203
207
  var observer = new IntersectionObserver(handlePosition, {
@@ -274,8 +278,9 @@ var Sticky = function Sticky(props) {
274
278
  children: children
275
279
  })
276
280
  }) : null;
281
+ var isFixed = style.position === 'fixed';
277
282
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
278
- children: [context.target && context.div && /*#__PURE__*/(0, _reactDom.createPortal)(StickyEl, context.div), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
283
+ children: [isFixed ? StickyEl : context.target && context.div && /*#__PURE__*/(0, _reactDom.createPortal)(StickyEl, context.div), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
279
284
  className: props.className,
280
285
  style: _objectSpread(_objectSpread({}, props.style), {}, {
281
286
  opacity: show && parentVisible ? 0 : (_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.opacity
@@ -17,11 +17,15 @@ export interface StickyProps extends Pick<CommonType, 'className' | 'style'> {
17
17
  * @cn 距离底部多少偏移量触发
18
18
  */
19
19
  bottom?: number;
20
+ /**
21
+ * @deprecated use scrollContainer
22
+ */
23
+ target?: string | HTMLElement | null;
20
24
  /**
21
25
  * @en Custom attachment target. You can pass in HTMLElement or css selector. The target must be an ancestor node of the Sticky component
22
26
  * @cn 自定义附着的目标。可以传入 HTMLElement 或者 css selector,target 必须为 Sticky 组件的祖先节点
23
27
  */
24
- target?: string | HTMLElement | null;
28
+ scrollContainer?: string | HTMLElement | null;
25
29
  /**
26
30
  * @cn sticky 父级元素, 当父元素离开视窗时,sticky 将失效
27
31
  * @en sticky parent, when the parent element leaves the viewport, the sticky will be invalid
@@ -1 +1 @@
1
- {"version":3,"file":"sticky.type.d.ts","sourceRoot":"","sources":["sticky.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC;IAC1E,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,MAAM,aAAa,CAAC;KAC7B,CAAC;IAEF;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
1
+ {"version":3,"file":"sticky.type.d.ts","sourceRoot":"","sources":["sticky.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC;IAC1E,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,MAAM,aAAa,CAAC;KAC7B,CAAC;IAEF;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAE9C;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["checkbox.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqFhD,QAAA,MAAM,mBAAmB,6CAIxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["checkbox.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2FhD,QAAA,MAAM,mBAAmB,6CAIxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -26,6 +26,10 @@ var Checkbox = function Checkbox(props) {
26
26
  inputable = props.inputable,
27
27
  rest = _objectWithoutProperties(props, _excluded);
28
28
  var checkboxStyle = jssStyle === null || jssStyle === void 0 || (_jssStyle$checkbox = jssStyle.checkbox) === null || _jssStyle$checkbox === void 0 ? void 0 : _jssStyle$checkbox.call(jssStyle);
29
+ var disabled = props.disabled;
30
+ if (htmlValue !== undefined && typeof disabled === 'function') {
31
+ disabled = disabled(htmlValue);
32
+ }
29
33
  var _useInputAble = useInputAble({
30
34
  value: valuePo,
31
35
  defaultValue: defaultValuePo,
@@ -70,6 +74,7 @@ var Checkbox = function Checkbox(props) {
70
74
  return /*#__PURE__*/_jsx(SimpleCheckbox, _objectSpread(_objectSpread({
71
75
  jssStyle: jssStyle
72
76
  }, rest), {}, {
77
+ disabled: disabled,
73
78
  checked: getChecked(),
74
79
  onChange: handleChange,
75
80
  renderFooter: function renderFooter(c) {
@@ -1,5 +1,5 @@
1
1
  import { CheckboxProps } from './checkbox.type';
2
- declare const useCheckboxInputable: <T>(props: Pick<CheckboxProps<T>, "onChange" | "value" | "checked" | "inputable">) => {
2
+ declare const useCheckboxInputable: <T>(props: Pick<CheckboxProps<T>, "value" | "onChange" | "checked" | "inputable">) => {
3
3
  checked: boolean | "indeterminate" | ((d: T) => boolean | "indeterminate") | undefined;
4
4
  onInputableCheckboxChange: (c: boolean) => void;
5
5
  onInputChange: (value?: string) => void;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  declare const config: {
2
3
  alert: {
3
4
  Close: JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.tsx"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIX,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,KAAK,cAAc,GAAG,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;AAGjD,eAAO,MAAM,QAAQ,cAAe,cAAc,SAYjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.tsx"],"names":[],"mappings":";AACA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIX,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,KAAK,cAAc,GAAG,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;AAGjD,eAAO,MAAM,QAAQ,cAAe,cAAc,SAYjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { InputCommonProps } from './input.type';
3
- declare const useInputCommon: <Value, Props extends InputCommonProps<Value>>(props0: Props) => Omit<Props, "error" | "onChange" | "value" | "htmlName" | "disabled" | "style" | "status" | "defaultValue" | "onBlur" | "info" | "size" | "width" | "delay" | "innerTitle" | "placeTitle" | "popover" | "tip" | "clearable" | "beforeChange" | "popoverProps" | "suffix" | "forwardRef" | "clearToUndefined"> & {
3
+ declare const useInputCommon: <Value, Props extends InputCommonProps<Value>>(props0: Props) => Omit<Props, "error" | "info" | "style" | "status" | "size" | "innerTitle" | "placeTitle" | "tip" | "value" | "onChange" | "disabled" | "width" | "defaultValue" | "popover" | "beforeChange" | "delay" | "onBlur" | "clearable" | "popoverProps" | "suffix" | "forwardRef" | "htmlName" | "clearToUndefined"> & {
4
4
  name: string | undefined;
5
5
  style: React.CSSProperties;
6
6
  suffix: JSX.Element;
7
7
  status: "error" | undefined;
8
8
  disabled: boolean | undefined;
9
- size: "default" | "small" | "large" | undefined;
9
+ size: "small" | "large" | "default" | undefined;
10
10
  rootRef: React.RefObject<HTMLElement>;
11
11
  inputRef: React.Ref<HTMLInputElement> | undefined;
12
12
  renderInput: (el: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["result.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ5C,QAAA,MAAM,MAAM,uEA4WX,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["result.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ5C,QAAA,MAAM,MAAM,uEA6WX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -242,6 +242,7 @@ var Result = function Result(props) {
242
242
  var renderMultipleResultMore = /*#__PURE__*/_jsx(More, {
243
243
  keygen: keygen,
244
244
  classes: props.classes,
245
+ jssStyle: props.jssStyle,
245
246
  data: result,
246
247
  size: size,
247
248
  more: moreNumber,
@@ -1 +1 @@
1
- {"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["sticky.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsB5C,QAAA,MAAM,MAAM,UAAW,WAAW,gBA0OjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["sticky.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsB5C,QAAA,MAAM,MAAM,UAAW,WAAW,gBAmPjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -19,28 +19,29 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
19
19
  var cssSupport = util.cssSupport;
20
20
  var supportSticky = cssSupport('position', 'sticky');
21
21
  var defaultZIndex = 900;
22
- var getFirstScrollParent = function getFirstScrollParent(el) {
23
- var parent = el.parentNode;
24
- while (parent) {
25
- if (parent === document.body || parent === document.documentElement) {
26
- parent = document.body;
27
- break;
28
- }
29
- var _window$getComputedSt = window.getComputedStyle(parent),
30
- overflowY = _window$getComputedSt.overflowY;
31
- if (overflowY === 'scroll' || overflowY === 'auto') {
32
- break;
33
- }
34
- parent = parent.parentNode;
35
- }
36
- return parent;
37
- };
22
+
23
+ // const getFirstScrollParent = (el: HTMLElement) => {
24
+ // let parent = el.parentNode as HTMLElement;
25
+ // while (parent) {
26
+ // if (parent === document.body || parent === document.documentElement) {
27
+ // parent = document.body;
28
+ // break;
29
+ // }
30
+ // const { overflowY } = window.getComputedStyle(parent);
31
+ // if (overflowY === 'scroll' || overflowY === 'auto') {
32
+ // break;
33
+ // }
34
+ // parent = parent.parentNode as HTMLElement;
35
+ // }
36
+ // return parent;
37
+ // };
38
+
38
39
  var Sticky = function Sticky(props) {
39
40
  var _props$style;
40
- var css = props.css,
41
- children = props.children,
41
+ var children = props.children,
42
42
  top = props.top,
43
43
  bottom = props.bottom;
44
+ var css = props.css || props.target;
44
45
  var _useRef = useRef({
45
46
  target: null,
46
47
  div: null,
@@ -68,15 +69,15 @@ var Sticky = function Sticky(props) {
68
69
  timer: 0
69
70
  });
70
71
  var getTarget = function getTarget() {
71
- var target = props.target;
72
- if (typeof props.target === 'string') {
73
- target = document.querySelector(props.target);
72
+ var scrollContainer = props.scrollContainer;
73
+ if (typeof scrollContainer === 'string') {
74
+ scrollContainer = document.querySelector(scrollContainer);
74
75
  }
75
76
  // 判断是否是dom元素
76
- if (target && target.nodeType === 1) {
77
- return target;
77
+ if (scrollContainer && scrollContainer.nodeType === 1) {
78
+ return scrollContainer;
78
79
  }
79
- return getFirstScrollParent(elementRef.current);
80
+ return document.body;
80
81
  };
81
82
  var updateStyle = usePersistFn(function () {
82
83
  if (context.div && !context.isTop && show) {
@@ -172,7 +173,7 @@ var Sticky = function Sticky(props) {
172
173
  };
173
174
  var createObserver = function createObserver() {
174
175
  var target = getTarget();
175
- if (!context.div) {
176
+ if (!context.div && target !== document.body) {
176
177
  context.div = document.createElement('div');
177
178
  context.div.style.position = 'relative';
178
179
  }
@@ -180,18 +181,21 @@ var Sticky = function Sticky(props) {
180
181
  forceRender();
181
182
  context.target = target;
182
183
  cleanEvents();
183
- if (target === document.body) {
184
- document.body.appendChild(context.div);
185
- } else {
186
- target.parentNode.insertBefore(context.div, target);
187
- }
188
- var _style4 = window.getComputedStyle(target);
189
- if (_style4.position === 'absolute' || _style4.position === 'fixed') {
190
- context.div.style.position = _style4.position;
191
- context.div.style.top = _style4.top;
192
- context.div.style.left = _style4.left;
193
- context.div.style.right = _style4.right;
194
- context.div.style.bottom = _style4.bottom;
184
+ if (context.div) {
185
+ // append div
186
+ if (target === document.body) {
187
+ document.body.appendChild(context.div);
188
+ } else {
189
+ target.parentNode.insertBefore(context.div, target);
190
+ }
191
+ var _style4 = window.getComputedStyle(target);
192
+ if (_style4.position === 'absolute' || _style4.position === 'fixed') {
193
+ context.div.style.position = _style4.position;
194
+ context.div.style.top = _style4.top;
195
+ context.div.style.left = _style4.left;
196
+ context.div.style.right = _style4.right;
197
+ context.div.style.bottom = _style4.bottom;
198
+ }
195
199
  }
196
200
  if (window.IntersectionObserver) {
197
201
  var observer = new IntersectionObserver(handlePosition, {
@@ -268,8 +272,9 @@ var Sticky = function Sticky(props) {
268
272
  children: children
269
273
  })
270
274
  }) : null;
275
+ var isFixed = style.position === 'fixed';
271
276
  return /*#__PURE__*/_jsxs(_Fragment, {
272
- children: [context.target && context.div && /*#__PURE__*/createPortal(StickyEl, context.div), /*#__PURE__*/_jsx("div", {
277
+ children: [isFixed ? StickyEl : context.target && context.div && /*#__PURE__*/createPortal(StickyEl, context.div), /*#__PURE__*/_jsx("div", {
273
278
  className: props.className,
274
279
  style: _objectSpread(_objectSpread({}, props.style), {}, {
275
280
  opacity: show && parentVisible ? 0 : (_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.opacity
@@ -17,11 +17,15 @@ export interface StickyProps extends Pick<CommonType, 'className' | 'style'> {
17
17
  * @cn 距离底部多少偏移量触发
18
18
  */
19
19
  bottom?: number;
20
+ /**
21
+ * @deprecated use scrollContainer
22
+ */
23
+ target?: string | HTMLElement | null;
20
24
  /**
21
25
  * @en Custom attachment target. You can pass in HTMLElement or css selector. The target must be an ancestor node of the Sticky component
22
26
  * @cn 自定义附着的目标。可以传入 HTMLElement 或者 css selector,target 必须为 Sticky 组件的祖先节点
23
27
  */
24
- target?: string | HTMLElement | null;
28
+ scrollContainer?: string | HTMLElement | null;
25
29
  /**
26
30
  * @cn sticky 父级元素, 当父元素离开视窗时,sticky 将失效
27
31
  * @en sticky parent, when the parent element leaves the viewport, the sticky will be invalid
@@ -1 +1 @@
1
- {"version":3,"file":"sticky.type.d.ts","sourceRoot":"","sources":["sticky.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC;IAC1E,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,MAAM,aAAa,CAAC;KAC7B,CAAC;IAEF;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
1
+ {"version":3,"file":"sticky.type.d.ts","sourceRoot":"","sources":["sticky.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC;IAC1E,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,MAAM,aAAa,CAAC;KAC7B,CAAC;IAEF;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAE9C;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.0.0-rc.4",
3
+ "version": "3.0.0-rc.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "ISC",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.0.0-rc.4",
13
+ "@sheinx/hooks": "3.0.0-rc.5",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.2"