@ttoss/components 1.18.0 → 1.21.0

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/esm/index.js CHANGED
@@ -3,8 +3,64 @@
3
3
  // tsup.inject.js
4
4
  import * as React from "react";
5
5
 
6
- // src/components/InstallPwa/InstallPwa.tsx
6
+ // src/components/Accordion/Accordion.tsx
7
7
  import * as React2 from "react";
8
+ import {
9
+ AccordionItem,
10
+ AccordionItemButton,
11
+ AccordionItemHeading,
12
+ AccordionItemPanel,
13
+ Accordion as ReactAccessibleAccordion
14
+ } from "react-accessible-accordion";
15
+ import { Box, useTheme } from "@ttoss/ui";
16
+ import { css as createClassName } from "@emotion/css";
17
+ import { css as transformStyleObject } from "@theme-ui/css";
18
+ var Accordion = ({
19
+ children,
20
+ allowMultipleExpanded,
21
+ allowZeroExpanded,
22
+ preExpanded,
23
+ onChange,
24
+ ...boxProps
25
+ }) => {
26
+ const { theme } = useTheme();
27
+ const className = React2.useMemo(() => {
28
+ const styles = transformStyleObject({
29
+ ".accordion__item": {
30
+ marginBottom: 3
31
+ },
32
+ ".accordion__heading": {
33
+ padding: 2,
34
+ border: "1px solid",
35
+ borderColor: "black"
36
+ },
37
+ ".accordion__button": {},
38
+ ".accordion__panel": {
39
+ padding: 2
40
+ }
41
+ })(theme);
42
+ return createClassName(styles);
43
+ }, [theme]);
44
+ return /* @__PURE__ */ React2.createElement(Box, {
45
+ variant: "accordion",
46
+ className,
47
+ ...boxProps
48
+ }, /* @__PURE__ */ React2.createElement(ReactAccessibleAccordion, {
49
+ ...{
50
+ allowMultipleExpanded,
51
+ allowZeroExpanded,
52
+ preExpanded,
53
+ onChange
54
+ }
55
+ }, children));
56
+ };
57
+ Accordion.Item = AccordionItem;
58
+ Accordion.ItemButton = AccordionItemButton;
59
+ Accordion.ItemHeading = AccordionItemHeading;
60
+ Accordion.ItemPanel = AccordionItemPanel;
61
+
62
+ // src/components/InstallPwa/InstallPwa.tsx
63
+ import * as React3 from "react";
8
64
 
9
65
  // src/components/InstallPwa/InstallPwaUi.tsx
10
66
  import { Button, Flex, Text } from "@ttoss/ui";
