@helpdice/ui 2.0.9 → 2.1.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.
Files changed (64) hide show
  1. package/dist/AutoComplete/auto-complete.d.ts +1 -1
  2. package/dist/AutoComplete/index.js +1 -1
  3. package/dist/ButtonDropdown/index.js +2 -1
  4. package/dist/Carousal/component/Indicator.d.ts +1 -0
  5. package/dist/Carousal/component/Thumbs.d.ts +1 -1
  6. package/dist/Carousal/component/index.d.ts +1 -1
  7. package/dist/Carousal/component/types.d.ts +4 -3
  8. package/dist/Carousal/index.js +88 -38
  9. package/dist/Form/types.d.ts +2 -2
  10. package/dist/Grid/grid-container.d.ts +14 -0
  11. package/dist/Grid/grid.d.ts +14 -0
  12. package/dist/Input/index.js +1 -1
  13. package/dist/Popover/index.js +1 -1
  14. package/dist/Rating/rating.d.ts +1 -1
  15. package/dist/Select/index.js +6 -4
  16. package/dist/Table/index.js +8 -6
  17. package/dist/Table/table-types.d.ts +1 -1
  18. package/dist/Text/child.d.ts +1 -1
  19. package/dist/Textarea/index.js +1 -1
  20. package/dist/Tooltip/index.js +1 -1
  21. package/dist/Tree/index.js +3 -1
  22. package/dist/Tree/tree-help.d.ts +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +250 -61
  25. package/dist/use-toasts/helpers.d.ts +17 -0
  26. package/dist/use-toasts/index.d.ts +3 -0
  27. package/dist/use-toasts/index.js +204 -0
  28. package/dist/use-toasts/use-toast.d.ts +40 -0
  29. package/dist/utils/use-drag.d.ts +1 -1
  30. package/dist/utils/use-hd-ui-context.d.ts +16 -0
  31. package/esm/AutoComplete/auto-complete.d.ts +1 -1
  32. package/esm/Carousal/component/Indicator.d.ts +1 -0
  33. package/esm/Carousal/component/Indicator.js +56 -13
  34. package/esm/Carousal/component/Thumbs.d.ts +1 -1
  35. package/esm/Carousal/component/Thumbs.js +3 -3
  36. package/esm/Carousal/component/index.d.ts +1 -1
  37. package/esm/Carousal/component/index.js +29 -22
  38. package/esm/Carousal/component/types.d.ts +4 -3
  39. package/esm/Carousal/main.js +42 -59
  40. package/esm/Form/types.d.ts +2 -2
  41. package/esm/Grid/grid-container.d.ts +14 -0
  42. package/esm/Grid/grid.d.ts +14 -0
  43. package/esm/Rating/rating.d.ts +1 -1
  44. package/esm/Select/select.js +4 -3
  45. package/esm/Table/table-types.d.ts +1 -1
  46. package/esm/Text/child.d.ts +1 -1
  47. package/esm/Textarea/textarea.js +1 -1
  48. package/esm/Tooltip/tooltip.js +1 -1
  49. package/esm/Tree/tree-help.d.ts +1 -1
  50. package/esm/Tree/tree-help.js +3 -1
  51. package/esm/index.d.ts +2 -0
  52. package/esm/index.js +2 -1
  53. package/esm/use-toasts/helpers.d.ts +17 -0
  54. package/esm/use-toasts/helpers.js +69 -0
  55. package/esm/use-toasts/index.d.ts +3 -0
  56. package/esm/use-toasts/index.js +2 -0
  57. package/esm/use-toasts/toast-container.js +118 -0
  58. package/esm/use-toasts/toast-item.js +42 -0
  59. package/esm/use-toasts/use-toast.d.ts +40 -0
  60. package/esm/use-toasts/use-toast.js +103 -0
  61. package/esm/utils/collections.js +2 -1
  62. package/esm/utils/use-drag.d.ts +1 -1
  63. package/esm/utils/use-hd-ui-context.d.ts +16 -0
  64. package/package.json +17 -15
@@ -0,0 +1,204 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _arrayLikeToArray(r, a) {
8
+ (null == a || a > r.length) && (a = r.length);
9
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
+ return n;
11
+ }
12
+ function _arrayWithoutHoles(r) {
13
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
14
+ }
15
+ function _defineProperty(e, r, t) {
16
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
17
+ value: t,
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true
21
+ }) : e[r] = t, e;
22
+ }
23
+ function _iterableToArray(r) {
24
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
25
+ }
26
+ function _nonIterableSpread() {
27
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
28
+ }
29
+ function ownKeys(e, r) {
30
+ var t = Object.keys(e);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var o = Object.getOwnPropertySymbols(e);
33
+ r && (o = o.filter(function (r) {
34
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
35
+ })), t.push.apply(t, o);
36
+ }
37
+ return t;
38
+ }
39
+ function _objectSpread2(e) {
40
+ for (var r = 1; r < arguments.length; r++) {
41
+ var t = null != arguments[r] ? arguments[r] : {};
42
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
43
+ _defineProperty(e, r, t[r]);
44
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
45
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
46
+ });
47
+ }
48
+ return e;
49
+ }
50
+ function _toConsumableArray(r) {
51
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
52
+ }
53
+ function _toPrimitive(t, r) {
54
+ if ("object" != typeof t || !t) return t;
55
+ var e = t[Symbol.toPrimitive];
56
+ if (void 0 !== e) {
57
+ var i = e.call(t, r);
58
+ if ("object" != typeof i) return i;
59
+ throw new TypeError("@@toPrimitive must return a primitive value.");
60
+ }
61
+ return ("string" === r ? String : Number)(t);
62
+ }
63
+ function _toPropertyKey(t) {
64
+ var i = _toPrimitive(t, "string");
65
+ return "symbol" == typeof i ? i : i + "";
66
+ }
67
+ function _unsupportedIterableToArray(r, a) {
68
+ if (r) {
69
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
70
+ var t = {}.toString.call(r).slice(8, -1);
71
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
72
+ }
73
+ }
74
+
75
+ var defaultToastLayout = {
76
+ padding: '12px 16px',
77
+ margin: '8px 0',
78
+ width: '420px',
79
+ maxWidth: '90vw',
80
+ maxHeight: '75px',
81
+ placement: 'bottomRight'
82
+ };
83
+ var defaultParams = {
84
+ toasts: [],
85
+ toastLayout: defaultToastLayout,
86
+ updateToastLayout: function updateToastLayout(t) {
87
+ return t;
88
+ },
89
+ updateToasts: function updateToasts(t) {
90
+ return t;
91
+ },
92
+ lastUpdateToastId: null,
93
+ updateLastToastId: function updateLastToastId() {
94
+ return null;
95
+ }
96
+ };
97
+ var HUIContent = /*#__PURE__*/React.createContext(defaultParams);
98
+ var useHUIContext = function useHUIContext() {
99
+ return React.useContext(HUIContent);
100
+ };
101
+
102
+ /* "use client" */
103
+
104
+ var getId = function getId() {
105
+ return Math.random().toString(32).slice(2, 10);
106
+ };
107
+
108
+ var defaultToast = {
109
+ delay: 2000,
110
+ type: 'default'
111
+ };
112
+ var useToasts = function useToasts(layout) {
113
+ var _useHUIContext = useHUIContext(),
114
+ updateToasts = _useHUIContext.updateToasts,
115
+ toasts = _useHUIContext.toasts,
116
+ updateToastLayout = _useHUIContext.updateToastLayout,
117
+ updateLastToastId = _useHUIContext.updateLastToastId;
118
+ React.useEffect(function () {
119
+ if (!layout) return;
120
+ updateToastLayout(function () {
121
+ return layout ? _objectSpread2(_objectSpread2({}, defaultToastLayout), layout) : defaultToastLayout;
122
+ });
123
+ }, []);
124
+ var _cancel = function cancel(internalId) {
125
+ updateToasts(function (currentToasts) {
126
+ return currentToasts.map(function (item) {
127
+ if (item._internalIdent !== internalId) return item;
128
+ return _objectSpread2(_objectSpread2({}, item), {}, {
129
+ visible: false
130
+ });
131
+ });
132
+ });
133
+ updateLastToastId(function () {
134
+ return internalId;
135
+ });
136
+ };
137
+ var removeAll = function removeAll() {
138
+ updateToasts(function (last) {
139
+ return last.map(function (toast) {
140
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
141
+ visible: false
142
+ });
143
+ });
144
+ });
145
+ };
146
+ var findToastOneByID = function findToastOneByID(id) {
147
+ return toasts.find(function (t) {
148
+ return t.id === id;
149
+ });
150
+ };
151
+ var removeToastOneByID = function removeToastOneByID(id) {
152
+ updateToasts(function (last) {
153
+ return last.map(function (toast) {
154
+ if (toast.id !== id) return toast;
155
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
156
+ visible: false
157
+ });
158
+ });
159
+ });
160
+ };
161
+ var setToast = function setToast(toast) {
162
+ var internalIdent = "toast-".concat(getId());
163
+ var delay = toast.delay || defaultToast.delay;
164
+ if (toast.id) {
165
+ var hasIdent = toasts.find(function (t) {
166
+ return t.id === toast.id;
167
+ });
168
+ if (hasIdent) {
169
+ throw new Error('Toast: Already have the same key: "ident"');
170
+ }
171
+ }
172
+ updateToasts(function (last) {
173
+ var newToast = {
174
+ delay: delay,
175
+ text: toast.text,
176
+ visible: true,
177
+ type: toast.type || defaultToast.type,
178
+ id: toast.id || internalIdent,
179
+ actions: toast.actions || [],
180
+ _internalIdent: internalIdent,
181
+ _timeout: window.setTimeout(function () {
182
+ _cancel(internalIdent);
183
+ if (newToast._timeout) {
184
+ window.clearTimeout(newToast._timeout);
185
+ newToast._timeout = null;
186
+ }
187
+ }, delay),
188
+ cancel: function cancel() {
189
+ return _cancel(internalIdent);
190
+ }
191
+ };
192
+ return [].concat(_toConsumableArray(last), [newToast]);
193
+ });
194
+ };
195
+ return {
196
+ toasts: toasts,
197
+ setToast: setToast,
198
+ removeAll: removeAll,
199
+ findToastOneByID: findToastOneByID,
200
+ removeToastOneByID: removeToastOneByID
201
+ };
202
+ };
203
+
204
+ exports.default = useToasts;
@@ -0,0 +1,40 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import type { NormalTypes } from '../utils/prop-types';
3
+ import { ToastPlacement } from '../use-toasts/helpers';
4
+ export interface ToastAction {
5
+ name: string;
6
+ handler: (event: React.MouseEvent<HTMLButtonElement>, cancel: () => void) => void;
7
+ passive?: boolean;
8
+ }
9
+ export type ToastTypes = NormalTypes;
10
+ export type ToastLayout = {
11
+ padding?: CSSProperties['padding'];
12
+ margin?: CSSProperties['margin'];
13
+ width?: CSSProperties['width'];
14
+ maxWidth?: CSSProperties['maxWidth'];
15
+ maxHeight?: CSSProperties['maxHeight'];
16
+ placement?: ToastPlacement;
17
+ };
18
+ export interface ToastInput {
19
+ text: string | React.ReactNode;
20
+ type?: ToastTypes;
21
+ id?: string;
22
+ delay?: number;
23
+ actions?: Array<ToastAction>;
24
+ }
25
+ export type ToastInstance = {
26
+ visible: boolean;
27
+ cancel: () => void;
28
+ _timeout: null | number;
29
+ _internalIdent: string;
30
+ };
31
+ export type Toast = Required<ToastInput> & ToastInstance;
32
+ export type ToastHooksResult = {
33
+ toasts: Array<Toast>;
34
+ setToast: (toast: ToastInput) => void;
35
+ removeAll: () => void;
36
+ findToastOneByID: (ident: string) => Toast | undefined;
37
+ removeToastOneByID: (ident: string) => void;
38
+ };
39
+ declare const useToasts: (layout?: ToastLayout) => ToastHooksResult;
40
+ export default useToasts;
@@ -4,5 +4,5 @@ export type DraggingEvent = {
4
4
  currentX: number;
5
5
  };
