@helpdice/ui 2.0.7 → 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.
- package/dist/AutoComplete/auto-complete.d.ts +1 -1
- package/dist/AutoComplete/index.js +1 -1
- package/dist/ButtonDropdown/index.js +2 -1
- package/dist/Carousal/component/Indicator.d.ts +1 -0
- package/dist/Carousal/component/Thumbs.d.ts +1 -1
- package/dist/Carousal/component/index.d.ts +1 -1
- package/dist/Carousal/component/types.d.ts +4 -3
- package/dist/Carousal/index.js +88 -38
- package/dist/Form/types.d.ts +2 -2
- package/dist/Grid/grid-container.d.ts +14 -0
- package/dist/Grid/grid.d.ts +14 -0
- package/dist/Input/index.js +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/Rating/rating.d.ts +1 -1
- package/dist/Select/index.js +6 -4
- package/dist/Table/index.js +8 -6
- package/dist/Table/table-types.d.ts +1 -1
- package/dist/Text/child.d.ts +1 -1
- package/dist/Textarea/index.js +1 -1
- package/dist/Tooltip/index.js +1 -1
- package/dist/Tree/index.js +3 -1
- package/dist/Tree/tree-help.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +250 -61
- package/dist/use-toasts/helpers.d.ts +17 -0
- package/dist/use-toasts/index.d.ts +3 -0
- package/dist/use-toasts/index.js +204 -0
- package/dist/use-toasts/use-toast.d.ts +40 -0
- package/dist/utils/use-drag.d.ts +1 -1
- package/dist/utils/use-hd-ui-context.d.ts +16 -0
- package/esm/AutoComplete/auto-complete.d.ts +1 -1
- package/esm/Carousal/component/Indicator.d.ts +1 -0
- package/esm/Carousal/component/Indicator.js +56 -13
- package/esm/Carousal/component/Thumbs.d.ts +1 -1
- package/esm/Carousal/component/Thumbs.js +3 -3
- package/esm/Carousal/component/index.d.ts +1 -1
- package/esm/Carousal/component/index.js +29 -22
- package/esm/Carousal/component/types.d.ts +4 -3
- package/esm/Carousal/main.js +42 -59
- package/esm/Form/types.d.ts +2 -2
- package/esm/Grid/grid-container.d.ts +14 -0
- package/esm/Grid/grid.d.ts +14 -0
- package/esm/Rating/rating.d.ts +1 -1
- package/esm/Select/select.js +4 -3
- package/esm/Table/table-types.d.ts +1 -1
- package/esm/Text/child.d.ts +1 -1
- package/esm/Textarea/textarea.js +1 -1
- package/esm/Tooltip/tooltip.js +1 -1
- package/esm/Tree/tree-help.d.ts +1 -1
- package/esm/Tree/tree-help.js +3 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -1
- package/esm/use-toasts/helpers.d.ts +17 -0
- package/esm/use-toasts/helpers.js +69 -0
- package/esm/use-toasts/index.d.ts +3 -0
- package/esm/use-toasts/index.js +2 -0
- package/esm/use-toasts/toast-container.js +118 -0
- package/esm/use-toasts/toast-item.js +42 -0
- package/esm/use-toasts/use-toast.d.ts +40 -0
- package/esm/use-toasts/use-toast.js +103 -0
- package/esm/utils/collections.js +2 -1
- package/esm/utils/use-drag.d.ts +1 -1
- package/esm/utils/use-hd-ui-context.d.ts +16 -0
- package/package.json +188 -57
|
@@ -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;
|
package/dist/utils/use-drag.d.ts
CHANGED
|
@@ -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
|
|
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<
|
|
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;
|
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
@@ -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-
|
|
218
|
+
className: "jsx-2625056898" + " " + (thumbProps && thumbProps.className != null && thumbProps.className || "")
|
|
219
219
|
}), img, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
220
|
-
id: "
|
|
221
|
-
}, ".thumb.jsx-
|
|
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-
|
|
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: "
|
|
483
|
-
}, ".slide.jsx-
|
|
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
|
|
665
|
+
var _item = item;
|
|
666
|
+
if (! /*#__PURE__*/React.isValidElement(_item)) return undefined;
|
|
662
667
|
|
|
663
|
-
//
|
|
664
|
-
if (
|
|
665
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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;
|
package/esm/Carousal/main.js
CHANGED
|
@@ -1,59 +1,42 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
// });
|