@ansible/ansible-ui-framework 0.0.271 → 0.0.273

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,5 @@
1
+ /// <reference types="react" />
2
+ export declare function BytesCell(props: {
3
+ bytes: number;
4
+ decimals?: number;
5
+ }): JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BytesCell = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ function BytesCell(props) {
6
+ var bytes = props.bytes;
7
+ if (!+bytes)
8
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
9
+ var k = 1024;
10
+ var decimals = props.decimals ? props.decimals : 0;
11
+ var dm = decimals < 0 ? 0 : decimals;
12
+ var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
13
+ var i = Math.floor(Math.log(bytes) / Math.log(k));
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]) });
15
+ }
16
+ exports.BytesCell = BytesCell;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare function CapacityCell(props: {
3
+ format?: string;
4
+ used: number;
5
+ capacity: number;
6
+ }): JSX.Element;
@@ -27,52 +27,11 @@ var __read = (this && this.__read) || function (o, n) {
27
27
  return ar;
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.BytesCell = exports.CapacityCell = exports.SinceCell = exports.CopyCell = exports.DateCell = exports.LabelsCell = void 0;
30
+ exports.CapacityCell = void 0;
31
31
  var jsx_runtime_1 = require("react/jsx-runtime");
32
32
  var react_core_1 = require("@patternfly/react-core");
33
- var luxon_1 = require("luxon");
34
- var react_1 = require("react");
35
33
  var Settings_1 = require("../Settings");
36
34
  var useFrameworkTranslations_1 = require("../useFrameworkTranslations");
37
- function LabelsCell(props) {
38
- return ((0, jsx_runtime_1.jsx)(react_core_1.LabelGroup, __assign({ numLabels: 999, style: { flexWrap: 'nowrap' } }, { children: props.labels.map(function (label) { return ((0, jsx_runtime_1.jsx)(react_core_1.Label, { children: label }, label)); }) })));
39
- }
40
- exports.LabelsCell = LabelsCell;
41
- function DateCell(props) {
42
- var date = new Date(props.value);
43
- return ((0, jsx_runtime_1.jsxs)(react_core_1.Split, __assign({ hasGutter: true }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.SplitItem, { children: date.toLocaleDateString() }), (0, jsx_runtime_1.jsx)(react_core_1.SplitItem, { children: date.toLocaleTimeString() })] })));
44
- }
45
- exports.DateCell = DateCell;
46
- function CopyCell(props) {
47
- if (!props.text)
48
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
49
- return ((0, jsx_runtime_1.jsx)(react_core_1.ClipboardCopy, __assign({ hoverTip: "Copy", clickTip: "Copied", variant: "inline-compact", style: { display: 'flex', flexWrap: 'nowrap', borderRadius: 4 }, onCopy: function () {
50
- var _a;
51
- void navigator.clipboard.writeText((_a = props.text) !== null && _a !== void 0 ? _a : '');
52
- } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Truncate, { content: props.text, style: { minWidth: props.minWidth } }) })));
53
- }
54
- exports.CopyCell = CopyCell;
55
- function SinceCell(props) {
56
- var t = props.t;
57
- t = t ? t : function (t) { return t; };
58
- var author = props.author, onClick = props.onClick;
59
- var _a = __read((0, react_1.useState)(null), 2), dateTime = _a[0], setDateTime = _a[1];
60
- (0, react_1.useEffect)(function () {
61
- if (props.value) {
62
- setDateTime(luxon_1.DateTime.fromISO(props.value).toRelative());
63
- }
64
- var timeout = setInterval(function () {
65
- if (props.value) {
66
- setDateTime(luxon_1.DateTime.fromISO(props.value).toRelative());
67
- }
68
- }, 1000);
69
- return function () { return clearTimeout(timeout); };
70
- }, [props.value]);
71
- if (props.value === undefined)
72
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
73
- return ((0, jsx_runtime_1.jsxs)("span", __assign({ style: { whiteSpace: 'nowrap' } }, { children: [dateTime, author && (0, jsx_runtime_1.jsxs)("span", { children: ["\u00A0", t('by'), "\u00A0"] }), onClick ? ((0, jsx_runtime_1.jsx)(react_core_1.Button, __assign({ variant: "link", isInline: true, onClick: onClick }, { children: author }))) : ((0, jsx_runtime_1.jsx)("span", { children: author }))] })));
74
- }
75
- exports.SinceCell = SinceCell;
76
35
  function CapacityCell(props) {
77
36
  var _a = __read((0, useFrameworkTranslations_1.useFrameworkTranslations)(), 1), translations = _a[0];
78
37
  var settings = (0, Settings_1.useSettings)();
@@ -105,15 +64,3 @@ function CapacityCell(props) {
105
64
  .replace('{capacity}', props.capacity.toString()) })) : ((0, jsx_runtime_1.jsxs)(react_core_1.FlexItem, { children: [props.used, " ".concat(translations.ofText, " "), props.capacity] }))] })));