6
6
  export type DraggingHandler = (event: DraggingEvent) => void;
7
- declare const useDrag: (elementRef: RefObject<HTMLElement> | null, draggingHandler?: DraggingHandler, dragStartHandler?: DraggingHandler, dragEndHandler?: DraggingHandler) => void;
7
+ declare const useDrag: (elementRef: RefObject<HTMLElement | null>, draggingHandler?: DraggingHandler, dragStartHandler?: DraggingHandler, dragEndHandler?: DraggingHandler) => void;
8
8
  export default useDrag;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { ToastLayout, Toast } from '@helpdice/theme';
3
+ export declare const defaultToastLayout: Required<ToastLayout>;
4
+ export type UpdateToastsFunction = (fn: (toasts: Array<Toast>) => Array<Toast>) => any;
5
+ export type UpdateToastsLayoutFunction = (fn: (layout: Required<ToastLayout>) => Required<ToastLayout>) => any;
6
+ export type UpdateToastsIDFunction = (fn: () => string | null) => any;
7
+ export interface HUIContextParams {
8
+ toasts: Array<Toast>;
9
+ updateToasts: UpdateToastsFunction;
10
+ toastLayout: Required<ToastLayout>;
11
+ updateToastLayout: UpdateToastsLayoutFunction;
12
+ lastUpdateToastId: string | null;
13
+ updateLastToastId: UpdateToastsIDFunction;
14
+ }
15
+ export declare const HUIContent: React.Context<HUIContextParams>;
16
+ export declare const useHUIContext: () => HUIContextParams;
@@ -27,7 +27,7 @@ interface Props {
27
27
  }
