@react-querybuilder/bootstrap 4.0.0-beta.6

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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sapient Global Markets
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## @react-querybuilder/bootstrap
2
+
3
+ Custom [Bootstrap](https://getbootstrap.com/) components for [react-querybuilder](https://npmjs.com/package/react-querybuilder).
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var u=require("react");function b(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var t=b(u),E=u.forwardRef(function({className:l,title:c},r){return t.default.createElement("span",{ref:r,className:l,title:c},t.default.createElement("i",{className:"bi bi-grip-vertical"}))});const i=({className:a,handleOnChange:l,title:c,label:r,checked:o})=>{const[n]=u.useState(`notToggle-${Math.random()}`);return t.default.createElement("div",{className:`form-check-inline form-switch ${a}`},t.default.createElement("input",{id:n,className:"form-check-input",type:"checkbox",onChange:s=>l(s.target.checked),checked:!!o}),t.default.createElement("label",{title:c,htmlFor:n,className:"form-check-label"},r))};i.displayName="BootstrapNotToggle";const p=({fieldData:a,operator:l,value:c,handleOnChange:r,title:o,className:n,type:s,inputType:m,values:d})=>{var f;if(u.useEffect(()=>{m==="number"&&!["between","notBetween"].includes(l)&&typeof c=="string"&&c.includes(",")&&r("")},[m,l,c,r]),l==="null"||l==="notNull")return null;const g=(f=a==null?void 0:a.placeholder)!=null?f:"",h=["between","notBetween"].includes(l)?"text":m||"text";switch(s){case"select":return t.default.createElement("select",{className:`${n} form-select form-select-sm`,title:o,onChange:e=>r(e.target.value),value:c},d.map(e=>t.default.createElement("option",{key:e.name,value:e.name},e.label)));case"checkbox":return t.default.createElement("input",{type:"checkbox",className:`form-check-input ${n}`,title:o,onChange:e=>r(e.target.checked),checked:!!c});case"radio":return t.default.createElement("span",{title:o},d.map(e=>t.default.createElement("div",{key:e.name,className:"form-check form-check-inline"},t.default.createElement("input",{className:"form-check-input",type:"radio",id:e.name,value:e.name,checked:c===e.name,onChange:k=>r(k.target.value)}),t.default.createElement("label",{className:"form-check-label",htmlFor:e.name},e.label))));default:return t.default.createElement("input",{type:h,value:c,title:o,className:n,placeholder:g,onChange:e=>r(e.target.value)})}};p.displayName="ValueEditor";exports.BootstrapDragHandle=E;exports.BootstrapNotToggle=i;exports.BootstrapValueEditor=p;
@@ -0,0 +1,104 @@
1
+ import React, { forwardRef, useState, useEffect } from "react";
2
+ var BootstrapDragHandle = forwardRef(function BootstrapDragHandle2({ className, title }, dragRef) {
3
+ return /* @__PURE__ */ React.createElement("span", {
4
+ ref: dragRef,
5
+ className,
6
+ title
7
+ }, /* @__PURE__ */ React.createElement("i", {
8
+ className: "bi bi-grip-vertical"
9
+ }));
10
+ });
11
+ const BootstrapNotToggle = ({
12
+ className,
13
+ handleOnChange,
14
+ title,
15
+ label,
16
+ checked
17
+ }) => {
18
+ const [id] = useState(`notToggle-${Math.random()}`);
19
+ return /* @__PURE__ */ React.createElement("div", {
20
+ className: `form-check-inline form-switch ${className}`
21
+ }, /* @__PURE__ */ React.createElement("input", {
22
+ id,
23
+ className: "form-check-input",
24
+ type: "checkbox",
25
+ onChange: (e) => handleOnChange(e.target.checked),
26
+ checked: !!checked
27
+ }), /* @__PURE__ */ React.createElement("label", {
28
+ title,
29
+ htmlFor: id,
30
+ className: "form-check-label"
31
+ }, label));
32
+ };
33
+ BootstrapNotToggle.displayName = "BootstrapNotToggle";
34
+ const BootstrapValueEditor = ({
35
+ fieldData,
36
+ operator,
37
+ value,
38
+ handleOnChange,
39
+ title,
40
+ className,
41
+ type,
42
+ inputType,
43
+ values
44
+ }) => {
45
+ var _a;
46
+ useEffect(() => {
47
+ if (inputType === "number" && !["between", "notBetween"].includes(operator) && typeof value === "string" && value.includes(",")) {
48
+ handleOnChange("");
49
+ }
50
+ }, [inputType, operator, value, handleOnChange]);
51
+ if (operator === "null" || operator === "notNull") {
52
+ return null;
53
+ }
54
+ const placeHolderText = (_a = fieldData == null ? void 0 : fieldData.placeholder) != null ? _a : "";
55
+ const inputTypeCoerced = ["between", "notBetween"].includes(operator) ? "text" : inputType || "text";
56
+ switch (type) {
57
+ case "select":
58
+ return /* @__PURE__ */ React.createElement("select", {
59
+ className: `${className} form-select form-select-sm`,
60
+ title,
61
+ onChange: (e) => handleOnChange(e.target.value),
62
+ value
63
+ }, values.map((v) => /* @__PURE__ */ React.createElement("option", {
64
+ key: v.name,
65
+ value: v.name
66
+ }, v.label)));
67
+ case "checkbox":
68
+ return /* @__PURE__ */ React.createElement("input", {
69
+ type: "checkbox",
70
+ className: `form-check-input ${className}`,
71
+ title,
72
+ onChange: (e) => handleOnChange(e.target.checked),
73
+ checked: !!value
74
+ });
75
+ case "radio":
76
+ return /* @__PURE__ */ React.createElement("span", {
77
+ title
78
+ }, values.map((v) => /* @__PURE__ */ React.createElement("div", {
79
+ key: v.name,
80
+ className: "form-check form-check-inline"
81
+ }, /* @__PURE__ */ React.createElement("input", {
82
+ className: "form-check-input",
83
+ type: "radio",
84
+ id: v.name,
85
+ value: v.name,
86
+ checked: value === v.name,
87
+ onChange: (e) => handleOnChange(e.target.value)
88
+ }), /* @__PURE__ */ React.createElement("label", {
89
+ className: "form-check-label",
90
+ htmlFor: v.name
91
+ }, v.label))));
92
+ default:
93
+ return /* @__PURE__ */ React.createElement("input", {
94
+ type: inputTypeCoerced,
95
+ value,
96
+ title,
97
+ className,
98
+ placeholder: placeHolderText,
99
+ onChange: (e) => handleOnChange(e.target.value)
100
+ });
101
+ }
102
+ };
103
+ BootstrapValueEditor.displayName = "ValueEditor";
104
+ export { BootstrapDragHandle, BootstrapNotToggle, BootstrapValueEditor };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { DragHandleProps } from 'react-querybuilder';
3
+ declare const _default: import("react").ForwardRefExoticComponent<DragHandleProps & import("react").RefAttributes<HTMLSpanElement>>;
4
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { NotToggleProps } from 'react-querybuilder';
3
+ declare const BootstrapNotToggle: {
4
+ ({ className, handleOnChange, title, label, checked }: NotToggleProps): JSX.Element;
5
+ displayName: string;
6
+ };
7
+ export default BootstrapNotToggle;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { ValueEditorProps } from 'react-querybuilder';
3
+ declare const BootstrapValueEditor: {
4
+ ({ fieldData, operator, value, handleOnChange, title, className, type, inputType, values }: ValueEditorProps): JSX.Element | null;
5
+ displayName: string;
6
+ };
7
+ export default BootstrapValueEditor;
@@ -0,0 +1,3 @@
1
+ export { default as BootstrapDragHandle } from './BootstrapDragHandle';
2
+ export { default as BootstrapNotToggle } from './BootstrapNotToggle';
3
+ export { default as BootstrapValueEditor } from './BootstrapValueEditor';
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@react-querybuilder/bootstrap",
3
+ "description": "Custom Bootstrap components for react-querybuilder",
4
+ "version": "4.0.0-beta.6",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "dist/index.cjs.js",
9
+ "module": "dist/index.es.js",
10
+ "types": "dist/types/index.d.ts",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/react-querybuilder/react-querybuilder"
17
+ },
18
+ "license": "MIT",
19
+ "homepage": "https://react-querybuilder.js.org/",
20
+ "scripts": {
21
+ "build": "vite build && tsc --emitDeclarationOnly"
22
+ },
23
+ "devDependencies": {
24
+ "@types/react": "^17.0.0",
25
+ "bootstrap-icons": "^1.7.0",
26
+ "react": "^17.0.1",
27
+ "react-querybuilder": "^4.0.0-beta.6",
28
+ "typescript": "^4.5.0"
29
+ },
30
+ "peerDependencies": {
31
+ "bootstrap-icons": ">=1.7.0",
32
+ "react": ">=16.8.0",
33
+ "react-querybuilder": "4.0.0-beta.5"
34
+ },
35
+ "gitHead": "484708b1405f14cafef165248e258e4ff679da6b"
36
+ }