106
65
  }
107
66
  exports.CapacityCell = CapacityCell;
108
- function BytesCell(props) {
109
- var bytes = props.bytes;
110
- if (!+bytes)
111
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
112
- var k = 1024;
113
- var decimals = props.decimals ? props.decimals : 0;
114
- var dm = decimals < 0 ? 0 : decimals;
115
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
116
- var i = Math.floor(Math.log(bytes) / Math.log(k));
117
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]) });
118
- }
119
- exports.BytesCell = BytesCell;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare function CopyCell(props: {
3
+ text?: string;
4
+ minWidth?: number;
5
+ }): JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.CopyCell = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_core_1 = require("@patternfly/react-core");
17
+ function CopyCell(props) {
18
+ if (!props.text)
19
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
20
+ return ((0, jsx_runtime_1.jsx)(react_core_1.ClipboardCopy, __assign({ hoverTip: "Copy", clickTip: "Copied", variant: "inline-compact", style: { display: 'flex', flexWrap: 'nowrap', borderRadius: 4 }, onCopy: function () {
21
+ var _a;
22
+ void navigator.clipboard.writeText((_a = props.text) !== null && _a !== void 0 ? _a : '');
23
+ } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Truncate, { content: props.text, style: { minWidth: props.minWidth } }) })));
24
+ }
25
+ exports.CopyCell = CopyCell;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ export declare function DateCell(props: {
3
+ value: number | string;
4
+ }): JSX.Element;
5
+ export declare function SinceCell(props: {
6
+ value: string | undefined | null;
7
+ author?: string;
8
+ onClick?: () => void;
9
+ t?: (t: string) => string;
10
+ }): JSX.Element;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.SinceCell = exports.DateCell = void 0;
31
+ var jsx_runtime_1 = require("react/jsx-runtime");
32
+ var react_core_1 = require("@patternfly/react-core");
33
+ var luxon_1 = require("luxon");
34
+ var react_1 = require("react");
35
+ function DateCell(props) {
36
+ var date = new Date(props.value);
37
+ return ((0, jsx_runtime_1.jsxs)(react_core_1.Split, __assign({ hasGutter: true }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.SplitItem, { children: date.toLocaleDateString() }), (0, jsx_runtime_1.jsx)(react_core_1.SplitItem, { children: date.toLocaleTimeString() })] })));
38
+ }
39
+ exports.DateCell = DateCell;
40
+ function SinceCell(props) {
41
+ var t = props.t;
42
+ t = t ? t : function (t) { return t; };
43
+ var author = props.author, onClick = props.onClick;
44
+ var _a = __read((0, react_1.useState)(null), 2), dateTime = _a[0], setDateTime = _a[1];
45
+ (0, react_1.useEffect)(function () {
46
+ if (props.value) {
47
+ setDateTime(luxon_1.DateTime.fromISO(props.value).toRelative());
48
+ }
49
+ var timeout = setInterval(function () {
50
+ if (props.value) {
51
+ setDateTime(luxon_1.DateTime.fromISO(props.value).toRelative());
52
+ }
53
+ }, 1000);
54
+ return function () { return clearTimeout(timeout); };
55
+ }, [props.value]);
56
+ if (props.value === undefined)
57
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
58
+ return ((0, jsx_runtime_1.jsxs)("span", __assign({ style: { whiteSpace: 'nowrap' } }, { children: [dateTime, author && (0, jsx_runtime_1.jsxs)("span", { children: ["\u00A0", t('by'), "\u00A0"] }), onClick ? ((0, jsx_runtime_1.jsx)(react_core_1.Button, __assign({ variant: "link", isInline: true, onClick: onClick }, { children: author }))) : ((0, jsx_runtime_1.jsx)("span", { children: author }))] })));
59
+ }
60
+ exports.SinceCell = SinceCell;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare function LabelsCell(props: {
3
+ labels: string[];
4
+ }): JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.LabelsCell = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_core_1 = require("@patternfly/react-core");
17
+ function LabelsCell(props) {
18
+ return ((0, jsx_runtime_1.jsx)(react_core_1.LabelGroup, __assign({ numLabels: 999, style: { flexWrap: 'nowrap' } }, { children: props.labels.map(function (label) { return ((0, jsx_runtime_1.jsx)(react_core_1.Label, { children: label }, label)); }) })));
19
+ }
20
+ exports.LabelsCell = LabelsCell;
package/cjs/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export * from './BulkActionDialog';
2
- export * from './cells/PageCells';
2
+ export * from './cells/BytesCell';
3
+ export * from './cells/CapacityCell';
4
+ export * from './cells/CopyCell';
5
+ export * from './cells/DateTimeCell';
6
+ export * from './cells/LabelsCell';
3
7
  export * from './cells/TextCell';