28
28
  type NativeAttrs = Omit<React.InputHTMLAttributes<any>, keyof Props>;
29
29
  export type AutoCompleteProps = Props & NativeAttrs & ReactElement;
30
- declare const AutoComplete: React.ForwardRefExoticComponent<Omit<Props & NativeAttrs & React.ReactElement<any, string | React.JSXElementConstructor<any>> & {
30
+ declare const AutoComplete: React.ForwardRefExoticComponent<Omit<Props & NativeAttrs & React.ReactElement<unknown, string | React.JSXElementConstructor<any>> & {
31
31
  children?: React.ReactNode | undefined;
32
32
  } & React.RefAttributes<HTMLInputElement> & {
33
33
  width?: string | number;
@@ -4,6 +4,7 @@ interface IndicatorProps {
4
4
  isSelected: boolean;
5
5
  index: number;
6
6
  label: string;
7
+ type: string;
7
8
  }
8
9
  declare const Indicator: React.FC<IndicatorProps>;
9
10
  export default Indicator;
@@ -6,18 +6,61 @@ var Indicator = function Indicator(_ref) {
6
6
  var onClickHandler = _ref.onClickHandler,
7
7
  isSelected = _ref.isSelected,
8
8
  index = _ref.index,
9
- label = _ref.label;
10
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
11
- onClick: onClickHandler,
12
- onKeyDown: onClickHandler,
13
- value: index,
14
- key: index,
15
- role: "button",
16
- tabIndex: 0,
17
- "aria-label": "".concat(label, " ").concat(index + 1),
18
- className: "jsx-3056554148" + " " + (klass.DOT(isSelected) || "")
19
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
20
- id: "3056554148"
21
- }, ".dot.jsx-3056554148{-webkit-transition:opacity 0.25s ease-in;transition:opacity 0.25s ease-in;opacity:0.3;box-shadow:1px 1px 2px rgba(0,0,0,0.9);background:#fff;border-radius:50%;width:8px;height:8px;cursor:pointer;display:inline-block;margin:0 8px;}.dot.selected.jsx-3056554148,.dot.jsx-3056554148:hover{opacity:1;}"));
9
+ label = _ref.label,
10
+ type = _ref.type;
11
+ switch (type) {
12
+ case 'line':
13
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
14
+ onClick: onClickHandler,
15
+ onKeyDown: onClickHandler,
16
+ value: index,
17
+ key: index,
18
+ role: "button",
19
+ tabIndex: 0,
20
+ "aria-label": "".concat(label, " ").concat(index + 1),
21
+ className: "jsx-110677664" + " " + (klass.DOT(isSelected) || "")
22
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
23
+ id: "110677664"
24
+ }, ".dot.jsx-110677664{-webkit-transition:opacity 0.25s ease-in;transition:opacity 0.25s ease-in;opacity:0.3;box-shadow:1px 1px 2px rgba(0,0,0,0.9);background:#fff;width:14px;height:2px;cursor:pointer;display:inline-block;margin:0 8px;}.dot.selected.jsx-110677664,.dot.jsx-110677664:hover{opacity:1;}"));
25
+ case 'square':
26
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
27
+ onClick: onClickHandler,
28
+ onKeyDown: onClickHandler,
29
+ value: index,
30
+ key: index,
31
+ role: "button",
32
+ tabIndex: 0,
33
+ "aria-label": "".concat(label, " ").concat(index + 1),
34
+ className: "jsx-157344968" + " " + (klass.DOT(isSelected) || "")
35
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
36
+ id: "157344968"
37
+ }, ".dot.jsx-157344968{-webkit-transition:opacity 0.25s ease-in;transition:opacity 0.25s ease-in;opacity:0.3;box-shadow:1px 1px 2px rgba(0,0,0,0.9);background:#fff;width:8px;height:8px;cursor:pointer;display:inline-block;margin:0 8px;}.dot.selected.jsx-157344968,.dot.jsx-157344968:hover{opacity:1;}"));
38
+ case 'pill':
39
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
40
+ onClick: onClickHandler,
41
+ onKeyDown: onClickHandler,
42
+ value: index,
43
+ key: index,
44
+ role: "button",
45
+ tabIndex: 0,
46
+ "aria-label": "".concat(label, " ").concat(index + 1),
47
+ className: "jsx-2836895747" + " " + (klass.DOT(isSelected) || "")
48
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
49
+ id: "2836895747"
50
+ }, ".dot.jsx-2836895747{-webkit-transition:opacity 0.25s ease-in;transition:opacity 0.25s ease-in;opacity:0.3;box-shadow:1px 1px 2px rgba(0,0,0,0.9);background:#fff;border-radius:25px;width:20px;height:5px;cursor:pointer;display:inline-block;margin:0 8px;}.dot.selected.jsx-2836895747,.dot.jsx-2836895747:hover{opacity:1;}"));
51
+ default:
52
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
53
+ onClick: onClickHandler,
54
+ onKeyDown: onClickHandler,
55
+ value: index,
56
+ key: index,
57
+ role: "button",
58
+ tabIndex: 0,
59
+ "aria-label": "".concat(label, " ").concat(index + 1),
60
+ className: "jsx-3056554148" + " " + (klass.DOT(isSelected) || "")
61
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
62
+ id: "3056554148"
63
+ }, ".dot.jsx-3056554148{-webkit-transition:opacity 0.25s ease-in;transition:opacity 0.25s ease-in;opacity:0.3;box-shadow:1px 1px 2px rgba(0,0,0,0.9);background:#fff;border-radius:50%;width:8px;height:8px;cursor:pointer;display:inline-block;margin:0 8px;}.dot.selected.jsx-3056554148,.dot.jsx-3056554148:hover{opacity:1;}"));
64
+ }
22
65
  };