@@ -35,9 +91,9 @@ var InstallPwaUi = ({ onInstall }) => {
35
91
 
36
92
  // src/components/InstallPwa/InstallPwa.tsx
37
93
  var InstallPwa = () => {
38
- const [supportsPwa, setSupportsPwa] = React2.useState(false);
39
- const [promptInstall, setPromptInstall] = React2.useState(null);
40
- React2.useEffect(() => {
94
+ const [supportsPwa, setSupportsPwa] = React3.useState(false);
95
+ const [promptInstall, setPromptInstall] = React3.useState(null);
96
+ React3.useEffect(() => {
41
97
  const handler = (e) => {
42
98
  e.preventDefault();
43
99
  setSupportsPwa(true);
@@ -56,21 +112,21 @@ var InstallPwa = () => {
56
112
  if (!supportsPwa) {
57
113
  return null;
58
114
  }
59
- return /* @__PURE__ */ React2.createElement(InstallPwaUi, {
115
+ return /* @__PURE__ */ React3.createElement(InstallPwaUi, {
60
116
  onInstall
61
117
  });
62
118
  };
63
119
 
64
120
  // src/components/Modal/Modal.tsx
65
- import { useResponsiveValue, useTheme } from "@ttoss/ui";
121
+ import { useResponsiveValue, useTheme as useTheme2 } from "@ttoss/ui";
66
122
  import ReactModal from "react-modal";
67
123
  ReactModal.defaultStyles = {
68
124
  overlay: {},
69
125
  content: {}
70
126
  };
71
127
  var Modal = (props) => {
72
- var _a, _b, _c, _d, _e, _f, _g;
73
- const { theme } = useTheme();
128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
129
+ const { theme } = useTheme2();
74
130
  const padding = useResponsiveValue([
75
131
  (_a = theme.space) == null ? void 0 : _a[2],
76
132
  (_b = theme.space) == null ? void 0 : _b[3],
@@ -91,7 +147,7 @@ var Modal = (props) => {
91
147
  ...(_d = props.style) == null ? void 0 : _d.overlay
92
148
  },
93
149
  content: {
94
- background: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
150
+ backgroundColor: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
95
151
  padding,
96
152
  WebkitOverflowScrolling: "touch",
97
153
  overflow: "auto",
@@ -100,11 +156,12 @@ var Modal = (props) => {
100
156
  left: "0px",
101
157
  right: "0px",
102
158
  bottom: "0px",
103
- border: "1px solid #ccc",
159
+ border: "2px solid",
160
+ borderColor: ((_h = (_g = theme.rawColors) == null ? void 0 : _g.muted) == null ? void 0 : _h.toString()) || "#fff",
104
161
  display: "flex",
105
162
  flexDirection: "column",
106
163
  alignItems: "center",
107
- ...(_g = props.style) == null ? void 0 : _g.content
164
+ ...(_i = props.style) == null ? void 0 : _i.content
108
165
  }
109
166
  };
110
167
  return /* @__PURE__ */ React.createElement(ReactModal, {
@@ -113,7 +170,36 @@ var Modal = (props) => {
113
170
  });
114
171
  };
115
172
  Modal.setAppElement = ReactModal.setAppElement;
173
+
174
+ // src/components/Toast/Toast.tsx
175
+ import { Box as Box2 } from "@ttoss/ui";
176
+ import {
177
+ ToastContainer as ReactToastifyToastContainer,
178
+ ToastContainerProps,
179
+ toast
180
+ } from "react-toastify";
181
+ import "react-toastify/dist/ReactToastify.min.css";
182
+ var ToastContainer = (props) => {
183
+ return /* @__PURE__ */ React.createElement(Box2, {
184
+ sx: ({ colors, fonts }) => ({
185
+ "--toastify-color-light": "#fff",
186
+ "--toastify-color-dark": "#121212",
187
+ "--toastify-color-info": (colors == null ? void 0 : colors.info) || "#3498db",
188
+ "--toastify-color-success": (colors == null ? void 0 : colors.success) || "#07bc0c",
189
+ "--toastify-color-warning": "#f1c40f",
190
+ "--toastify-color-error": "#e74c3c",
191
+ "--toastify-color-progress-light": `linear-gradient(to right, ${colors == null ? void 0 : colors.primary}, ${colors == null ? void 0 : colors.secondary})`,
192
+ "--toastify-font-family": fonts.body
193
+ })
194
+ }, /* @__PURE__ */ React.createElement(ReactToastifyToastContainer, {
195
+ ...props
196
+ }));
197
+ };
116
198
  export {
199
+ Accordion,
117
200
  InstallPwa,
118
- Modal
201
+ Modal,
202
+ ToastContainer,
203
+ ToastContainerProps,
204
+ toast
119
205
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,289 @@
1
+ import * as react_accessible_accordion_dist_types_helpers_DisplayName from 'react-accessible-accordion/dist/types/helpers/DisplayName';
2
+ import * as react_accessible_accordion_dist_types_components_ItemContext from 'react-accessible-accordion/dist/types/components/ItemContext';
3
+ import * as react_accessible_accordion_dist_types_helpers_types from 'react-accessible-accordion/dist/types/helpers/types';
4
+ import * as React from 'react';
5
+ import { BoxProps } from '@ttoss/ui';
1
6
  import ReactModal from 'react-modal';
7
+ import { ToastContainerProps } from 'react-toastify';
8
+ export { ToastContainerProps, toast } from 'react-toastify';
9
+
10
+ declare type AccordionProps = BoxProps & {
11
+ allowMultipleExpanded?: boolean;
12
+ allowZeroExpanded?: boolean;
13
+ preExpanded?: string[];
14
+ /**
15
+ * Callback which is invoked when items are expanded or collapsed. Gets passed uuids of the currently expanded AccordionItems.
16
+ */
17
+ onChange?: (args: string[]) => void;
18
+ };
19
+ declare const Accordion: {
20
+ ({ children, allowMultipleExpanded, allowZeroExpanded, preExpanded, onChange, ...boxProps }: AccordionProps): JSX.Element;
21
+ Item: {
22
+ ({ uuid: customUuid, dangerouslySetExpanded, className, activeClassName, ...rest }: react_accessible_accordion_dist_types_helpers_types.DivAttributes & {
23
+ uuid?: react_accessible_accordion_dist_types_components_ItemContext.ID | undefined;
24
+ activeClassName?: string | undefined;
25
+ dangerouslySetExpanded?: boolean | undefined;
26
+ }): JSX.Element;
27
+ displayName: react_accessible_accordion_dist_types_helpers_DisplayName.default;
28
+ };
29
+ ItemButton: React.FC<{
30
+ children?: React.ReactNode;
31
+ slot?: string | undefined;
32
+ style?: React.CSSProperties | undefined;
33
+ title?: string | undefined;
34
+ defaultChecked?: boolean | undefined;
35
+ defaultValue?: string | number | readonly string[] | undefined;
36
+ suppressContentEditableWarning?: boolean | undefined;
37
+ suppressHydrationWarning?: boolean | undefined;
38
+ accessKey?: string | undefined;
39
+ className?: string | undefined;
40
+ contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
41
+ contextMenu?: string | undefined;
42
+ dir?: string | undefined;
43
+ draggable?: (boolean | "true" | "false") | undefined;
44
+ hidden?: boolean | undefined;
45
+ lang?: string | undefined;
46
+ placeholder?: string | undefined;
47
+ spellCheck?: (boolean | "true" | "false") | undefined;
48
+ translate?: "yes" | "no" | undefined;
49
+ radioGroup?: string | undefined;
50
+ about?: string | undefined;
51
+ datatype?: string | undefined;
52
+ inlist?: any;
53
+ prefix?: string | undefined;
54
+ property?: string | undefined;
55
+ resource?: string | undefined;
56
+ typeof?: string | undefined;
57
+ vocab?: string | undefined;
58
+ autoCapitalize?: string | undefined;
59
+ autoCorrect?: string | undefined;
60
+ autoSave?: string | undefined;
61
+ color?: string | undefined;
62
+ itemProp?: string | undefined;
63
+ itemScope?: boolean | undefined;
64
+ itemType?: string | undefined;
65
+ itemID?: string | undefined;
66
+ itemRef?: string | undefined;
67
+ results?: number | undefined;
68
+ security?: string | undefined;
69
+ unselectable?: "on" | "off" | undefined;
70
+ inputMode?: "text" | "none" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
71
+ is?: string | undefined;
72
+ 'aria-activedescendant'?: string | undefined;
73
+ 'aria-atomic'?: (boolean | "true" | "false") | undefined;
74
+ 'aria-autocomplete'?: "list" | "none" | "both" | "inline" | undefined;
75
+ 'aria-busy'?: (boolean | "true" | "false") | undefined;
76
+ 'aria-checked'?: boolean | "true" | "false" | "mixed" | undefined;
77
+ 'aria-colcount'?: number | undefined;
78
+ 'aria-colindex'?: number | undefined;
79
+ 'aria-colspan'?: number | undefined;
80
+ 'aria-current'?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined;
81
+ 'aria-describedby'?: string | undefined;
82
+ 'aria-details'?: string | undefined;
83
+ 'aria-dropeffect'?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
84
+ 'aria-errormessage'?: string | undefined;
85
+ 'aria-flowto'?: string | undefined;
86
+ 'aria-grabbed'?: (boolean | "true" | "false") | undefined;
87
+ 'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
88
+ 'aria-hidden'?: (boolean | "true" | "false") | undefined;
89
+ 'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
90
+ 'aria-keyshortcuts'?: string | undefined;
91
+ 'aria-label'?: string | undefined;
92
+ 'aria-labelledby'?: string | undefined;
93
+ 'aria-level'?: number | undefined;
94
+ 'aria-live'?: "off" | "assertive" | "polite" | undefined;
95
+ 'aria-modal'?: (boolean | "true" | "false") | undefined;
96
+ 'aria-multiline'?: (boolean | "true" | "false") | undefined;
97
+ 'aria-multiselectable'?: (boolean | "true" | "false") | undefined;
98
+ 'aria-orientation'?: "horizontal" | "vertical" | undefined;
99
+ 'aria-owns'?: string | undefined;
100
+ 'aria-placeholder'?: string | undefined;
101
+ 'aria-posinset'?: number | undefined;
102
+ 'aria-pressed'?: boolean | "true" | "false" | "mixed" | undefined;
103
+ 'aria-readonly'?: (boolean | "true" | "false") | undefined;
104
+ 'aria-relevant'?: "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
105
+ 'aria-required'?: (boolean | "true" | "false") | undefined;
106
+ 'aria-roledescription'?: string | undefined;
107
+ 'aria-rowcount'?: number | undefined;
108
+ 'aria-rowindex'?: number | undefined;
109
+ 'aria-rowspan'?: number | undefined;
110
+ 'aria-selected'?: (boolean | "true" | "false") | undefined;
111
+ 'aria-setsize'?: number | undefined;
112
+ 'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
113
+ 'aria-valuemax'?: number | undefined;
114
+ 'aria-valuemin'?: number | undefined;
115
+ 'aria-valuenow'?: number | undefined;
116
+ 'aria-valuetext'?: string | undefined;
117
+ dangerouslySetInnerHTML?: {
118
+ __html: string;
119
+ } | undefined;
120
+ onCopy?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
121
+ onCopyCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
122
+ onCut?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
123
+ onCutCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
124
+ onPaste?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
125
+ onPasteCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
126
+ onCompositionEnd?: React.CompositionEventHandler<HTMLDivElement> | undefined;
127
+ onCompositionEndCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
128
+ onCompositionStart?: React.CompositionEventHandler<HTMLDivElement> | undefined;
129
+ onCompositionStartCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
130
+ onCompositionUpdate?: React.CompositionEventHandler<HTMLDivElement> | undefined;
131
+ onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
132
+ onFocus?: React.FocusEventHandler<HTMLDivElement> | undefined;
133
+ onFocusCapture?: React.FocusEventHandler<HTMLDivElement> | undefined;
134
+ onBlur?: React.FocusEventHandler<HTMLDivElement> | undefined;
135
+ onBlurCapture?: React.FocusEventHandler<HTMLDivElement> | undefined;
136
+ onChange?: React.FormEventHandler<HTMLDivElement> | undefined;
137
+ onChangeCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
138
+ onBeforeInput?: React.FormEventHandler<HTMLDivElement> | undefined;
139
+ onBeforeInputCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
140
+ onInput?: React.FormEventHandler<HTMLDivElement> | undefined;
141
+ onInputCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
142
+ onReset?: React.FormEventHandler<HTMLDivElement> | undefined;
143
+ onResetCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
144
+ onSubmit?: React.FormEventHandler<HTMLDivElement> | undefined;
145
+ onSubmitCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
146
+ onInvalid?: React.FormEventHandler<HTMLDivElement> | undefined;
147
+ onInvalidCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
148
+ onLoad?: React.ReactEventHandler<HTMLDivElement> | undefined;
149
+ onLoadCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
150
+ onError?: React.ReactEventHandler<HTMLDivElement> | undefined;
151
+ onErrorCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
152
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
153
+ onKeyDownCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
154
+ onKeyPress?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
155
+ onKeyPressCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
156
+ onKeyUp?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
157
+ onKeyUpCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
158
+ onAbort?: React.ReactEventHandler<HTMLDivElement> | undefined;
159
+ onAbortCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
160
+ onCanPlay?: React.ReactEventHandler<HTMLDivElement> | undefined;
161
+ onCanPlayCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
162
+ onCanPlayThrough?: React.ReactEventHandler<HTMLDivElement> | undefined;
163
+ onCanPlayThroughCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
164
+ onDurationChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
165
+ onDurationChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
166
+ onEmptied?: React.ReactEventHandler<HTMLDivElement> | undefined;
167
+ onEmptiedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
168
+ onEncrypted?: React.ReactEventHandler<HTMLDivElement> | undefined;
169
+ onEncryptedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
170
+ onEnded?: React.ReactEventHandler<HTMLDivElement> | undefined;
171
+ onEndedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
172
+ onLoadedData?: React.ReactEventHandler<HTMLDivElement> | undefined;
173
+ onLoadedDataCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
174
+ onLoadedMetadata?: React.ReactEventHandler<HTMLDivElement> | undefined;
175
+ onLoadedMetadataCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
176
+ onLoadStart?: React.ReactEventHandler<HTMLDivElement> | undefined;
177
+ onLoadStartCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
178
+ onPause?: React.ReactEventHandler<HTMLDivElement> | undefined;
179
+ onPauseCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
180
+ onPlay?: React.ReactEventHandler<HTMLDivElement> | undefined;
181
+ onPlayCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
182
+ onPlaying?: React.ReactEventHandler<HTMLDivElement> | undefined;
183
+ onPlayingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
184
+ onProgress?: React.ReactEventHandler<HTMLDivElement> | undefined;
185
+ onProgressCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
186
+ onRateChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
187
+ onRateChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
188
+ onSeeked?: React.ReactEventHandler<HTMLDivElement> | undefined;
189
+ onSeekedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
190
+ onSeeking?: React.ReactEventHandler<HTMLDivElement> | undefined;
191
+ onSeekingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
192
+ onStalled?: React.ReactEventHandler<HTMLDivElement> | undefined;
193
+ onStalledCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
194
+ onSuspend?: React.ReactEventHandler<HTMLDivElement> | undefined;
195
+ onSuspendCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
196
+ onTimeUpdate?: React.ReactEventHandler<HTMLDivElement> | undefined;
197
+ onTimeUpdateCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
198
+ onVolumeChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
199
+ onVolumeChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
200
+ onWaiting?: React.ReactEventHandler<HTMLDivElement> | undefined;
201
+ onWaitingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
202
+ onAuxClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
203
+ onAuxClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
204
+ onClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
205
+ onClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
206
+ onContextMenu?: React.MouseEventHandler<HTMLDivElement> | undefined;
207
+ onContextMenuCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
208
+ onDoubleClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
209
+ onDoubleClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
210
+ onDrag?: React.DragEventHandler<HTMLDivElement> | undefined;
211
+ onDragCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
212
+ onDragEnd?: React.DragEventHandler<HTMLDivElement> | undefined;
213
+ onDragEndCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
214
+ onDragEnter?: React.DragEventHandler<HTMLDivElement> | undefined;
215
+ onDragEnterCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
216
+ onDragExit?: React.DragEventHandler<HTMLDivElement> | undefined;
217
+ onDragExitCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
218
+ onDragLeave?: React.DragEventHandler<HTMLDivElement> | undefined;
219
+ onDragLeaveCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
220
+ onDragOver?: React.DragEventHandler<HTMLDivElement> | undefined;
221
+ onDragOverCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
222
+ onDragStart?: React.DragEventHandler<HTMLDivElement> | undefined;
223
+ onDragStartCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
224
+ onDrop?: React.DragEventHandler<HTMLDivElement> | undefined;
225
+ onDropCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
226
+ onMouseDown?: React.MouseEventHandler<HTMLDivElement> | undefined;
227
+ onMouseDownCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
228
+ onMouseEnter?: React.MouseEventHandler<HTMLDivElement> | undefined;
229
+ onMouseLeave?: React.MouseEventHandler<HTMLDivElement> | undefined;
230
+ onMouseMove?: React.MouseEventHandler<HTMLDivElement> | undefined;
231
+ onMouseMoveCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
232
+ onMouseOut?: React.MouseEventHandler<HTMLDivElement> | undefined;
233
+ onMouseOutCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
234
+ onMouseOver?: React.MouseEventHandler<HTMLDivElement> | undefined;
235
+ onMouseOverCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
236
+ onMouseUp?: React.MouseEventHandler<HTMLDivElement> | undefined;
237
+ onMouseUpCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
238
+ onSelect?: React.ReactEventHandler<HTMLDivElement> | undefined;
239
+ onSelectCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
240
+ onTouchCancel?: React.TouchEventHandler<HTMLDivElement> | undefined;
241
+ onTouchCancelCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
242
+ onTouchEnd?: React.TouchEventHandler<HTMLDivElement> | undefined;
243
+ onTouchEndCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
244
+ onTouchMove?: React.TouchEventHandler<HTMLDivElement> | undefined;
245
+ onTouchMoveCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
246
+ onTouchStart?: React.TouchEventHandler<HTMLDivElement> | undefined;
247
+ onTouchStartCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
248
+ onPointerDown?: React.PointerEventHandler<HTMLDivElement> | undefined;
249
+ onPointerDownCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
250
+ onPointerMove?: React.PointerEventHandler<HTMLDivElement> | undefined;
251
+ onPointerMoveCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
252
+ onPointerUp?: React.PointerEventHandler<HTMLDivElement> | undefined;
253
+ onPointerUpCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
254
+ onPointerCancel?: React.PointerEventHandler<HTMLDivElement> | undefined;
255
+ onPointerCancelCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
256
+ onPointerEnter?: React.PointerEventHandler<HTMLDivElement> | undefined;
257
+ onPointerEnterCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
258
+ onPointerLeave?: React.PointerEventHandler<HTMLDivElement> | undefined;
259
+ onPointerLeaveCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
260
+ onPointerOver?: React.PointerEventHandler<HTMLDivElement> | undefined;
261
+ onPointerOverCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
262
+ onPointerOut?: React.PointerEventHandler<HTMLDivElement> | undefined;
263
+ onPointerOutCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
264
+ onGotPointerCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
265
+ onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
266
+ onLostPointerCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
267
+ onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
268
+ onScroll?: React.UIEventHandler<HTMLDivElement> | undefined;
269
+ onScrollCapture?: React.UIEventHandler<HTMLDivElement> | undefined;
270
+ onWheel?: React.WheelEventHandler<HTMLDivElement> | undefined;
271
+ onWheelCapture?: React.WheelEventHandler<HTMLDivElement> | undefined;
272
+ onAnimationStart?: React.AnimationEventHandler<HTMLDivElement> | undefined;
273
+ onAnimationStartCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
274
+ onAnimationEnd?: React.AnimationEventHandler<HTMLDivElement> | undefined;
275
+ onAnimationEndCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
276
+ onAnimationIteration?: React.AnimationEventHandler<HTMLDivElement> | undefined;
277
+ onAnimationIterationCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
278
+ onTransitionEnd?: React.TransitionEventHandler<HTMLDivElement> | undefined;
279
+ onTransitionEndCapture?: React.TransitionEventHandler<HTMLDivElement> | undefined;
280
+ }>;
281
+ ItemHeading: React.FC<react_accessible_accordion_dist_types_helpers_types.DivAttributes>;
282
+ ItemPanel: ({ className, region, id, ...rest }: react_accessible_accordion_dist_types_helpers_types.DivAttributes & {
283
+ region?: boolean | undefined;
284
+ className?: string | undefined;
285
+ }) => JSX.Element;
286
+ };
2
287
 
3
288
  declare const InstallPwa: () => JSX.Element | null;
4
289
 
@@ -8,4 +293,6 @@ declare const Modal: {
8
293
  setAppElement: typeof ReactModal.setAppElement;
9
294
  };
10
295
 
11
- export { InstallPwa, Modal, ModalProps };
296
+ declare const ToastContainer: (props: ToastContainerProps) => JSX.Element;
297
+
298
+ export { Accordion, AccordionProps, InstallPwa, Modal, ModalProps, ToastContainer };
package/dist/index.js CHANGED
@@ -23,28 +23,82 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
23
23
  // src/index.ts
24
24
  var src_exports = {};
25
25
  __export(src_exports, {
26
+ Accordion: () => Accordion,
26
27
  InstallPwa: () => InstallPwa,
27
- Modal: () => Modal
28
+ Modal: () => Modal,
29
+ ToastContainer: () => ToastContainer,
30
+ ToastContainerProps: () => import_react_toastify.ToastContainerProps,
31
+ toast: () => import_react_toastify.toast
28
32
  });
29
33
  module.exports = __toCommonJS(src_exports);
30
34
 
31
35
  // tsup.inject.js
32
36
  var React = __toESM(require("react"));
33
37
 
34
- // src/components/InstallPwa/InstallPwa.tsx
38
+ // src/components/Accordion/Accordion.tsx
35
39
  var React2 = __toESM(require("react"));
40
+ var import_react_accessible_accordion = require("react-accessible-accordion");
41
+ var import_ui = require("@ttoss/ui");
42
+ var import_css = require("@emotion/css");
43
+ var import_css2 = require("@theme-ui/css");
44
+ var Accordion = ({
45
+ children,
46
+ allowMultipleExpanded,
47
+ allowZeroExpanded,
48
+ preExpanded,
49
+ onChange,
50
+ ...boxProps
51
+ }) => {
52
+ const { theme } = (0, import_ui.useTheme)();
53
+ const className = React2.useMemo(() => {
54
+ const styles = (0, import_css2.css)({
55
+ ".accordion__item": {
56
+ marginBottom: 3
57
+ },
58
+ ".accordion__heading": {
59
+ padding: 2,
60
+ border: "1px solid",
61
+ borderColor: "black"
62
+ },
63
+ ".accordion__button": {},
64
+ ".accordion__panel": {
65
+ padding: 2
66
+ }
67
+ })(theme);
68
+ return (0, import_css.css)(styles);
69
+ }, [theme]);
70
+ return /* @__PURE__ */ React2.createElement(import_ui.Box, {
71
+ variant: "accordion",
72
+ className,
73
+ ...boxProps
74
+ }, /* @__PURE__ */ React2.createElement(import_react_accessible_accordion.Accordion, {
75
+ ...{
76
+ allowMultipleExpanded,
77
+ allowZeroExpanded,
78
+ preExpanded,
79
+ onChange
80
+ }
81
+ }, children));
82
+ };
83
+ Accordion.Item = import_react_accessible_accordion.AccordionItem;
84
+ Accordion.ItemButton = import_react_accessible_accordion.AccordionItemButton;
85
+ Accordion.ItemHeading = import_react_accessible_accordion.AccordionItemHeading;
86
+ Accordion.ItemPanel = import_react_accessible_accordion.AccordionItemPanel;
87
+
88
+ // src/components/InstallPwa/InstallPwa.tsx
89
+ var React3 = __toESM(require("react"));
36
90
 
37
91
  // src/components/InstallPwa/InstallPwaUi.tsx
38
- var import_ui = require("@ttoss/ui");
92
+ var import_ui2 = require("@ttoss/ui");
39
93
  var InstallPwaUi = ({ onInstall }) => {
40
- return /* @__PURE__ */ React.createElement(import_ui.Flex, {
94
+ return /* @__PURE__ */ React.createElement(import_ui2.Flex, {
41
95
  sx: {
42
96
  position: "absolute",
43
97
  bottom: 4,
44
98
  width: "100%",
45
99
  justifyContent: "center"
46
100
  }
47
- }, /* @__PURE__ */ React.createElement(import_ui.Flex, {
101
+ }, /* @__PURE__ */ React.createElement(import_ui2.Flex, {
48
102
  sx: {
49
103
  backgroundColor: "background",
50
104
  justifyContent: "center",
@@ -56,16 +110,16 @@ var InstallPwaUi = ({ onInstall }) => {
56
110
  borderRadius: 1,
57
111
  padding: 4
58
112
  }
59
- }, /* @__PURE__ */ React.createElement(import_ui.Text, null, "Deseja instalar o nosso aplicativo?"), /* @__PURE__ */ React.createElement(import_ui.Button, {
113
+ }, /* @__PURE__ */ React.createElement(import_ui2.Text, null, "Deseja instalar o nosso aplicativo?"), /* @__PURE__ */ React.createElement(import_ui2.Button, {
60
114
  onClick: onInstall
61
115
  }, "Instalar")));
62
116
  };
63
117
 
64
118
  // src/components/InstallPwa/InstallPwa.tsx
65
119
  var InstallPwa = () => {
66
- const [supportsPwa, setSupportsPwa] = React2.useState(false);
67
- const [promptInstall, setPromptInstall] = React2.useState(null);
68
- React2.useEffect(() => {
120
+ const [supportsPwa, setSupportsPwa] = React3.useState(false);
121
+ const [promptInstall, setPromptInstall] = React3.useState(null);
122
+ React3.useEffect(() => {
69
123
  const handler = (e) => {
70
124
  e.preventDefault();
71
125
  setSupportsPwa(true);
@@ -84,22 +138,22 @@ var InstallPwa = () => {
84
138
  if (!supportsPwa) {
85
139
  return null;
86
140
  }
87
- return /* @__PURE__ */ React2.createElement(InstallPwaUi, {
141
+ return /* @__PURE__ */ React3.createElement(InstallPwaUi, {
88
142
  onInstall
89
143
  });
90
144
  };
91
145
 
92
146
  // src/components/Modal/Modal.tsx
93
- var import_ui2 = require("@ttoss/ui");
147
+ var import_ui3 = require("@ttoss/ui");
94
148
  var import_react_modal = __toESM(require("react-modal"));
95
149
  import_react_modal.default.defaultStyles = {
96
150
  overlay: {},
97
151
  content: {}
98
152
  };
99
153
  var Modal = (props) => {
100
- var _a, _b, _c, _d, _e, _f, _g;
101
- const { theme } = (0, import_ui2.useTheme)();
102
- const padding = (0, import_ui2.useResponsiveValue)([
154
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
155
+ const { theme } = (0, import_ui3.useTheme)();
156
+ const padding = (0, import_ui3.useResponsiveValue)([
103
157
  (_a = theme.space) == null ? void 0 : _a[2],
104
158
  (_b = theme.space) == null ? void 0 : _b[3],
105
159
  (_c = theme.space) == null ? void 0 : _c[4]
@@ -119,7 +173,7 @@ var Modal = (props) => {
119
173
  ...(_d = props.style) == null ? void 0 : _d.overlay
120
174
  },
121
175
  content: {
122
- background: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
176
+ backgroundColor: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
123
177
  padding,
124
178
  WebkitOverflowScrolling: "touch",
125
179
  overflow: "auto",
@@ -128,11 +182,12 @@ var Modal = (props) => {
128
182
  left: "0px",
129
183
  right: "0px",
130
184
  bottom: "0px",
131
- border: "1px solid #ccc",
185
+ border: "2px solid",
186
+ borderColor: ((_h = (_g = theme.rawColors) == null ? void 0 : _g.muted) == null ? void 0 : _h.toString()) || "#fff",
132
187
  display: "flex",
133
188
  flexDirection: "column",
134
189
  alignItems: "center",
135
- ...(_g = props.style) == null ? void 0 : _g.content
190
+ ...(_i = props.style) == null ? void 0 : _i.content
136
191
  }
137
192
  };
138
193
  return /* @__PURE__ */ React.createElement(import_react_modal.default, {
@@ -141,8 +196,33 @@ var Modal = (props) => {
141
196
  });
142
197
  };
143
198
  Modal.setAppElement = import_react_modal.default.setAppElement;
199
+
200
+ // src/components/Toast/Toast.tsx
201
+ var import_ui4 = require("@ttoss/ui");
202
+ var import_react_toastify = require("react-toastify");
203
+ var import_ReactToastify_min = require("react-toastify/dist/ReactToastify.min.css");
204
+ var ToastContainer = (props) => {
205
+ return /* @__PURE__ */ React.createElement(import_ui4.Box, {
206
+ sx: ({ colors, fonts }) => ({
207
+ "--toastify-color-light": "#fff",
208
+ "--toastify-color-dark": "#121212",
209
+ "--toastify-color-info": (colors == null ? void 0 : colors.info) || "#3498db",
210
+ "--toastify-color-success": (colors == null ? void 0 : colors.success) || "#07bc0c",
211
+ "--toastify-color-warning": "#f1c40f",
212
+ "--toastify-color-error": "#e74c3c",
213
+ "--toastify-color-progress-light": `linear-gradient(to right, ${colors == null ? void 0 : colors.primary}, ${colors == null ? void 0 : colors.secondary})`,
214
+ "--toastify-font-family": fonts.body
215
+ })
216
+ }, /* @__PURE__ */ React.createElement(import_react_toastify.ToastContainer, {
217
+ ...props
218
+ }));
219
+ };
144
220
  // Annotate the CommonJS export names for ESM import in node:
145
221
  0 && (module.exports = {
222
+ Accordion,
146
223
  InstallPwa,
147
- Modal
224
+ Modal,
225
+ ToastContainer,
226
+ ToastContainerProps,
227
+ toast
148
228
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/components",
3
- "version": "1.18.0",
3
+ "version": "1.21.0",
4
4
  "description": "React components.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -31,19 +31,23 @@
31
31
  "dev": "yarn workspace @docs/storybook run dev"
32
32
  },
33
33
  "dependencies": {
34
+ "@emotion/css": "^11.10.0",
35
+ "@theme-ui/css": "^0.14.7",
34
36
  "@types/react-modal": "^3.13.1",
35
- "react-modal": "^3.15.1"
37
+ "react-accessible-accordion": "^5.0.0",
38
+ "react-modal": "^3.15.1",
39
+ "react-toastify": "^9.0.8"
36
40
  },
37
41
  "peerDependencies": {
38
42
  "@ttoss/ui": "^1.16.5",
39
43
  "react": ">=16.8.0"
40
44
  },
41
45
  "devDependencies": {
42
- "@ttoss/config": "^1.15.2",
43
- "@ttoss/test-utils": "^1.15.2",
44
- "@ttoss/ui": "^1.18.0",
46
+ "@ttoss/config": "^1.17.0",
47
+ "@ttoss/test-utils": "^1.16.6",
48
+ "@ttoss/ui": "^1.19.0",
45
49
  "@types/jest": "^28.1.5",
46
50
  "jest": "^28.1.3"
47
51
  },
48
- "gitHead": "38d76661c6302b6447804375cd0193be9056b446"
52
+ "gitHead": "bea31ace95128d57607156807e402a793b0c46e4"
49
53
  }
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import {
3
+ AccordionItem,
4
+ AccordionItemButton,
5
+ AccordionItemHeading,
6
+ AccordionItemPanel,
7
+ Accordion as ReactAccessibleAccordion,
8
+ } from 'react-accessible-accordion';
9
+ import { Box, BoxProps, useTheme } from '@ttoss/ui';
10
+ import { css as createClassName } from '@emotion/css';
11
+ import { css as transformStyleObject } from '@theme-ui/css';
12
+
13
+ export type AccordionProps = BoxProps & {
14
+ // https://github.com/springload/react-accessible-accordion#accordion
15
+ allowMultipleExpanded?: boolean;
16
+ allowZeroExpanded?: boolean;
17
+ preExpanded?: string[];
18
+ /**
19
+ * Callback which is invoked when items are expanded or collapsed. Gets passed uuids of the currently expanded AccordionItems.
20
+ */
21
+ onChange?: (args: string[]) => void;
22
+ };
23
+
24
+ export const Accordion = ({
25
+ children,
26
+ allowMultipleExpanded,
27
+ allowZeroExpanded,
28
+ preExpanded,
29
+ onChange,
30
+ ...boxProps
31
+ }: AccordionProps) => {
32
+ const { theme } = useTheme();
33
+
34
+ const className = React.useMemo(() => {
35
+ const styles = transformStyleObject({
36
+ '.accordion__item': {
37
+ marginBottom: 3,
38
+ },
39
+ '.accordion__heading': {
40
+ padding: 2,
41
+ border: '1px solid',
42
+ borderColor: 'black',
43
+ },
44
+ '.accordion__button': {},
45
+ '.accordion__panel': {
46
+ padding: 2,
47
+ },
48
+ })(theme);
49
+
50
+ return createClassName(styles);
51
+ }, [theme]);
52
+
53
+ return (
54
+ <Box variant="accordion" className={className} {...boxProps}>
55
+ <ReactAccessibleAccordion
56
+ {...{
57
+ allowMultipleExpanded,
58
+ allowZeroExpanded,
59
+ preExpanded,
60
+ onChange,
61
+ }}
62
+ >
63
+ {children}
64
+ </ReactAccessibleAccordion>
65
+ </Box>
66
+ );
67
+ };
68
+
69
+ Accordion.Item = AccordionItem;
70
+ Accordion.ItemButton = AccordionItemButton;
71
+ Accordion.ItemHeading = AccordionItemHeading;
72
+ Accordion.ItemPanel = AccordionItemPanel;
@@ -36,7 +36,7 @@ export const Modal = (props: ModalProps) => {
36
36
  /**
37
37
  * Theme
38
38
  */
39
- background: theme.rawColors?.background?.toString() || '#fff',
39
+ backgroundColor: theme.rawColors?.background?.toString() || '#fff',
40
40
  padding,
41
41
  /**
42
42
  * General
@@ -48,7 +48,8 @@ export const Modal = (props: ModalProps) => {
48
48
  left: '0px',
49
49
  right: '0px',
50
50
  bottom: '0px',
51
- border: '1px solid #ccc',
51
+ border: '2px solid',
52
+ borderColor: theme.rawColors?.muted?.toString() || '#fff',
52
53
  display: 'flex',
53
54
  flexDirection: 'column',
54
55
  alignItems: 'center',
@@ -0,0 +1,28 @@
1
+ import { Box } from '@ttoss/ui';
2
+ import {
3
+ ToastContainer as ReactToastifyToastContainer,
4
+ ToastContainerProps,
5
+ toast,
6
+ } from 'react-toastify';
7
+ import 'react-toastify/dist/ReactToastify.min.css';
8
+
9
+ export { toast, ToastContainerProps };
10
+
11
+ export const ToastContainer = (props: ToastContainerProps) => {
12
+ return (
13
+ <Box
14
+ sx={({ colors, fonts }) => ({
15
+ '--toastify-color-light': '#fff',
16
+ '--toastify-color-dark': '#121212',
17
+ '--toastify-color-info': colors?.info || '#3498db',
18
+ '--toastify-color-success': colors?.success || '#07bc0c',
19
+ '--toastify-color-warning': '#f1c40f',
20
+ '--toastify-color-error': '#e74c3c',
21
+ '--toastify-color-progress-light': `linear-gradient(to right, ${colors?.primary}, ${colors?.secondary})`,
22
+ '--toastify-font-family': (fonts as { body: string }).body,
23
+ })}
24
+ >
25
+ <ReactToastifyToastContainer {...props} />
26
+ </Box>
27
+ );
28
+ };
@@ -1,8 +1,11 @@
1
1
  import * as componentsModule from './index';
2
2
 
3
- test.each([componentsModule.InstallPwa, componentsModule.Modal])(
4
- 'should export components %#',
5
- (Component) => {
6
- expect(Component).toBeDefined();
7
- }
8
- );
3
+ test.each([
4
+ componentsModule.Accordion,
5
+ componentsModule.InstallPwa,
6
+ componentsModule.Modal,
7
+ componentsModule.ToastContainer,
8
+ componentsModule.toast,
9
+ ])('should export components %#', (Component) => {
10
+ expect(Component).toBeDefined();
11
+ });
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
- export { InstallPwa } from './components/InstallPwa/InstallPwa';
2
- export { Modal, ModalProps } from './components/Modal/Modal';
1
+ export * from './components/Accordion/Accordion';
2
+ export * from './components/InstallPwa/InstallPwa';
3
+ export * from './components/Modal/Modal';
4
+ export * from './components/Toast/Toast';
@@ -1,56 +0,0 @@
1
- # Modal
2
-
3
- This components uses [react-modal package](http://reactcommunity.org/react-modal) as a base and apply [@ttoss/ui](/docs/modules/packages/ui/) styles.
4
-
5
- ## Storybook
6
-
7
- [Modal Stories](https://storybook.ttoss.dev/?path=/story/components-modal)
8
-
9
- ## Example
10
-
11
- ```jsx
12
- import { Modal } from "@ttoss/components";
13
- import { Box, Flex, Text } from "@ttoss/ui";
14
-
15
- const Component = () => {
16
- const [isOpen, setIsOpen] = React.useState(false);
17
-
18
- return (
19
- <Box>
20
- <Modal
21
- isOpen={isOpen}
22
- onRequestClose={() => {
23
- setIsOpen(false);
24
- }}
25
- >
26
- <Flex
27
- sx={{
28
- flexDirection: "column",
29
- alignItems: "center",
30
- }}
31
- >
32
- <Text>This is a modal.</Text>
33
- <Button
34
- onClick={() => {
35
- setIsOpen(false);
36
- }}
37
- >
38
- Close Modal
39
- </Button>
40
- </Flex>
41
- </Modal>
42
- <Button
43
- onClick={() => {
44
- setIsOpen(true);
45
- }}
46
- >
47
- Open Modal
48
- </Button>
49
- </Box>
50
- );
51
- };
52
- ```
53
-
54
- ## API
55
-
56
- This components extends the API of [react-modal package](http://reactcommunity.org/react-modal/#usage).