@pingux/astro 1.0.0-alpha.2 → 1.0.0-alpha.6

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.
@@ -0,0 +1,100 @@
1
+ import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
2
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
3
+ import React, { useCallback, useRef } from 'react';
4
+ import InsertDriveFileIcon from 'mdi-react/InsertDriveFileIcon';
5
+ import ErrorIcon from 'mdi-react/ErrorIcon';
6
+ import DeleteIcon from 'mdi-react/DeleteIcon';
7
+ import PropTypes from 'prop-types';
8
+ import { useVisuallyHidden } from '@react-aria/visually-hidden';
9
+ import { Box, Button, IconButton, Icon, Text } from '../../index';
10
+ import statuses from '../../utils/devUtils/constants/statuses';
11
+ import { jsx as ___EmotionJSX } from "@emotion/react";
12
+
13
+ var FileItem = function FileItem(props) {
14
+ var downloadLink = props.downloadLink,
15
+ handleFileDelete = props.handleFileDelete,
16
+ id = props.id,
17
+ isDisabled = props.isDisabled,
18
+ name = props.name,
19
+ status = props.status,
20
+ textProps = props.textProps;
21
+ var handleDeleteButtonPress = useCallback(function (e) {
22
+ return handleFileDelete(e, id);
23
+ }, [id, handleFileDelete]);
24
+
25
+ var _useVisuallyHidden = useVisuallyHidden(),
26
+ visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
27
+
28
+ var downloadRef = useRef();
29
+ var getFileIconProps = useCallback(function () {
30
+ switch (status) {
31
+ case statuses.ERROR:
32
+ return {
33
+ icon: ErrorIcon,
34
+ color: 'critical.dark',
35
+ 'data-testid': 'file-uploaded__file-icon--is-error'
36
+ };
37
+
38
+ default:
39
+ return {
40
+ icon: InsertDriveFileIcon
41
+ };
42
+ }
43
+ }, [status]);
44
+
45
+ var handleDownloadPress = function handleDownloadPress() {
46
+ downloadRef.current.click();
47
+ };
48
+
49
+ return ___EmotionJSX(Box, {
50
+ isRow: true,
51
+ alignItems: "center",
52
+ mx: 15,
53
+ my: 5
54
+ }, ___EmotionJSX(Icon, _extends({
55
+ size: 15,
56
+ "data-testid": "file-uploaded__file-icon"
57
+ }, getFileIconProps(), {
58
+ isDisabled: isDisabled
59
+ })), ___EmotionJSX(Button, {
60
+ variant: "fileInputField",
61
+ mx: 5,
62
+ isDisabled: isDisabled,
63
+ "aria-label": name,
64
+ "data-testid": "file-uploaded__download-file-button",
65
+ onPress: handleDownloadPress
66
+ }, ___EmotionJSX(Text, _extends({
67
+ color: "active"
68
+ }, textProps), name)), ___EmotionJSX(IconButton, {
69
+ "aria-label": "Delete ".concat(name, " file icon"),
70
+ "data-testid": "file-uploaded__delete-file-button",
71
+ isDisabled: isDisabled,
72
+ onPress: handleDeleteButtonPress,
73
+ sx: {
74
+ alignSelf: 'auto'
75
+ }
76
+ }, ___EmotionJSX(Icon, {
77
+ icon: DeleteIcon,
78
+ size: 15,
79
+ isDisabled: isDisabled
80
+ })), ___EmotionJSX("a", _extends({
81
+ href: downloadLink
82
+ }, visuallyHiddenProps, {
83
+ download: true,
84
+ ref: downloadRef,
85
+ "aria-label": "download",
86
+ "data-testid": "file-uploaded__download-link",
87
+ tabIndex: -1
88
+ })));
89
+ };
90
+
91
+ export default FileItem;
92
+ FileItem.propTypes = {
93
+ downloadLink: PropTypes.string,
94
+ handleFileDelete: PropTypes.func,
95
+ id: PropTypes.string,
96
+ isDisabled: PropTypes.bool,
97
+ name: PropTypes.string,
98
+ status: PropTypes.oneOf(_Object$values(statuses)),
99
+ textProps: PropTypes.shape({})
100
+ };
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { Button, Text } from '../../index';
5
+ import { jsx as ___EmotionJSX } from "@emotion/react";
6
+
7
+ var FileSelect = function FileSelect(props) {
8
+ var buttonText = props.buttonText,
9
+ handleFileSelect = props.handleFileSelect,
10
+ isDisabled = props.isDisabled,
11
+ textProps = props.textProps;
12
+ return ___EmotionJSX(Button, {
13
+ "aria-label": buttonText,
14
+ "data-testid": "file-input-field__file-select",
15
+ isDisabled: isDisabled,
16
+ mx: 15,
17
+ my: 5,
18
+ onPress: handleFileSelect,
19
+ variant: "fileInputField"
20
+ }, ___EmotionJSX(Text, _extends({
21
+ color: "active"
22
+ }, textProps), buttonText));
23
+ };
24
+
25
+ export default FileSelect;
26
+ FileSelect.propTypes = {
27
+ buttonText: PropTypes.string,
28
+ handleFileSelect: PropTypes.func,
29
+ isDisabled: PropTypes.bool,
30
+ textProps: PropTypes.shape({})
31
+ };
@@ -0,0 +1 @@
1
+ export { default } from './FileInputField';
package/lib/index.js CHANGED
@@ -36,6 +36,7 @@ export { default as DropdownField } from './components/DropdownField';
36
36
  export * from './components/DropdownField';
37
37
  export { default as FieldHelperText } from './components/FieldHelperText';
38
38
  export * from './components/FieldHelperText';
39
+ export { default as FileInputField } from './components/FileInputField';
39
40
  export { default as HelpHint } from './components/HelpHint';
40
41
  export * from './components/HelpHint';
41
42
  export { default as Icon } from './components/Icon';
@@ -49,6 +49,17 @@ export var input = _objectSpread(_objectSpread({}, text.inputValue), {}, {
49
49
  '&::placeholder': text.placeholder,
50
50
  '&::-ms-expand': {
51
51
  display: 'none'
52
+ },
53
+ '&::-webkit-contacts-auto-fill-button, &::-webkit-credentials-auto-fill-button': {
54
+ visibility: 'hidden',
55
+ display: 'none !important',
56
+ pointerEvents: 'none',
57
+ height: 0,
58
+ width: 0,
59
+ margin: 0
60
+ },
61
+ '&::-ms-reveal, &::-ms-clear': {
62
+ display: 'none'
52
63
  }
53
64
  }); // Example variant input
54
65
 
@@ -229,6 +229,28 @@ var datePicker = {
229
229
  }
230
230
  }
231
231
  };
232
+ var fileInputFieldWrapper = {
233
+ display: 'flex',
234
+ border: '1px dashed',
235
+ borderColor: 'active',
236
+ padding: '10px 0',
237
+ '&.is-drag-active': {
238
+ backgroundColor: 'accent.95'
239
+ },
240
+ '&.is-error': {
241
+ borderColor: 'critical.dark'
242
+ },
243
+ '&.is-success': {
244
+ borderColor: 'success.dark'
245
+ },
246
+ '&.is-warning': {
247
+ borderColor: 'warning.dark'
248
+ },
249
+ '&.is-loading': {
250
+ justifyContent: 'center',
251
+ alignItems: 'center'
252
+ }
253
+ };
232
254
  export default {
233
255
  base: base,
234
256
  card: card,
@@ -237,6 +259,7 @@ export default {
237
259
  datePicker: datePicker,
238
260
  expandableRow: expandableRow,
239
261
  inputInContainerSlot: inputInContainerSlot,
262
+ fileInputFieldWrapper: fileInputFieldWrapper,
240
263
  listItem: listItem,
241
264
  listBoxSectionTitle: listBoxSectionTitle,
242
265
  listViewItem: listViewItem,
@@ -452,6 +452,25 @@ var expandableRow = {
452
452
  }
453
453
  }
454
454
  };
455
+ var fileInputField = {
456
+ background: 'none',
457
+ cursor: 'pointer',
458
+ '& span': {
459
+ textAlign: 'initial'
460
+ },
461
+ '&:focus-visible': {
462
+ outline: 'none'
463
+ },
464
+ '&.is-hovered, &.is-pressed': {
465
+ cursor: 'pointer',
466
+ '& span': {
467
+ textDecoration: 'underline'
468
+ }
469
+ },
470
+ '&.is-focused': {
471
+ boxShadow: 'focus'
472
+ }
473
+ };
455
474
  export default {
456
475
  accordionHeader: accordionHeader,
457
476
  chipDeleteButton: chipDeleteButton,
@@ -470,6 +489,7 @@ export default {
470
489
  '&.is-focused': _objectSpread({}, defaultFocus)
471
490
  }),
472
491
  expandableRow: expandableRow,
492
+ fileInputField: fileInputField,
473
493
  iconButton: iconButton,
474
494
  icon: icon,
475
495
  imageUpload: imageUpload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "uxdev@pingidentity.com",
6
6
  "license": "Apache-2.0",
@@ -135,6 +135,7 @@
135
135
  "prop-types": "^15.7.2",
136
136
  "react-calendar": "^3.4.0",
137
137
  "react-color": "^2.19.3",
138
+ "react-dropzone": "^11.4.2",
138
139
  "rebass": "^4.0.7",
139
140
  "recharts": "^2.1.4",
140
141
  "regenerator-runtime": "^0.13.7",