23
66
  export default Indicator;
@@ -1,7 +1,7 @@
1
1
  import React, { Component } from 'react';
2
2
  export interface Props {
3
3
  axis: 'horizontal' | 'vertical';
4
- children: React.ReactChild[];
4
+ children: React.ReactNode[];
5
5
  labels: {
6
6
  leftArrow: string;
7
7
  rightArrow: string;
@@ -215,10 +215,10 @@ var Thumbs = /*#__PURE__*/function (_Component) {
215
215
  return /*#__PURE__*/React.createElement("li", _extends({}, thumbProps, {
216
216
  role: "button",
217
217
  tabIndex: 0,
218
- className: "jsx-2129274269" + " " + (thumbProps && thumbProps.className != null && thumbProps.className || "")
218
+ className: "jsx-2625056898" + " " + (thumbProps && thumbProps.className != null && thumbProps.className || "")
219
219
  }), img, /*#__PURE__*/React.createElement(_JSXStyle, {
220
- id: "2129274269"
221
- }, ".thumb.jsx-2129274269{-webkit-transition:border 0.15s ease-in;transition:border 0.15s ease-in;display:inline-block;margin-right:6px;margin-bottom:0 !important;white-space:nowrap;overflow:hidden;border:3px solid #fff;padding:2px;}.thumb.jsx-2129274269:focus{border:3px solid #ccc;outline:none;}.thumb.selected.jsx-2129274269,.thumb.jsx-2129274269:hover{border:3px solid #0099ff;}.thumb.jsx-2129274269 img.jsx-2129274269{vertical-align:top;}"));
220
+ id: "2625056898"
221
+ }, ".thumb.jsx-2625056898{-webkit-transition:border 0.15s ease-in;transition:border 0.15s ease-in;display:inline-block;margin-right:6px;margin-bottom:0 !important;white-space:nowrap;overflow:hidden;border:3px solid #fff;padding:2px;}.thumb.jsx-2625056898:focus{border:3px solid #ccc;outline:none;}.thumb.selected.jsx-2625056898,.thumb.jsx-2625056898:hover{border:3px solid #0099ff;}.thumb.jsx-2625056898 img.jsx-2625056898{vertical-align:top;}"));
222
222
  });
223
223
  }