4
8
  export * from './components/BulkSelector';
5
9
  export * from './components/Collapse';
package/cjs/index.js CHANGED
@@ -15,7 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BulkActionDialog"), exports);
18
- __exportStar(require("./cells/PageCells"), exports);
18
+ __exportStar(require("./cells/BytesCell"), exports);
19
+ __exportStar(require("./cells/CapacityCell"), exports);
20
+ __exportStar(require("./cells/CopyCell"), exports);
21
+ __exportStar(require("./cells/DateTimeCell"), exports);
22
+ __exportStar(require("./cells/LabelsCell"), exports);
19
23
  __exportStar(require("./cells/TextCell"), exports);
20
24
  __exportStar(require("./components/BulkSelector"), exports);
21
25
  __exportStar(require("./components/Collapse"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "Framework for building consistent responsive web applications using PatternFly.",
4
- "version": "0.0.271",
4
+ "version": "0.0.273",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,6 +20,7 @@
20
20
  "@react-hook/resize-observer": "^1",
21
21
  "@types/json-schema": "^7",
22
22
  "@types/react": "^17 || ^18",
23
+ "@types/react-dom": "^17 || ^18",
23
24
  "@types/styled-components": "^5",
24
25
  "debounce": "^1",
25
26
  "get-value": "^3",
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function LabelsCell(props: {
3
- labels: string[];
4
- }): JSX.Element;
5
- export declare function DateCell(props: {
6
- value: number | string;
7
- }): JSX.Element;
8
- export declare function CopyCell(props: {
9
- text?: string;
10
- minWidth?: number;
11
- }): JSX.Element;
12
- export declare function SinceCell(props: {
13
- value: string | undefined | null;
14
- author?: string;
15
- onClick?: () => void;
16
- t?: (t: string) => string;
17
- }): JSX.Element;
18
- export declare function CapacityCell(props: {
19
- format?: string;
20
- used: number;
21
- capacity: number;
22
- }): JSX.Element;
23
- export declare function BytesCell(props: {
24
- bytes: number;
25
- decimals?: number;
26
- }): JSX.Element;