@fixefy/fixefy-ui-utils 0.2.1 → 0.2.2

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,3 @@
1
+ export declare const parseInput: ({ client, fetcher, control, structure, droppedItem, state, onInputChange, classes, args, ...rest }: {
2
+ [x: string]: any;
3
+ }) => any;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "parseInput", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseInput;
9
+ }
10
+ });
11
+ const _jsxruntime = require("react/jsx-runtime");
12
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
+ const _ = require("../");
14
+ const _fixefyuicomponents = require("@fixefy/fixefy-ui-components");
15
+ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
27
+ }
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ function _object_spread(target) {
34
+ for(var i = 1; i < arguments.length; i++){
35
+ var source = arguments[i] != null ? arguments[i] : {};
36
+ var ownKeys = Object.keys(source);
37
+ if (typeof Object.getOwnPropertySymbols === "function") {
38
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
39
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
40
+ }));
41
+ }
42
+ ownKeys.forEach(function(key) {
43
+ _define_property(target, key, source[key]);
44
+ });
45
+ }
46
+ return target;
47
+ }
48
+ function ownKeys(object, enumerableOnly) {
49
+ var keys = Object.keys(object);
50
+ if (Object.getOwnPropertySymbols) {
51
+ var symbols = Object.getOwnPropertySymbols(object);
52
+ if (enumerableOnly) {
53
+ symbols = symbols.filter(function(sym) {
54
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
55
+ });
56
+ }
57
+ keys.push.apply(keys, symbols);
58
+ }
59
+ return keys;
60
+ }
61
+ function _object_spread_props(target, source) {
62
+ source = source != null ? source : {};
63
+ if (Object.getOwnPropertyDescriptors) {
64
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
65
+ } else {
66
+ ownKeys(Object(source)).forEach(function(key) {
67
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ function _object_without_properties(source, excluded) {
73
+ if (source == null) return {};
74
+ var target = _object_without_properties_loose(source, excluded);
75
+ var key, i;
76
+ if (Object.getOwnPropertySymbols) {
77
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
78
+ for(i = 0; i < sourceSymbolKeys.length; i++){
79
+ key = sourceSymbolKeys[i];
80
+ if (excluded.indexOf(key) >= 0) continue;
81
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
82
+ target[key] = source[key];
83
+ }
84
+ }
85
+ return target;
86
+ }
87
+ function _object_without_properties_loose(source, excluded) {
88
+ if (source == null) return {};
89
+ var target = {};
90
+ var sourceKeys = Object.keys(source);
91
+ var key, i;
92
+ for(i = 0; i < sourceKeys.length; i++){
93
+ key = sourceKeys[i];
94
+ if (excluded.indexOf(key) >= 0) continue;
95
+ target[key] = source[key];
96
+ }
97
+ return target;
98
+ }
99
+ const parseInput = (_param)=>{
100
+ var { client, fetcher, control, structure, droppedItem, state, onInputChange, classes, args } = _param, rest = _object_without_properties(_param, [
101
+ "client",
102
+ "fetcher",
103
+ "control",
104
+ "structure",
105
+ "droppedItem",
106
+ "state",
107
+ "onInputChange",
108
+ "classes",
109
+ "args"
110
+ ]);
111
+ const { type, children } = structure;
112
+ const { AsyncDropdown, Textfield, clear, dropdownOptions } = _.ComponentTypes;
113
+ switch(type){
114
+ case AsyncDropdown:
115
+ {
116
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_fixefyuicomponents.FxAsyncDropdown, _object_spread({
117
+ classes: classes,
118
+ structure: structure,
119
+ fetcher: fetcher,
120
+ onChange: ()=>{}
121
+ }, rest));
122
+ }
123
+ case Textfield:
124
+ {
125
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_fixefyuicomponents.FxTextField, _object_spread({
126
+ autoFocus: true,
127
+ droppedItem: droppedItem,
128
+ defaultValue: args && args.data && args.data.default_value,
129
+ onChange: (e)=>onInputChange({
130
+ structure,
131
+ value: e.target.value
132
+ }),
133
+ structure: structure
134
+ }, rest));
135
+ }
136
+ case dropdownOptions:
137
+ return children.map((child)=>{
138
+ return parseInput(_object_spread({
139
+ client,
140
+ control,
141
+ structure: child,
142
+ droppedItem,
143
+ state,
144
+ onInputChange,
145
+ classes,
146
+ args
147
+ }, rest));
148
+ });
149
+ case clear:
150
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_fixefyuicomponents.FxButton, _object_spread_props(_object_spread({}, rest), {
151
+ children: structure.name
152
+ }));
153
+ }
154
+ };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './auth';
2
2
  export * from './aws';
3
3
  export * from './commander';
4
4
  export * from './constants';
5
+ export * from './contents';
5
6
  export * from './files';
6
7
  export * from './graphql';
7
8
  export * from './headers';
@@ -9,6 +10,7 @@ export * from './images';
9
10
  export * from './json';
10
11
  export * from './page_context';
11
12
  export * from './redirect';
13
+ export * from './renderer';
12
14
  export * from './transform';
13
15
  export * from './types';
14
16
  export * from './validate';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ _export_star(require("./auth"), exports);
12
12
  _export_star(require("./aws"), exports);
13
13
  _export_star(require("./commander"), exports);
14
14
  _export_star(require("./constants"), exports);
15
+ _export_star(require("./contents"), exports);
15
16
  _export_star(require("./files"), exports);
16
17
  _export_star(require("./graphql"), exports);
17
18
  _export_star(require("./headers"), exports);
@@ -19,6 +20,7 @@ _export_star(require("./images"), exports);
19
20
  _export_star(require("./json"), exports);
20
21
  const _page_context = /*#__PURE__*/ _interop_require_default(_export_star(require("./page_context"), exports));
21
22
  _export_star(require("./redirect"), exports);
23
+ _export_star(require("./renderer"), exports);
22
24
  _export_star(require("./transform"), exports);
23
25
  _export_star(require("./types"), exports);
24
26
  _export_star(require("./validate"), exports);
@@ -362,9 +362,13 @@ const theme = (0, _styles.createTheme)({
362
362
  border: '#56CCF2',
363
363
  background: '#56CCF2'
364
364
  },
365
- pending: {
366
- border: '#ECC631',
367
- background: '#ECC631'
365
+ approved: {
366
+ border: '#27AE60',
367
+ background: '#27AE60'
368
+ },
369
+ declined: {
370
+ border: '#EB5757',
371
+ background: '#EB5757'
368
372
  },
369
373
  approved: {
370
374
  border: '#27AE60',
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare const parseValue: ({ value, structure, onClick }: any) => any;
3
+ export declare const getValueComponentByComponentValue: ({ value, name, title, type, onClick, }: {
4
+ value?: any;
5
+ name?: string;
6
+ title?: string;
7
+ type?: any;
8
+ onClick?: any;
9
+ }) => React.JSX.Element;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getValueComponentByComponentValue: function() {
13
+ return getValueComponentByComponentValue;
14
+ },
15
+ parseValue: function() {
16
+ return parseValue;
17
+ }
18
+ });
19
+ const _jsxruntime = require("react/jsx-runtime");
20
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
21
+ const _material = require("@mui/material");
22
+ const _fixefyuicomponents = require("@fixefy/fixefy-ui-components");
23
+ const _ = require("../");
24
+ function _interop_require_default(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ const parseValue = ({ value, structure, onClick })=>{
30
+ //TODO: change active to enabled or disabled
31
+ const { extended, name, type, title } = structure;
32
+ // extract path if exists
33
+ const path = extended && extended.title_path;
34
+ let theTruth;
35
+ if (path) {
36
+ // extract the object in the path
37
+ theTruth = (0, _.getJPart)(value, path, undefined);
38
+ }
39
+ const _value = theTruth === undefined || theTruth === null ? value[name] : theTruth;
40
+ if (_value === undefined || _value === null) {
41
+ return getValueComponentByComponentValue({
42
+ value: 'No Value Found'
43
+ });
44
+ }
45
+ // get string value according to value type
46
+ let rv = (0, _.getStringValueByValueType)({
47
+ value: _value,
48
+ name
49
+ });
50
+ // parse wrapping component according to type
51
+ rv = getValueComponentByComponentValue({
52
+ value: rv,
53
+ name,
54
+ title,
55
+ type,
56
+ onClick: (e)=>onClick(e, _value)
57
+ });
58
+ return rv;
59
+ };
60
+ const getValueComponentByComponentValue = ({ value, name, title, type, onClick })=>{
61
+ let rv = null;
62
+ switch(type){
63
+ case _.ComponentTypes.Chip:
64
+ rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_fixefyuicomponents.FxChip, {
65
+ size: "small",
66
+ style: {
67
+ marginBottom: '5px'
68
+ },
69
+ status: value.toLowerCase(),
70
+ label: value
71
+ }, `${name}-Chip-3003`);
72
+ break;
73
+ case _.ComponentTypes.ClickableLabel:
74
+ rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
75
+ sx: {
76
+ marginBottom: '5px',
77
+ fontSize: '14px',
78
+ textDecoration: 'underline',
79
+ cursor: 'pointer'
80
+ },
81
+ variant: "body1",
82
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Link, {
83
+ onClick: onClick,
84
+ children: (0, _.titleCase)(value)
85
+ })
86
+ }, `${name}-Link-2002`);
87
+ break;
88
+ case _.ComponentTypes.Label:
89
+ if (Array.isArray(value) && (value === null || value === void 0 ? void 0 : value.length) > 1) {
90
+ rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_fixefyuicomponents.FxShowMore, {
91
+ items: value,
92
+ label: title !== null && title !== void 0 ? title : '',
93
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
94
+ lineHeight: '20px',
95
+ sx: {
96
+ fontSize: '14px'
97
+ },
98
+ variant: "body1",
99
+ children: (0, _.titleCase)(value[0])
100
+ }, `${name}-Label-1000`)
101
+ });
102
+ } else {
103
+ rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
104
+ lineHeight: '20px',
105
+ sx: {
106
+ fontSize: '14px'
107
+ },
108
+ variant: "body1",
109
+ children: (0, _.titleCase)(value)
110
+ }, `${name}-Label-1000`);
111
+ }
112
+ break;
113
+ default:
114
+ rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
115
+ lineHeight: '20px',
116
+ sx: {
117
+ fontSize: '14px'
118
+ },
119
+ variant: "body1",
120
+ children: (0, _.titleCase)(value)
121
+ }, `${name}-Label-1000`);
122
+ break;
123
+ }
124
+ return rv;
125
+ };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ attachAuth: function() {
13
+ return attachAuth;
14
+ },
15
+ getToken: function() {
16
+ return getToken;
17
+ }
18
+ });
19
+ const _nookies = require("nookies");
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ function _object_spread(target) {
34
+ for(var i = 1; i < arguments.length; i++){
35
+ var source = arguments[i] != null ? arguments[i] : {};
36
+ var ownKeys = Object.keys(source);
37
+ if (typeof Object.getOwnPropertySymbols === "function") {
38
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
39
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
40
+ }));
41
+ }
42
+ ownKeys.forEach(function(key) {
43
+ _define_property(target, key, source[key]);
44
+ });
45
+ }
46
+ return target;
47
+ }
48
+ function ownKeys(object, enumerableOnly) {
49
+ var keys = Object.keys(object);
50
+ if (Object.getOwnPropertySymbols) {
51
+ var symbols = Object.getOwnPropertySymbols(object);
52
+ if (enumerableOnly) {
53
+ symbols = symbols.filter(function(sym) {
54
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
55
+ });
56
+ }
57
+ keys.push.apply(keys, symbols);
58
+ }
59
+ return keys;
60
+ }
61
+ function _object_spread_props(target, source) {
62
+ source = source != null ? source : {};
63
+ if (Object.getOwnPropertyDescriptors) {
64
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
65
+ } else {
66
+ ownKeys(Object(source)).forEach(function(key) {
67
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ const attachAuth = (ctx, headers)=>{
73
+ const token = getToken(ctx);
74
+ return _object_spread_props(_object_spread({}, headers), {
75
+ authorization: `Bearer ${token}`
76
+ });
77
+ };
78
+ const getToken = (ctx)=>{
79
+ return (0, _nookies.parseCookies)(ctx)['token'];
80
+ } // export const checkLoggedIn = async ({ client }) => {
81
+ // const rv = await client
82
+ // .query({ query: gql(ME_QUERY) })
83
+ // .then(({ data }) => ({ loggedInUser: data }))
84
+ // .catch(() => ({
85
+ // loggedInUser: null,
86
+ // })); // Fail gracefully
87
+ // return rv;
88
+ // };
89
+ ;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ generateMappings: function() {
13
+ return generateMappings;
14
+ },
15
+ getLambda: function() {
16
+ return getLambda;
17
+ },
18
+ getLambdaParams: function() {
19
+ return getLambdaParams;
20
+ },
21
+ getLambdaResult: function() {
22
+ return getLambdaResult;
23
+ }
24
+ });
25
+ const _awssdk = /*#__PURE__*/ _interop_require_default(require("aws-sdk"));
26
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
27
+ try {
28
+ var info = gen[key](arg);
29
+ var value = info.value;
30
+ } catch (error) {
31
+ reject(error);
32
+ return;
33
+ }
34
+ if (info.done) {
35
+ resolve(value);
36
+ } else {
37
+ Promise.resolve(value).then(_next, _throw);
38
+ }
39
+ }
40
+ function _async_to_generator(fn) {
41
+ return function() {
42
+ var self = this, args = arguments;
43
+ return new Promise(function(resolve, reject) {
44
+ var gen = fn.apply(self, args);
45
+ function _next(value) {
46
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
47
+ }
48
+ function _throw(err) {
49
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
50
+ }
51
+ _next(undefined);
52
+ });
53
+ };
54
+ }
55
+ function _define_property(obj, key, value) {
56
+ if (key in obj) {
57
+ Object.defineProperty(obj, key, {
58
+ value: value,
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true
62
+ });
63
+ } else {
64
+ obj[key] = value;
65
+ }
66
+ return obj;
67
+ }
68
+ function _interop_require_default(obj) {
69
+ return obj && obj.__esModule ? obj : {
70
+ default: obj
71
+ };
72
+ }
73
+ function _object_spread(target) {
74
+ for(var i = 1; i < arguments.length; i++){
75
+ var source = arguments[i] != null ? arguments[i] : {};
76
+ var ownKeys = Object.keys(source);
77
+ if (typeof Object.getOwnPropertySymbols === "function") {
78
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
79
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
80
+ }));
81
+ }
82
+ ownKeys.forEach(function(key) {
83
+ _define_property(target, key, source[key]);
84
+ });
85
+ }
86
+ return target;
87
+ }
88
+ function ownKeys(object, enumerableOnly) {
89
+ var keys = Object.keys(object);
90
+ if (Object.getOwnPropertySymbols) {
91
+ var symbols = Object.getOwnPropertySymbols(object);
92
+ if (enumerableOnly) {
93
+ symbols = symbols.filter(function(sym) {
94
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
95
+ });
96
+ }
97
+ keys.push.apply(keys, symbols);
98
+ }
99
+ return keys;
100
+ }
101
+ function _object_spread_props(target, source) {
102
+ source = source != null ? source : {};
103
+ if (Object.getOwnPropertyDescriptors) {
104
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
105
+ } else {
106
+ ownKeys(Object(source)).forEach(function(key) {
107
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
108
+ });
109
+ }
110
+ return target;
111
+ }
112
+ const getLambda = (args)=>{
113
+ const { key, region, secret } = args, lambdaCredentials = new _awssdk.default.Credentials({
114
+ accessKeyId: key,
115
+ secretAccessKey: secret
116
+ }), rv = new _awssdk.default.Lambda({
117
+ credentials: lambdaCredentials,
118
+ region,
119
+ maxRetries: 0,
120
+ httpOptions: {
121
+ connectTimeout: 30000,
122
+ timeout: 300000
123
+ }
124
+ });
125
+ return rv;
126
+ };
127
+ const getLambdaParams = (args)=>{
128
+ const { function_name: functionName } = args, // clientContextObj: unknown = { authorization, file_name, ws },
129
+ clientContext = '' //Buffer.from( JSON.stringify( clientContextObj ) ).toString( 'base64' )
130
+ ;
131
+ const rv = {
132
+ ClientContext: clientContext,
133
+ FunctionName: functionName,
134
+ InvocationType: 'RequestResponse',
135
+ Payload: ''
136
+ };
137
+ return rv;
138
+ };
139
+ const generateMappings = function() {
140
+ var _ref = _async_to_generator(function*(args) {
141
+ // get the lambda's params
142
+ const params = getLambdaParams(args);
143
+ // get lambda
144
+ const lambda = getLambda(args);
145
+ // create promise
146
+ const p = new Promise((resolve, reject)=>{
147
+ lambda.invoke(params, (err, data)=>{
148
+ if (err) {
149
+ reject(err);
150
+ } else {
151
+ resolve(data);
152
+ }
153
+ });
154
+ });
155
+ // execute lambda
156
+ const result = yield p;
157
+ // get result
158
+ const rv = getLambdaResult({
159
+ result
160
+ });
161
+ return rv;
162
+ });
163
+ return function generateMappings(args) {
164
+ return _ref.apply(this, arguments);
165
+ };
166
+ }();
167
+ const getLambdaResult = (args)=>{
168
+ const { result: { ExecutedVersion: executedVersion, FunctionError: functionError, LogResult: logResult, Payload: payload, StatusCode: statusCode } } = args;
169
+ let rv = {
170
+ execute_version: executedVersion,
171
+ function_error: functionError,
172
+ log_result: logResult,
173
+ status_code: statusCode
174
+ };
175
+ // input check - if payload is invalid - return empty object
176
+ if (payload != null) {
177
+ const payloadObject = JSON.parse(payload);
178
+ rv = _object_spread_props(_object_spread({}, rv), {
179
+ body: payloadObject,
180
+ error: payloadObject.errorMessage
181
+ });
182
+ }
183
+ return rv;
184
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./aws_lambda_helper"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }