@fixefy/fixefy-ui-utils 0.2.1 → 0.2.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.
@@ -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;
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';
@@ -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,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
+ };
@@ -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);
@@ -297,8 +297,8 @@ const theme = (0, _styles.createTheme)({
297
297
  background: '#EB5757'
298
298
  },
299
299
  in_dispute: {
300
- border: '#56CCF2',
301
- background: '#56CCF2'
300
+ border: '#EC6AC8',
301
+ background: '#EC6AC8'
302
302
  },
303
303
  in_progress: {
304
304
  border: '#56CCF2',
@@ -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
+ };
package/package.json CHANGED
@@ -4,7 +4,9 @@
4
4
  "fs": false
5
5
  },
6
6
  "dependencies": {
7
+ "@fixefy/fixefy-ui-components": "0.2.0",
7
8
  "@mui/material": "^5.15.19",
9
+ "@mui/styled-engine": "^5.15.14",
8
10
  "@mui/styles": "^5.15.19",
9
11
  "aws-sdk": "^2.1632.0",
10
12
  "convert-excel-to-json": "^1.7.0",
@@ -13,6 +15,7 @@
13
15
  "react-dom": "^18.3.1"
14
16
  },
15
17
  "devDependencies": {
18
+ "@svgr/webpack": "^8.1.0",
16
19
  "@types/convert-excel-to-json": "^1.7.4",
17
20
  "@types/node": "^20.14.0",
18
21
  "@types/nookies": "^2.0.3",
@@ -34,9 +37,14 @@
34
37
  "url": "https://github.com/Fixefy/fixefy-commander.git"
35
38
  },
36
39
  "scripts": {
37
- "build": "swc src -d dist --strip-leading-paths && tsc --declaration --emitDeclarationOnly --outDir dist",
40
+ "build": "swc src -d dist && tsc --declaration --emitDeclarationOnly --outDir dist",
41
+ "build:copy": "node ../../scripts/copy-files-ex.js",
38
42
  "pre_release": "yarn clean && yarn && yarn build",
39
- "release:rawotp" : "npm publish --userconfig ./.npmrc --otp 000000",
43
+ "release17": "node version-check.js 17 && yarn pre_release && npm pack && npm publish",
44
+ "release17:config": "node version-check.js 17 && yarn pre_release && npm publish --userconfig ./.npmrc",
45
+ "release18": "node version-check.js 18 && yarn pre_release && npm pack && npm publish",
46
+ "release18:config": "node version-check.js 18 && yarn pre_release && npm publish --userconfig ./.npmrc",
47
+ "raw_publish": "npm publish --userconfig ./.npmrc --otp=000000",
40
48
  "clean": "rm -rf build && rm -rf dist-* && yarn clean:node",
41
49
  "clean:node": "rm -rf node_modules",
42
50
  "lint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
@@ -57,5 +65,5 @@
57
65
  "require": "./dist/index.js"
58
66
  }
59
67
  },
60
- "version": "0.2.1"
68
+ "version": "0.2.3"
61
69
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes