@izara_frontend/shared-complex-filter 1.0.1

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,113 @@
1
+ import React, { useState, useEffect, useCallback, useMemo } from "react";
2
+ import { useImmer } from "use-immer";
3
+ import {
4
+ IzaraDivStyle,
5
+ IzaraButtonStyle,
6
+ createStyleDefualtTags,
7
+ createStyleTags,
8
+ } from "@izaraFrontends/styles";
9
+
10
+ var hash = require("object-hash");
11
+
12
+ function createObjTypeConcat(objType) {
13
+ console.log("objType:dfcvcbcxb ", objType);
14
+
15
+ return `${objType.serviceTag}_${objType.objectType}`;
16
+ }
17
+ function createRelTypeConcat(relType) {
18
+ console.log("objType:sdsadwsd ", relType);
19
+ return `${relType?.serviceTag}_${relType?.relationshipTag}`;
20
+ }
21
+ function objTypeFromObjTypeConcat(objTypeConcat) {
22
+ console.log("objTypeConcat:aeaeaeww ", objTypeConcat);
23
+ let result = objTypeConcat.split("_");
24
+
25
+ if (result.length !== 2) {
26
+ throw Error("objTypeConcat invalid");
27
+ }
28
+
29
+ return {
30
+ serviceTag: result[0],
31
+ objectType: result[1],
32
+ };
33
+ }
34
+
35
+ export const FieldNameComponent = ({
36
+ objTypeMain,
37
+ setLinkSteps,
38
+ linkSteps,
39
+ linkStepsOutput,
40
+ resultFieldName,
41
+ }) => {
42
+ function handelSelectFieldName(e) {
43
+ let value = e.target.value;
44
+
45
+ setLinkSteps((linkSteps) => {
46
+ linkSteps[linkStepsOutput.active] = {
47
+ fieldName: value,
48
+ };
49
+ });
50
+ }
51
+
52
+ return (
53
+ <>
54
+ {linkStepsOutput.status === "lastStep" && (
55
+ <>
56
+ <>
57
+ {!resultFieldName[
58
+ linkStepsOutput.active === 0
59
+ ? createObjTypeConcat(objTypeMain)
60
+ : createObjTypeConcat(
61
+ linkSteps[linkStepsOutput.active - 1].pathLinkType.objType,
62
+ )
63
+ ] ? (
64
+ <IzaraDivStyle
65
+ styletags={createStyleDefualtTags(
66
+ "loadingCircle",
67
+ "20px",
68
+ "template",
69
+ )}
70
+ ></IzaraDivStyle>
71
+ ) : (
72
+ <>
73
+ <IzaraDivStyle
74
+ styletags={createStyleDefualtTags(
75
+ "background",
76
+ "scroll",
77
+ "div",
78
+ )}
79
+ >
80
+ <p> fieldname:</p>
81
+ <select
82
+ value={linkSteps[linkStepsOutput.active]?.fieldName}
83
+ onChange={(e) => {
84
+ handelSelectFieldName(e);
85
+ }}
86
+ >
87
+ <option value="">-- fieldName --</option>
88
+ {Object.keys(
89
+ resultFieldName[
90
+ linkStepsOutput.active === 0
91
+ ? createObjTypeConcat(objTypeMain)
92
+ : createObjTypeConcat(
93
+ linkSteps[linkStepsOutput.active - 1].pathLinkType
94
+ .objType,
95
+ )
96
+ ].fieldNames,
97
+ ).map((key) => (
98
+ <option key={key} value={key}>
99
+ {key}
100
+ </option>
101
+ ))}
102
+ </select>
103
+ </IzaraDivStyle>
104
+ </>
105
+ )}
106
+ </>
107
+ </>
108
+ )}
109
+ </>
110
+ );
111
+ };
112
+
113
+ //----------------------------- use Lib -----------------------------------------------
@@ -0,0 +1,109 @@
1
+ // import React, { memo, Fragment, useContext, useEffect, useState } from "react";
2
+ // import { createAction } from "@reduxjs/toolkit";
3
+ // import {
4
+ // IzaraDivStyle,
5
+ // createStyleDefualtTags,
6
+ // IzaraButtonStyle,
7
+ // } from "@izaraFrontends/styles";
8
+ import { useImmer } from "use-immer";
9
+ import { useDispatch, useSelector } from "react-redux";
10
+
11
+ //----------------------------Lib-Test------------------------------
12
+ import { valueUserTagCreateConfig } from "../function/createActionLibCreateLinkStepAndComplexFilter";
13
+
14
+ export const UserTagsSelectAndCreateComponent = ({
15
+ parentOutputId,
16
+ valueUserTags,
17
+ handleSelectUserTag,
18
+ valueSelect,
19
+ }) => {
20
+ const dispatch = useDispatch();
21
+
22
+ const [objCreateValueUserTag, setObjCreateValueUserTag] = useImmer({});
23
+
24
+ function handleChangeValueUserTag(e, type, value) {
25
+ setObjCreateValueUserTag((objCreateValueUserTag) => {
26
+ objCreateValueUserTag[type] = value;
27
+ });
28
+ }
29
+
30
+ function handleCreateuserTagTypeValue() {
31
+ setObjCreateValueUserTag({
32
+ keyName: "",
33
+ defaultValue: "",
34
+ });
35
+ }
36
+
37
+ function handleAddValueUserTag() {
38
+ dispatch(
39
+ valueUserTagCreateConfig({
40
+ parentOutputId: parentOutputId,
41
+ objCreateValueUserTag: objCreateValueUserTag,
42
+ }),
43
+ );
44
+ setObjCreateValueUserTag({});
45
+ }
46
+
47
+ return (
48
+ <>
49
+ <fieldset>
50
+ <legend>valueUserTag</legend>
51
+ <select value={valueSelect} onChange={(e) => handleSelectUserTag(e)}>
52
+ <option>choose userTag</option>
53
+ {Object.keys(valueUserTags).map((key) => (
54
+ <option key={key} value={key}>
55
+ {key}
56
+ </option>
57
+ ))}
58
+ </select>
59
+ </fieldset>
60
+ <>
61
+ {Object.keys(objCreateValueUserTag).length > 0 && (
62
+ <>
63
+ <fieldset>
64
+ <legend>userTagName</legend>
65
+ <input
66
+ onChange={(e) => {
67
+ handleChangeValueUserTag(e, "keyName", e.target.value);
68
+ }}
69
+ value={objCreateValueUserTag.keyName}
70
+ ></input>
71
+ </fieldset>
72
+
73
+ <>
74
+ <fieldset>
75
+ <legend>defaultValue</legend>
76
+ null
77
+ <input
78
+ type="checkbox"
79
+ checked={objCreateValueUserTag.defaultValue}
80
+ onChange={(e) =>
81
+ handleChangeValueUserTag(
82
+ e,
83
+ "defaultValue",
84
+ e.target.checked ? null : "",
85
+ )
86
+ }
87
+ ></input>
88
+ <input
89
+ onChange={(e) =>
90
+ handleChangeValueUserTag(e, "defaultValue", e.target.value)
91
+ }
92
+ value={objCreateValueUserTag.defaultValue}
93
+ disabled={objCreateValueUserTag.defaultValue === null}
94
+ ></input>
95
+ </fieldset>
96
+ </>
97
+ <button onClick={() => handleAddValueUserTag()}>
98
+ add valueUserTag
99
+ </button>
100
+ </>
101
+ )}
102
+
103
+ <button onClick={() => handleCreateuserTagTypeValue()}>
104
+ create valueUserTag
105
+ </button>
106
+ </>
107
+ </>
108
+ );
109
+ };
@@ -0,0 +1,153 @@
1
+ const { resolve } = require("path");
2
+ // import { resolve } from 'path'
3
+ const webpack = require("webpack");
4
+
5
+ // export default {
6
+ module.exports = {
7
+ mode: "development",
8
+ entry: "./src/index.js",
9
+
10
+ output: {
11
+ path: resolve("dist"),
12
+ filename: "complexFilter.js",
13
+ libraryTarget: "commonjs2",
14
+ },
15
+
16
+ plugins: [
17
+ // fix "process is not defined" error:
18
+ // new webpack.ProvidePlugin({
19
+ // process: "process/browser",
20
+ // }),
21
+ // new webpack.ProvidePlugin({
22
+ // Buffer: ["buffer", "Buffer"],
23
+ // process: "process/browser",
24
+ // }),
25
+ ],
26
+ module: {
27
+ // noParse: [
28
+ // /backend-request/, /create.js/
29
+ // ],
30
+
31
+ rules: [
32
+ {
33
+ test: /\.(js|ts)x?$/,
34
+ exclude: /(node_modules)/,
35
+ use: {
36
+ loader: "babel-loader",
37
+ options: {
38
+ babelrc: false,
39
+ presets: ["@babel/preset-env", "@babel/preset-react"],
40
+ // presets: ['babel-preset-env', 'babel-preset-react'],
41
+ },
42
+ },
43
+ },
44
+ {
45
+ test: /\.(png|jp(e*)g|svg|gif)$/, //has file all img
46
+ // type: "src/icon",
47
+ use: [
48
+ {
49
+ loader: "file-loader",
50
+ options: {
51
+ name: "./src/icon/[hash]-[name].[ext]",
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ { test: /\.css$/, use: ["style-loader", "css-loader"] }, //has .css file in npm
57
+ { test: /\.ts$/, use: "ts-loader" },
58
+ ],
59
+ },
60
+ resolve: {
61
+ // fallback: {
62
+ // buffer: require.resolve("buffer/"),
63
+ // process: require.resolve("process/browser"),
64
+ // },
65
+ // fallback: {
66
+ // process: false,
67
+ // buffer: false,
68
+ // crypto: false,
69
+ // stream: false,
70
+ // },
71
+
72
+ alias: {
73
+ react: resolve("./node_modules/react"),
74
+ "react-dom": resolve("./node_modules/react-dom"),
75
+ },
76
+ extensions: [".js", ".jsx"],
77
+
78
+ // fallback: {
79
+ // fs: false,
80
+ // },
81
+ // importsFields: ['@izaraFrontends/styles', '@izaraFrontends/authentication$'],
82
+ // descriptionFiles: []
83
+ },
84
+
85
+ externals: {
86
+ react: {
87
+ commonjs: "react",
88
+ commonjs2: "react",
89
+ amd: "React",
90
+ root: "React",
91
+ },
92
+ "react-dom": {
93
+ commonjs: "react-dom",
94
+ commonjs2: "react-dom",
95
+ amd: "ReactDOM",
96
+ root: "ReactDOM",
97
+ },
98
+ "react-redux": {
99
+ commonjs: "react-redux",
100
+ commonjs2: "react-redux",
101
+ amd: "react-redux",
102
+ root: "react-redux",
103
+ },
104
+ "@reduxjs/toolkit": {
105
+ commonjs: "@reduxjs/toolkit",
106
+ commonjs2: "@reduxjs/toolkit",
107
+ amd: "@reduxjs/toolkit",
108
+ root: "@reduxjs/toolkit",
109
+ },
110
+ "use-immer": {
111
+ commonjs: "use-immer",
112
+ commonjs2: "use-immer",
113
+ amd: "use-immer",
114
+ root: "use-immer",
115
+ },
116
+ nanoid: {
117
+ commonjs: "nanoid",
118
+ commonjs2: "nanoid",
119
+ amd: "nanoid",
120
+ root: "nanoid",
121
+ },
122
+ "object-hash": {
123
+ commonjs: "object-hash",
124
+ commonjs2: "object-hash",
125
+ amd: "object-hash",
126
+ root: "object-hash",
127
+ },
128
+ "@izaraFrontends/styles": {
129
+ commonjs: "@izaraFrontends/styles",
130
+ commonjs2: "@izaraFrontends/styles",
131
+ amd: "@izaraFrontends/styles",
132
+ root: "@izaraFrontends/styles",
133
+ },
134
+ "@izaraFrontends/store": {
135
+ commonjs: "@izaraFrontends/store",
136
+ commonjs2: "@izaraFrontends/store",
137
+ amd: "@izaraFrontends/store",
138
+ root: "@izaraFrontends/store",
139
+ },
140
+ "@izara_project/izara-shared-search-and-sort": {
141
+ commonjs: "@izara_project/izara-shared-search-and-sort",
142
+ commonjs2: "@izara_project/izara-shared-search-and-sort",
143
+ amd: "@izara_project/izara-shared-search-and-sort",
144
+ root: "@izara_project/izara-shared-search-and-sort",
145
+ },
146
+ "@izara_project/izara-shared-service-schemas": {
147
+ commonjs: "@izara_project/izara-shared-service-schemas",
148
+ commonjs2: "@izara_project/izara-shared-service-schemas",
149
+ amd: "@izara_project/izara-shared-service-schemas",
150
+ root: "@izara_project/izara-shared-service-schemas",
151
+ },
152
+ },
153
+ };