224
224
  }, {
@@ -79,7 +79,7 @@ export default class Carousel extends React.Component<CarouselProps, CarouselSta
79
79
  selectItem: (state: Pick<CarouselState, "selectedItem" | "swiping">) => void;
80
80
  getInitialImage: () => HTMLImageElement;
81
81
  getVariableItemHeight: (position: number) => number | null;
82
- renderItems(isClone?: boolean): React.JSX.Element[];
82
+ renderItems(isClone?: boolean): React.JSX.Element[] | null | undefined;
83
83
  renderControls(): React.JSX.Element | null;
84
84
  renderStatus(): React.JSX.Element | null;
85
85
  renderThumbs(): React.JSX.Element | null;
@@ -311,7 +311,8 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
311
311
  itemListStyle: {},
312
312
  slideStyle: {},
313
313
  selectedStyle: {},
314
- prevStyle: {}
314
+ prevStyle: {},
315
+ indicator: 'dot'
315
316
  };
316
317
  _this.animationHandler = typeof props.animationHandler === 'function' && props.animationHandler || props.animationHandler === 'fade' && fadeAnimationHandler || slideAnimationHandler;
317
318
  _this.state = _extends({}, initState, _this.animationHandler(props, initState));
@@ -474,13 +475,13 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
474
475
  style: style
475
476
  };
476
477
  return /*#__PURE__*/React.createElement("li", _extends({}, slideProps, {
477
- className: "jsx-2755164558" + " " + (slideProps && slideProps.className != null && slideProps.className || "")
478
+ className: "jsx-4120978495" + " " + (slideProps && slideProps.className != null && slideProps.className || "")
478
479
  }), _this3.props.renderItem(item, {
479
480
  isSelected: index === _this3.state.selectedItem,
480
481
  isPrevious: index === _this3.state.previousItem
481
482
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
482
- id: "2755164558"
483
- }, ".slide.jsx-2755164558{min-width:100%;margin:0;position:relative;text-align:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}img.jsx-2755164558{width:100%;vertical-align:top;border:0;}iframe.jsx-2755164558{display:inline-block;width:calc(100% - 80px);margin:0 40px 40px;border:0;}.legend.jsx-2755164558{-webkit-transition:opacity 0.35s ease-in-out;transition:opacity 0.35s ease-in-out;position:absolute;bottom:40px;left:50%;margin-left:-45%;width:90%;border-radius:10px;background:#000;color:#fff;padding:10px;font-size:12px;text-align:center;opacity:0.25;}.slide.jsx-2755164558 .legend.jsx-2755164558{opacity:1;}"));
483
+ id: "4120978495"
484
+ }, ".slide.jsx-4120978495{min-width:100%;margin:0;position:relative;text-align:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}img.jsx-4120978495{width:100%;vertical-align:top;border:0;}iframe.jsx-4120978495{display:inline-block;width:calc(100% - 80px);margin:0 40px 40px;border:0;}.legend.jsx-4120978495{-webkit-transition:opacity 0.35s ease-in-out;transition:opacity 0.35s ease-in-out;position:absolute;bottom:40px;left:50%;margin-left:-45%;width:90%;border-radius:10px;background:#000;color:#fff;padding:10px;font-size:12px;text-align:center;opacity:0.25;}.slide.jsx-4120978495 .legend.jsx-4120978495{opacity:1;}"));
484
485
  });
485
486
  }
486
487
  }, {
@@ -491,14 +492,15 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
491
492
  showIndicators = _this$props.showIndicators,
492
493
  labels = _this$props.labels,
493
494
  renderIndicator = _this$props.renderIndicator,
494
- children = _this$props.children;
495
+ children = _this$props.children,
496
+ indicator = _this$props.indicator;
495
497
  if (!showIndicators) {
496
498
  return null;
497
499
  }
498
500
  return /*#__PURE__*/React.createElement("ul", {
499
501
  className: "jsx-4140983776" + " " + "control-dots"
500
502
  }, Children.map(children, function (_, index) {
501
- return renderIndicator && renderIndicator(_this4.changeItem(index), index === _this4.state.selectedItem, index, labels.item);
503
+ return renderIndicator && renderIndicator(_this4.changeItem(index), index === _this4.state.selectedItem, index, labels.item, indicator);
502
504
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
503
505
  id: "4140983776"
504
506
  }, ".control-dots.jsx-4140983776{position:absolute;bottom:0;margin:10px 0;padding:0;text-align:center;width:100%;z-index:1;}"));
@@ -547,8 +549,9 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
547
549
  // show right arrow
548
550
  var hasNext = canShowArrows && (this.state.selectedItem < Children.count(this.props.children) - 1 || this.props.infiniteLoop) || false;
549
551
  var itemsClone = this.renderItems(true);
550
- var firstClone = itemsClone.shift();
551
- var lastClone = itemsClone.pop();
552
+ var firstClone = itemsClone.shift(); // added not null
553
+ var lastClone = itemsClone.pop(); // added not null
554
+
552
555
  var swiperProps = {
553
556
  className: klass.SLIDER(true, this.state.swiping),
554
557
  onSwipeMove: this.onSwipeMove,
@@ -645,8 +648,9 @@ _defineProperty(Carousel, "defaultProps", {
645
648
  label: label
646
649
  });
647
650
  },
648
- renderIndicator: function renderIndicator(onClickHandler, isSelected, index, label) {
651
+ renderIndicator: function renderIndicator(onClickHandler, isSelected, index, label, type) {
649
652
  return /*#__PURE__*/React.createElement(Indicator, {
653
+ type: type,
650
654
  onClickHandler: onClickHandler,
651
655
  isSelected: isSelected,
652
656
  index: index,
@@ -658,26 +662,28 @@ _defineProperty(Carousel, "defaultProps", {
658
662
  },
659
663
  renderThumbs: function renderThumbs(children) {
660
664
  var images = Children.map(children, function (item) {
661
- var img = item;
665
+ var _item = item;
666
+ if (! /*#__PURE__*/React.isValidElement(_item)) return undefined;
662
667
 
663
- // if the item is not an image, try to find the first image in the item's children.
664
- if (item.type !== 'img') {
665
- img = Children.toArray(item.props.children).find(function (children) {
666
- return children.type === 'img';
667
- });
668
- }
669
- if (!img) {
670
- return undefined;
668
+ // Directly an <img> element
669
+ if (_item.type === 'img') {
670
+ return item;
671
671
  }
672
- return img;
672
+
673
+ // If not <img>, search its children
674
+ var childArray = Children.toArray(_item.props.children);
675
+ var foundImg = childArray.find(function (child) {
676
+ return /*#__PURE__*/React.isValidElement(child) && child.type === 'img';
677
+ });
678
+ return foundImg !== null && foundImg !== void 0 ? foundImg : undefined;
673
679
  });
674
- if (images.filter(function (image) {
680
+ if ((images === null || images === void 0 ? void 0 : images.filter(function (image) {
675
681
  return image;
676
- }).length === 0) {
682
+ }).length) === 0) {
677
683
  console.warn("No images found! Can't build the thumb list without images. If you don't need thumbs, set showThumbs={false} in the Carousel. Note that it's not possible to get images rendered inside custom components. More info at https://github.com/leandrowd/react-responsive-carousel/blob/master/TROUBLESHOOTING.md");
678
684
  return [];
679
685
  }
680
- return images;
686
+ return images !== null && images !== void 0 ? images : [];
681
687
  },
682
688
  statusFormatter: defaultStatusFormatter,
683
689
  selectedItem: 0,
@@ -691,6 +697,7 @@ _defineProperty(Carousel, "defaultProps", {
691
697
  transitionTime: 350,
692
698
  verticalSwipe: 'standard',
693
699
  width: '100%',
700
+ indicator: 'dot',
694
701
  animationHandler: 'slide',
695
702
  swipeAnimationHandler: slideSwipeAnimationHandler,
696
703
  stopSwipingHandler: slideStopSwipingHandler
@@ -17,7 +17,7 @@ export interface CarouselProps {
17
17
  autoPlay?: boolean;
18
18
  centerMode?: boolean;
19
19
  centerSlidePercentage: number;
20
- children?: React.ReactChild[];
20
+ children?: React.ReactNode[];
21
21
  className?: string;
22
22
  dynamicHeight?: boolean;
23
23
  emulateTouch?: boolean;
@@ -37,16 +37,17 @@ export interface CarouselProps {
37
37
  preventMovementUntilSwipeScrollTolerance: boolean;
38
38
  renderArrowPrev: (clickHandler: () => void, hasPrev: boolean, label: string) => React.ReactNode;
39
39
  renderArrowNext: (clickHandler: () => void, hasNext: boolean, label: string) => React.ReactNode;
40
- renderIndicator: (clickHandler: (e: React.MouseEvent | React.KeyboardEvent) => void, isSelected: boolean, index: number, label: string) => React.ReactNode;
40
+ renderIndicator: (clickHandler: (e: React.MouseEvent | React.KeyboardEvent) => void, isSelected: boolean, index: number, label: string, type: string) => React.ReactNode;
41
41
  renderItem: (item: React.ReactNode, options?: {
42
42
  isSelected: boolean;
43
43
  isPrevious: boolean;
44
44
  }) => React.ReactNode;
45
- renderThumbs: (children: React.ReactChild[]) => React.ReactChild[];
45
+ renderThumbs: (children: React.ReactNode[]) => React.ReactNode[];
46
46
  selectedItem: number;
47
47
  showArrows: boolean;
48
48
  showStatus: boolean;
49
49
  showIndicators: boolean;
50
+ indicator: string;
50
51
  showThumbs: boolean;
51
52
  statusFormatter: (currentItem: number, total: number) => string;
52
53
  stopOnHover: boolean;
@@ -1,59 +1,42 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import(/* webpackChunkName: "carousel-component" */'./component').then(function (_ref) {
4
- var Carousel = _ref["default"];
5
- var DemoCarousel = function DemoCarousel() {
6
- return /*#__PURE__*/React.createElement(Carousel, {
7
- showArrows: true,
8
- infiniteLoop: true,
9
- autoPlay: true,
10
- emulateTouch: true,
11
- onClickItem: function onClickItem() {
12
- var _console;
13
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14
- args[_key] = arguments[_key];
15
- }
16
- return (_console = console).log.apply(_console, ['onClickItem'].concat(args));
17
- },
18
- onChange: function onChange() {
19
- var _console2;
20
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
21
- args[_key2] = arguments[_key2];
22
- }
23
- return (_console2 = console).log.apply(_console2, ['onChange'].concat(args));
24
- },
25
- onClickThumb: function onClickThumb() {
26
- var _console3;
27
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
28
- args[_key3] = arguments[_key3];
29
- }
30
- return (_console3 = console).log.apply(_console3, ['onClickThumb'].concat(args));
31
- }
32
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
33
- src: "assets/1.jpeg"
34
- }), /*#__PURE__*/React.createElement("p", {
35
- className: "legend"
36
- }, "Legend 1")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
37
- src: "assets/2.jpeg"
38
- }), /*#__PURE__*/React.createElement("p", {
39
- className: "legend"
40
- }, "Legend 2")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
41
- src: "assets/3.jpeg"
42
- }), /*#__PURE__*/React.createElement("p", {
43
- className: "legend"
44
- }, "Legend 3")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
45
- src: "assets/4.jpeg"
46
- }), /*#__PURE__*/React.createElement("p", {
47
- className: "legend"
48
- }, "Legend 4")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
49
- src: "assets/5.jpeg"
50
- }), /*#__PURE__*/React.createElement("p", {
51
- className: "legend"
52
- }, "Legend 5")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
53
- src: "assets/6.jpeg"
54
- }), /*#__PURE__*/React.createElement("p", {
55
- className: "legend"
56
- }, "Legend 6")));
57
- };
58
- ReactDOM.render(/*#__PURE__*/React.createElement(DemoCarousel, null), document.querySelector('.demo-carousel'));
59
- });
1
+ // import React from 'react';
2
+ // import ReactDOM from 'react-dom';
3
+
4
+ // import(/* webpackChunkName: "carousel-component" */ './component').then(({ default: Carousel }) => {
5
+ // const DemoCarousel = () => (
6
+ // <Carousel
7
+ // showArrows
8
+ // infiniteLoop
9
+ // autoPlay
10
+ // emulateTouch
11
+ // onClickItem={(...args) => console.log('onClickItem', ...args)}
12
+ // onChange={(...args) => console.log('onChange', ...args)}
13
+ // onClickThumb={(...args) => console.log('onClickThumb', ...args)}
14
+ // >
15
+ // <div>
16
+ // <img src="assets/1.jpeg" />
17
+ // <p className="legend">Legend 1</p>
18
+ // </div>
19
+ // <div>
20
+ // <img src="assets/2.jpeg" />
21
+ // <p className="legend">Legend 2</p>
22
+ // </div>
23
+ // <div>
24
+ // <img src="assets/3.jpeg" />
25
+ // <p className="legend">Legend 3</p>
26
+ // </div>
27
+ // <div>
28
+ // <img src="assets/4.jpeg" />
29
+ // <p className="legend">Legend 4</p>
30
+ // </div>
31
+ // <div>
32
+ // <img src="assets/5.jpeg" />
33
+ // <p className="legend">Legend 5</p>
34
+ // </div>
35
+ // <div>
36
+ // <img src="assets/6.jpeg" />
37
+ // <p className="legend">Legend 6</p>
38
+ // </div>
39
+ // </Carousel>
40
+ // );
41
+ // ReactDOM.render(<DemoCarousel />, document.querySelector('.demo-carousel'));
42
+ // });