@rpcbase/client 0.215.0 → 0.216.0

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,48 @@
1
+ import {
2
+ QueryBuilderBootstrap,
3
+ bootstrapControlClassnames,
4
+ bootstrapControlElements,
5
+ } from "@react-querybuilder/bootstrap"
6
+ import {QueryBuilder as ReactQueryBuilder} from "react-querybuilder"
7
+ import {QueryBuilderDnD as ReactQueryBuilderDnD} from "@react-querybuilder/dnd"
8
+ import * as ReactDnD from "react-dnd"
9
+ import * as ReactDnDHtml5Backend from "react-dnd-html5-backend"
10
+
11
+ // import FieldSelector from "./FieldSelector"
12
+ // import OperatorSelector from "./OperatorSelector"
13
+ // import ValueEditor from "./ValueEditor"
14
+
15
+ import "./query-builder.scss"
16
+
17
+
18
+ const controlClassnames = {...bootstrapControlClassnames}
19
+ controlClassnames.queryBuilder += " queryBuilder-branches"
20
+
21
+ const QueryBuilder = ({controlElements = {}, ...props}) => {
22
+ return (
23
+ <ReactQueryBuilderDnD dnd={{...ReactDnD, ...ReactDnDHtml5Backend}}>
24
+ <QueryBuilderBootstrap>
25
+ <ReactQueryBuilder
26
+ addRuleToNewGroups
27
+ // TODO: why is DnD not working??
28
+ // https://react-querybuilder.js.org/docs/components/querybuilder#enabledraganddrop
29
+ enableDragAndDrop
30
+ showCombinatorsBetweenRules={false}
31
+ showNotToggle
32
+ showCloneButtons
33
+ controlClassnames={controlClassnames}
34
+ controlElements={{
35
+ ...bootstrapControlElements,
36
+ ...controlElements,
37
+ // fieldSelector: FieldSelector,
38
+ // operatorSelector: OperatorSelector,
39
+ // valueEditor: ValueEditor,
40
+ }}
41
+ {...props}
42
+ />
43
+ </QueryBuilderBootstrap>
44
+ </ReactQueryBuilderDnD>
45
+ )
46
+ }
47
+
48
+ export default QueryBuilder
@@ -0,0 +1,5 @@
1
+
2
+
3
+ export const TargetSelector = () => {
4
+
5
+ }
@@ -0,0 +1,9 @@
1
+ @import "helpers";
2
+
3
+ .queryBuilder {
4
+ .dropdown-item.active {
5
+ .text-secondary {
6
+ color: $gray-200 !important;
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,70 @@
1
+ import {useState} from "react"
2
+
3
+
4
+ const TARGET_TYPES = [
5
+ {
6
+ name: "Collection:",
7
+ key: "collection",
8
+ description: "Applies to all documents within the collection.",
9
+ },
10
+ {
11
+ name: "Document:",
12
+ key: "document",
13
+ description: "Applies only to certain specific documents.",
14
+ },
15
+ ]
16
+
17
+ export const PolicyEditor = () => {
18
+ const [targetType, setTargetType] = useState("collection")
19
+
20
+ const onChangeTargetType = (event) => {
21
+ setTargetType(event.target.value)
22
+ }
23
+
24
+ return (
25
+ <div>
26
+ <h6>Policy Editor</h6>
27
+ <br />
28
+ <div className="d-flex flex-row">
29
+ <div className="me-2">
30
+ <h6>Target Type:</h6>
31
+ <div style={{maxWidth: 300}}>
32
+ {TARGET_TYPES.map((type) => (
33
+ <div key={type.key} className="d-flex flex-row mb-1">
34
+ <input
35
+ className="form-check-input"
36
+ type="radio"
37
+ name="targetTypeOptions"
38
+ id={type.key}
39
+ value={type.key}
40
+ checked={targetType === type.key}
41
+ onChange={onChangeTargetType}
42
+ />
43
+ <label
44
+ className="form-check-label cursor-pointer ps-2"
45
+ htmlFor={type.key}
46
+ >
47
+ <b>{type.name}</b> {type.description}
48
+ </label>
49
+ </div>
50
+ ))}
51
+ </div>
52
+ </div>
53
+
54
+ <div>
55
+ <h6>Targets:</h6>
56
+ <div>
57
+ <input type="text" />
58
+ </div>
59
+ </div>
60
+ </div>
61
+ grant / deny
62
+ <br />
63
+ Scope: document, field
64
+ <br />
65
+ operation: create read write delete
66
+ <br />
67
+ to attributes / conditions add support for expiry date
68
+ </div>
69
+ )
70
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./ACLModal"
2
2
  export * from "./ACLForm"
3
+ export * from "./PolicyEditor"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.215.0",
3
+ "version": "0.216.0",
4
4
  "scripts": {
5
5
  "build": "../../node_modules/.bin/wireit",
6
6
  "test": "../../node_modules/.bin/wireit"
@@ -1,5 +1,6 @@
1
1
  import "./select-pills.scss"
2
2
 
3
+
3
4
  type Props = {
4
5
  direction?: "row" | "col";
5
6
  size?: "md" | "sm";
@@ -16,11 +17,11 @@ export const SelectPills= ({
16
17
  activeKey,
17
18
  }: Props) => {
18
19
  const handleSelectType = (type: string) => () => {
19
- onChange(type);
20
- };
20
+ onChange(type)
21
+ }
21
22
 
22
23
  const renderRow = () => {
23
- const iconSize = size === "sm" ? "24px" : "32px";
24
+ const iconSize = size === "sm" ? "24px" : "32px"
24
25
 
25
26
  return (
26
27
  <div className={`select-pills mb-3 card-group direction-row`}>
@@ -48,11 +49,11 @@ export const SelectPills= ({
48
49
  </div>
49
50
  ))}
50
51
  </div>
51
- );
52
- };
52
+ )
53
+ }
53
54
 
54
55
  const renderCol = () => {
55
- const iconSize = size === "sm" ? "24px" : "32px";
56
+ const iconSize = size === "sm" ? "24px" : "32px"
56
57
 
57
58
  return (
58
59
  <div className="select-pills">
@@ -64,11 +65,14 @@ export const SelectPills= ({
64
65
  onClick={handleSelectType(item.key)}
65
66
  >
66
67
  <div className="card-body d-flex flex-row px-2 py-3">
67
- <img
68
- className="d-flex align-self-center me-2"
69
- style={{ width: iconSize, height: iconSize }}
70
- src={item.icon}
71
- />
68
+ {item.icon && (
69
+ <img
70
+ className="d-flex align-self-center me-2"
71
+ style={{width: iconSize, height: iconSize}}
72
+ src={item.icon}
73
+ />
74
+ )}
75
+
72
76
  {size === "md" && (
73
77
  <div className="flex-column">
74
78
  <h6 className="card-title mb-1 fw-bold">{item.name}</h6>
@@ -77,7 +81,7 @@ export const SelectPills= ({
77
81
  )}
78
82
  {size === "sm" && (
79
83
  <div className="">
80
- <h6 className="card-title my-0 d-inline-block me-2 fw-bold">{item.name}</h6>
84
+ <h6 className="card-title my-0 d-inline-block me-1 fw-bold">{item.name}</h6>
81
85
  <span className="card-text">{item.description}</span>
82
86
  </div>
83
87
  )}
@@ -85,8 +89,8 @@ export const SelectPills= ({
85
89
  </div>
86
90
  ))}
87
91
  </div>
88
- );
89
- };
92
+ )
93
+ }
90
94
 
91
- return direction === "row" ? renderRow() : renderCol();
92
- };
95
+ return direction === "row" ? renderRow() : renderCol()
96
+ }