typecomposer 0.0.8 → 0.0.9

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.
Files changed (32) hide show
  1. package/dist/cjs/core/element/action/CheckBox.d.ts +16 -8
  2. package/dist/cjs/core/element/action/CheckBox.js +57 -7
  3. package/dist/cjs/core/element/action/CheckBox.js.map +1 -1
  4. package/dist/cjs/core/element/action/DropDown.d.ts +40 -0
  5. package/dist/cjs/core/element/action/DropDown.js +159 -0
  6. package/dist/cjs/core/element/action/DropDown.js.map +1 -0
  7. package/dist/cjs/core/element/index.d.ts +3 -4
  8. package/dist/cjs/core/element/index.js +4 -5
  9. package/dist/cjs/core/element/index.js.map +1 -1
  10. package/dist/esm/core/element/action/CheckBox.d.ts +16 -8
  11. package/dist/esm/core/element/action/CheckBox.js +55 -6
  12. package/dist/esm/core/element/action/CheckBox.js.map +1 -1
  13. package/dist/esm/core/element/action/DropDown.d.ts +40 -0
  14. package/dist/esm/core/element/action/DropDown.js +154 -0
  15. package/dist/esm/core/element/action/DropDown.js.map +1 -0
  16. package/dist/esm/core/element/index.d.ts +3 -4
  17. package/dist/esm/core/element/index.js +4 -5
  18. package/dist/esm/core/element/index.js.map +1 -1
  19. package/package.json +2 -2
  20. package/styles/style.scss +108 -15
  21. package/dist/cjs/core/element/action/SelectBox.d.ts +0 -20
  22. package/dist/cjs/core/element/action/SelectBox.js +0 -77
  23. package/dist/cjs/core/element/action/SelectBox.js.map +0 -1
  24. package/dist/cjs/core/element/dropdown/DropdownElement.d.ts +0 -8
  25. package/dist/cjs/core/element/dropdown/DropdownElement.js +0 -34
  26. package/dist/cjs/core/element/dropdown/DropdownElement.js.map +0 -1
  27. package/dist/esm/core/element/action/SelectBox.d.ts +0 -20
  28. package/dist/esm/core/element/action/SelectBox.js +0 -73
  29. package/dist/esm/core/element/action/SelectBox.js.map +0 -1
  30. package/dist/esm/core/element/dropdown/DropdownElement.d.ts +0 -8
  31. package/dist/esm/core/element/dropdown/DropdownElement.js +0 -30
  32. package/dist/esm/core/element/dropdown/DropdownElement.js.map +0 -1
@@ -1,23 +1,31 @@
1
- import { Component, InputElement, LabelElement, StyleOptional, Variant, IconElement } from "../..";
2
- type ChecBoxType = "checkbox" | "radio";
1
+ import { Component, InputElement, LabelElement, StyleOptional, IconElement } from "../..";
3
2
  export declare class CheckBox extends Component {
4
3
  private _input;
5
4
  private _label;
6
5
  private static serial;
7
- private checBoxType;
6
+ private _variant;
8
7
  constructor(optional?: StyleOptional & {
9
- variant?: Variant;
10
- placeholder?: string;
8
+ variant?: "checkbox" | "radio";
9
+ label?: string;
10
+ value?: any;
11
11
  icon?: IconElement;
12
12
  placeholderAnimation?: boolean;
13
- checBoxType: ChecBoxType;
14
13
  });
15
- onChange: (checked: boolean) => void;
14
+ onChange: (checked: boolean, value?: any) => void;
15
+ get id(): string;
16
16
  get checked(): boolean;
17
17
  set checked(value: boolean);
18
18
  get value(): string;
19
19
  set value(value: string);
20
20
  get input(): InputElement;
21
21
  get label(): LabelElement;
22
+ get variant(): "checkbox" | "radio";
23
+ set variant(value: "checkbox" | "radio");
24
+ }
25
+ export declare class CheckBoxGroup extends Component {
26
+ constructor(...checkBoxes: CheckBox[]);
27
+ append(...nodes: (string | Node)[]): void;
28
+ appendChild<T extends Node>(node: T): T;
29
+ onChange: (checkbox: CheckBox) => void;
30
+ private check;
22
31
  }
23
- export {};
@@ -1,21 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckBox = void 0;
3
+ exports.CheckBoxGroup = exports.CheckBox = void 0;
4
4
  const __1 = require("../..");
5
5
  class CheckBox extends __1.Component {
6
6
  _input;
7
7
  _label;
8
8
  static serial = Math.round(Math.random() * 1000);
9
- checBoxType = "checkbox";
9
+ _variant = "checkbox";
10
10
  constructor(optional) {
11
+ const label = optional?.label;
12
+ delete optional?.label;
11
13
  super(optional);
12
- this.checBoxType = optional?.checBoxType || "checkbox";
14
+ this._variant = optional?.variant || "checkbox";
13
15
  this._input = new __1.InputElement({
14
- type: this.checBoxType,
15
- className: this.checBoxType,
16
+ type: this.variant,
17
+ className: this.variant,
16
18
  id: `checkbox-${CheckBox.serial++}-${Math.round(Math.random() * 100)}`,
17
19
  });
18
- this._label = new __1.LabelElement({ text: optional?.placeholder });
20
+ this.input.value = optional?.value || label || "";
21
+ this._label = new __1.LabelElement({ text: label });
19
22
  this._label.setAttribute("for", this._input.id);
20
23
  if (optional?.color)
21
24
  this._input.style.accentColor = optional.color;
@@ -27,10 +30,13 @@ class CheckBox extends __1.Component {
27
30
  }
28
31
  else
29
32
  this._label.style.color = labelColor;
30
- this.onChange(this._input.checked);
33
+ this.onChange(this._input.checked, this.value);
31
34
  });
32
35
  }
33
36
  onChange = () => { };
37
+ get id() {
38
+ return this.input.id;
39
+ }
34
40
  get checked() {
35
41
  return this.input.checked;
36
42
  }
@@ -49,8 +55,52 @@ class CheckBox extends __1.Component {
49
55
  get label() {
50
56
  return this._label;
51
57
  }
58
+ get variant() {
59
+ return this._variant;
60
+ }
61
+ set variant(value) {
62
+ this._variant = value;
63
+ this.input.type = value;
64
+ this.input.className = value;
65
+ }
52
66
  }
53
67
  exports.CheckBox = CheckBox;
54
68
  // @ts-ignore
55
69
  customElements.define("check-box", CheckBox);
70
+ class CheckBoxGroup extends __1.Component {
71
+ constructor(...checkBoxes) {
72
+ super({ display: "flex" });
73
+ this.append(...checkBoxes);
74
+ }
75
+ append(...nodes) {
76
+ nodes.forEach((node) => {
77
+ this.check(node);
78
+ });
79
+ super.append(...nodes);
80
+ }
81
+ appendChild(node) {
82
+ this.check(node);
83
+ return super.appendChild(node);
84
+ }
85
+ onChange = () => { };
86
+ check(node) {
87
+ if (node instanceof CheckBox) {
88
+ const checkbox = node;
89
+ checkbox.addEventListener("change", () => {
90
+ if (checkbox.checked) {
91
+ this.onChange(checkbox);
92
+ this.querySelectorAll("check-box").forEach((cb) => {
93
+ if (cb !== checkbox) {
94
+ cb.checked = false;
95
+ }
96
+ });
97
+ }
98
+ console.log("checkbox: ", checkbox.id, "checked: ", checkbox.checked);
99
+ });
100
+ }
101
+ }
102
+ }
103
+ exports.CheckBoxGroup = CheckBoxGroup;
104
+ // @ts-ignore
105
+ customElements.define("check-box-group", CheckBoxGroup);
56
106
  //# sourceMappingURL=CheckBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../../../../src/core/element/action/CheckBox.ts"],"names":[],"mappings":";;;AAAA,6BAOe;AAIf,MAAa,QAAS,SAAQ,aAAS;IAC7B,MAAM,CAAe;IACrB,MAAM,CAAe;IACrB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,WAAW,GAAgB,UAAU,CAAC;IAE9C,YACE,QAMC;QAED,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,QAAQ,EAAE,WAAW,IAAI,UAAU,CAAC;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAY,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,SAAS,EAAE,IAAI,CAAC,WAAW;YAC3B,EAAE,EAAE,YAAY,QAAQ,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE;SACvE,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,IAAI,QAAQ,EAAE,KAAK;YAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC;QACpE,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,EAAE,CAAC;4BACnB,EAAe,CAAC,OAAO,GAAG,KAAK,CAAC;wBACnC,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AApCD,sCAoCC;AAED,aAAa;AACb,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Component, DivElement, StyleOptional } from "../..";
2
+ type SelectionType = "closeAndClean" | "closeAndKeep" | "openAndClean" | "openAndKeep";
3
+ export declare class DropDownItem extends DivElement {
4
+ }
5
+ export declare class DropDown<T = any> extends Component {
6
+ private onSelectionAction;
7
+ private _selectionType;
8
+ private previousSelected;
9
+ private _input;
10
+ private _inputAndButtonDiv;
11
+ private _options;
12
+ private _dropdownContent;
13
+ private _idClass;
14
+ onChange: (item: T) => void;
15
+ constructor(props: StyleOptional & {
16
+ placeHolder?: string;
17
+ noContent?: string;
18
+ options?: T[];
19
+ defaultOption?: string;
20
+ selectionType?: SelectionType;
21
+ });
22
+ onInit(): void;
23
+ private handleClickOutside;
24
+ private closeAndClean;
25
+ private closeAndKeep;
26
+ private openAndClean;
27
+ get selectionType(): SelectionType;
28
+ set selectionType(selectionType: SelectionType);
29
+ get input(): DivElement;
30
+ set input(input: DivElement);
31
+ get options(): T[];
32
+ set options(options: T[]);
33
+ get inputAndButtonDiv(): DivElement;
34
+ set inputAndButtonDiv(inputAndButtonDiv: DivElement);
35
+ get dropdownContent(): DivElement;
36
+ set dropdownContent(dropdownContent: DivElement);
37
+ get idClass(): number;
38
+ set idClass(idClass: number);
39
+ }
40
+ export {};
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DropDown = exports.DropDownItem = void 0;
4
+ const __1 = require("../..");
5
+ class DropDownItem extends __1.DivElement {
6
+ }
7
+ exports.DropDownItem = DropDownItem;
8
+ // @ts-ignore
9
+ customElements.define("drop-down-item", DropDownItem, { extends: "div" });
10
+ class DropDown extends __1.Component {
11
+ onSelectionAction = this.closeAndClean.bind(this);
12
+ _selectionType;
13
+ previousSelected = [];
14
+ _input;
15
+ _inputAndButtonDiv;
16
+ _options = [];
17
+ _dropdownContent;
18
+ _idClass;
19
+ onChange = () => { };
20
+ constructor(props) {
21
+ super(props);
22
+ this.inputAndButtonDiv = new __1.DivElement({
23
+ className: "input-and-button-div",
24
+ });
25
+ this.dropdownContent = new __1.DivElement({ className: "dropdown-content" });
26
+ this.append(this.inputAndButtonDiv, this.dropdownContent);
27
+ this.input = new __1.DivElement({ className: "input" });
28
+ this.input.textContent = props.placeHolder
29
+ ? props.placeHolder
30
+ : props.defaultOption;
31
+ this.selectionType = props.selectionType || "closeAndClean";
32
+ this.onInit();
33
+ this.options =
34
+ props.options == undefined || props.options.length === 0
35
+ ? [props.noContent]
36
+ : props.options;
37
+ }
38
+ onInit() {
39
+ this.className = "dropdown";
40
+ const arrow = new __1.DivElement({ className: "arrow-down" });
41
+ this.inputAndButtonDiv.append(this.input, arrow);
42
+ this.inputAndButtonDiv.onclick = () => {
43
+ if (this.options.length === 0)
44
+ return;
45
+ this.inputAndButtonDiv.classList.toggle("pressed");
46
+ arrow.classList.toggle("up");
47
+ console.log(this.inputAndButtonDiv.children[1].classList);
48
+ };
49
+ this.handleClickOutside = this.handleClickOutside.bind(this);
50
+ document.addEventListener("mousedown", this.handleClickOutside);
51
+ }
52
+ handleClickOutside(event) {
53
+ if (!this.inputAndButtonDiv.contains(event.target) &&
54
+ !this.dropdownContent.contains(event.target) &&
55
+ this.inputAndButtonDiv.classList.contains("pressed")) {
56
+ this.inputAndButtonDiv.children[1].classList.toggle("pressed");
57
+ this.inputAndButtonDiv.classList.toggle("pressed");
58
+ this.inputAndButtonDiv.children[1].classList.toggle("up");
59
+ }
60
+ }
61
+ closeAndClean() {
62
+ Array.from(this.dropdownContent.children).forEach((child) => {
63
+ child.classList.remove("selected");
64
+ });
65
+ this.inputAndButtonDiv.children[1].classList.toggle("pressed");
66
+ this.inputAndButtonDiv.classList.toggle("pressed");
67
+ this.inputAndButtonDiv.children[1].classList.toggle("up");
68
+ }
69
+ closeAndKeep() {
70
+ this.inputAndButtonDiv.children[1].classList.toggle("pressed");
71
+ this.inputAndButtonDiv.classList.toggle("pressed");
72
+ this.inputAndButtonDiv.children[1].classList.toggle("up");
73
+ }
74
+ openAndClean() {
75
+ Array.from(this.dropdownContent.children).forEach((child) => {
76
+ child.classList.remove("selected");
77
+ });
78
+ }
79
+ get selectionType() {
80
+ return this._selectionType;
81
+ }
82
+ set selectionType(selectionType) {
83
+ if (selectionType == "closeAndKeep")
84
+ this.onSelectionAction = this.closeAndKeep.bind(this);
85
+ else if (selectionType == "openAndClean")
86
+ this.onSelectionAction = this.openAndClean.bind(this);
87
+ else if (selectionType == "openAndKeep")
88
+ this.onSelectionAction = () => { };
89
+ else
90
+ this.onSelectionAction = this.closeAndClean.bind(this);
91
+ this._selectionType = selectionType;
92
+ }
93
+ get input() {
94
+ return this._input;
95
+ }
96
+ set input(input) {
97
+ this._input = input;
98
+ }
99
+ get options() {
100
+ return this._options;
101
+ }
102
+ set options(options) {
103
+ this._options = options;
104
+ if (!this.dropdownContent)
105
+ return;
106
+ this.dropdownContent.innerHTML = "";
107
+ this.options.forEach((option) => {
108
+ let node;
109
+ if (option instanceof Node)
110
+ node = this.dropdownContent.appendChild(option);
111
+ else {
112
+ const div = new DropDownItem({
113
+ text: option?.toString() || "",
114
+ });
115
+ node = div;
116
+ if (this.previousSelected.includes(option)) {
117
+ div.classList.toggle("selected");
118
+ }
119
+ this.dropdownContent.append(div);
120
+ }
121
+ node.classList.add("option");
122
+ node.onclick = () => {
123
+ this.onSelectionAction();
124
+ node.classList.toggle("selected");
125
+ if (node.classList.contains("selected")) {
126
+ this.previousSelected.push(option);
127
+ }
128
+ else {
129
+ this.previousSelected = this.previousSelected.filter((selectedOption) => selectedOption !== option);
130
+ }
131
+ this.input.textContent = option?.toString() || "";
132
+ this.input.style.color = "black";
133
+ this.onChange(option);
134
+ };
135
+ });
136
+ }
137
+ get inputAndButtonDiv() {
138
+ return this._inputAndButtonDiv;
139
+ }
140
+ set inputAndButtonDiv(inputAndButtonDiv) {
141
+ this._inputAndButtonDiv = inputAndButtonDiv;
142
+ }
143
+ get dropdownContent() {
144
+ return this._dropdownContent;
145
+ }
146
+ set dropdownContent(dropdownContent) {
147
+ this._dropdownContent = dropdownContent;
148
+ }
149
+ get idClass() {
150
+ return this._idClass;
151
+ }
152
+ set idClass(idClass) {
153
+ this._idClass = idClass;
154
+ }
155
+ }
156
+ exports.DropDown = DropDown;
157
+ // @ts-ignore
158
+ customElements.define("drop-down", DropDown);
159
+ //# sourceMappingURL=DropDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDown.js","sourceRoot":"","sources":["../../../../../src/core/element/action/DropDown.ts"],"names":[],"mappings":";;;AAAA,6BAA6D;AAQ7D,MAAa,YAAa,SAAQ,cAAU;CAAG;AAA/C,oCAA+C;AAE/C,aAAa;AACb,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAE1E,MAAa,QAAkB,SAAQ,aAAS;IACtC,iBAAiB,GAAe,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,cAAc,CAAgB;IAC9B,gBAAgB,GAAQ,EAAE,CAAC;IAC3B,MAAM,CAAa;IACnB,kBAAkB,CAAa;IAC/B,QAAQ,GAAQ,EAAE,CAAC;IACnB,gBAAgB,CAAa;IAC7B,QAAQ,CAAS;IAClB,QAAQ,GAAsB,GAAG,EAAE,GAAE,CAAC,CAAC;IAE9C,YACE,KAMC;QAED,KAAK,CAAC,KAAK,C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6
  import { HBoxElement } from "./layers/HBoxElement";
7
7
  import { GridElement } from "./layers/GridElement";
8
8
  import { BorderPaneElement } from "./layers/BorderPaneElement";
9
- import { DropdownElement } from "./dropdown/DropdownElement";
10
9
  import { App } from "./base/App";
11
10
  import { FlowPane } from "./layers/FlowPane";
12
11
  import { ListElement } from "./action/ListElement";
@@ -15,12 +14,12 @@ import { IconElement } from "./image/IconElement";
15
14
  import { TabElement } from "./action/TabElement";
16
15
  import { PaneElement } from "./layers/PaneElement";
17
16
  import { SlidePane } from "./action/SlidePane";
18
- import { SelectBox } from "./action/SelectBox";
17
+ import { DropDown } from "./action/DropDown";
19
18
  import { Variant } from "./base/CSSStyle";
20
19
  import { ChartElement } from "./action/ChartPane";
21
- import { CheckBox } from "./action/CheckBox";
20
+ import { CheckBox, CheckBoxGroup } from "./action/CheckBox";
22
21
  import { ToggleButton } from "./action/ToggleButton";
23
22
  import { ILayout, StyleOptional } from "./base/Elements";
24
23
  import { StackPane } from "./layers/StackPane";
25
- export { App, CardElement, SelectBox, ChartElement, CheckBox, ToggleButton, DropdownElement, SlidePane, TabPane, TabElement, ListElement, IconElement, FlowPane, VBoxElement, HBoxElement, GridElement, PaneElement, BorderPaneElement, StyleLink, ILayout, StackPane, };
24
+ export { App, CardElement, ChartElement, CheckBox, CheckBoxGroup, ToggleButton, DropDown, SlidePane, TabPane, TabElement, ListElement, IconElement, FlowPane, VBoxElement, HBoxElement, GridElement, PaneElement, BorderPaneElement, StyleLink, ILayout, StackPane, };
26
25
  export type { Variant, StyleOptional };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StackPane = exports.ILayout = exports.StyleLink = exports.BorderPaneElement = exports.PaneElement = exports.GridElement = exports.HBoxElement = exports.VBoxElement = exports.FlowPane = exports.IconElement = exports.ListElement = exports.TabElement = exports.TabPane = exports.SlidePane = exports.DropdownElement = exports.ToggleButton = exports.CheckBox = exports.ChartElement = exports.SelectBox = exports.CardElement = exports.App = void 0;
3
+ exports.StackPane = exports.ILayout = exports.StyleLink = exports.BorderPaneElement = exports.PaneElement = exports.GridElement = exports.HBoxElement = exports.VBoxElement = exports.FlowPane = exports.IconElement = exports.ListElement = exports.TabElement = exports.TabPane = exports.SlidePane = exports.DropDown = exports.ToggleButton = exports.CheckBoxGroup = exports.CheckBox = exports.ChartElement = exports.CardElement = exports.App = void 0;
4
4
  __exportStar(require("./base/Elements"), exports);
5
5
  __exportStar(require("./text"), exports);
6
6
  const CardElement_1 = require("./layers/CardElement");
@@ -15,8 +15,6 @@ const GridElement_1 = require("./layers/GridElement");
15
15
  Object.defineProperty(exports, "GridElement", { enumerable: true, get: function () { return GridElement_1.GridElement; } });
16
16
  const BorderPaneElement_1 = require("./layers/BorderPaneElement");
17
17
  Object.defineProperty(exports, "BorderPaneElement", { enumerable: true, get: function () { return BorderPaneElement_1.BorderPaneElement; } });
18
- const DropdownElement_1 = require("./dropdown/DropdownElement");
19
- Object.defineProperty(exports, "DropdownElement", { enumerable: true, get: function () { return DropdownElement_1.DropdownElement; } });
20
18
  const App_1 = require("./base/App");
21
19
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return App_1.App; } });
22
20
  const FlowPane_1 = require("./layers/FlowPane");
@@ -33,12 +31,13 @@ const PaneElement_1 = require("./layers/PaneElement");
33
31
  Object.defineProperty(exports, "PaneElement", { enumerable: true, get: function () { return PaneElement_1.PaneElement; } });
34
32
  const SlidePane_1 = require("./action/SlidePane");
35
33
  Object.defineProperty(exports, "SlidePane", { enumerable: true, get: function () { return SlidePane_1.SlidePane; } });
36
- const SelectBox_1 = require("./action/SelectBox");
37
- Object.defineProperty(exports, "SelectBox", { enumerable: true, get: function () { return SelectBox_1.SelectBox; } });
34
+ const DropDown_1 = require("./action/DropDown");
35
+ Object.defineProperty(exports, "DropDown", { enumerable: true, get: function () { return DropDown_1.DropDown; } });
38
36
  const ChartPane_1 = require("./action/ChartPane");
39
37
  Object.defineProperty(exports, "ChartElement", { enumerable: true, get: function () { return ChartPane_1.ChartElement; } });
40
38
  const CheckBox_1 = require("./action/CheckBox");
41
39
  Object.defineProperty(exports, "CheckBox", { enumerable: true, get: function () { return CheckBox_1.CheckBox; } });
40
+ Object.defineProperty(exports, "CheckBoxGroup", { enumerable: true, get: function () { return CheckBox_1.CheckBoxGroup; } });
42
41
  const ToggleButton_1 = require("./action/ToggleButton");
43
42
  Object.defineProperty(exports, "ToggleButton", { enumerable: true, get: function () { return ToggleButton_1.ToggleButton; } });
44
43
  const Elements_1 = require("./base/Elements");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/element/index.ts"],"names":[],"mappings":";;;AAAA,kDAAgC;AAChC,yCAAuB;AAEvB,sDAAmD;AAyBjD,4FAzBO,yBAAW,OAyBP;AAxBb,uDAAoD;AAmDlD,0FAnDO,qBAAS,OAmDP;AAlDX,sDAAmD;AA6CjD,4FA7CO,yBAAW,OA6CP;AA5Cb,sDAAmD;AA6CjD,4FA7CO,yBAAW,OA6CP;AA5Cb,sDAAmD;AA6CjD,4FA7CO,yBAAW,OA6CP;AA5Cb,kEAA+D;AA8C7D,kGA9CO,qCAAiB,OA8CP;AA7CnB,gEAA6D;AA4B3D,gGA5BO,iCAAe,OA4BP;AA3BjB,oCAAiC;AAiB/B,oFAjBO,SAAG,OAiBP;AAhBL,gDAA6C;AAsC3C,yFAtCO,mBAAQ,OAsCP;AArCV,sDAAmD;AAgCjD,4FAhCO,yBAAW,OAgCP;AA/Bb,8CAA2C;AA6BzC,wFA7BO,iBAAO,OA6BP;AA5BT,qDAAkD;AAgChD,4FAhCO,yBAAW,OAgCP;AA/Bb,oDAAiD;AA4B/C,2FA5BO,uBAAU,OA4BP;AA3BZ,sDAAmD;AAqCjD,4FArCO,yBAAW,OAqCP;AApCb,kDAA+C;AAwB7C,0FAxBO,qBAAS,OAwBP;AAvBX,kDAA+C;AAW7C,0FAXO,qBAAS,OAWP;AATX,kDAAkD;AAU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CO,qBAAS,OAiCP"}
@@ -1,23 +1,31 @@
1
- import { Component, InputElement, LabelElement, StyleOptional, Variant, IconElement } from "../..";
2
- type ChecBoxType = "checkbox" | "radio";
1
+ import { Component, InputElement, LabelElement, StyleOptional, IconElement } from "../..";
3
2
  export declare class CheckBox extends Component {
4
3
  private _input;
5
4
  private _label;
6
5
  private static serial;
7
- private checBoxType;
6
+ private _variant;
8
7
  constructor(optional?: StyleOptional & {
9
- variant?: Variant;
10
- placeholder?: string;
8
+ variant?: "checkbox" | "radio";
9
+ label?: string;
10
+ value?: any;
11
11
  icon?: IconElement;
12
12
  placeholderAnimation?: boolean;
13
- checBoxType: ChecBoxType;
14
13
  });
15
- onChange: (checked: boolean) => void;
14
+ onChange: (checked: boolean, value?: any) => void;
15
+ get id(): string;
16
16
  get checked(): boolean;
17
17
  set checked(value: boolean);
18
18
  get value(): string;
19
19
  set value(value: string);
20
20
  get input(): InputElement;
21
21
  get label(): LabelElement;
22
+ get variant(): "checkbox" | "radio";
23
+ set variant(value: "checkbox" | "radio");
24
+ }
25
+ export declare class CheckBoxGroup extends Component {
26
+ constructor(...checkBoxes: CheckBox[]);
27
+ append(...nodes: (string | Node)[]): void;
28
+ appendChild<T extends Node>(node: T): T;
29
+ onChange: (checkbox: CheckBox) => void;
30
+ private check;
22
31
  }
23
- export {};
@@ -3,16 +3,19 @@ export class CheckBox extends Component {
3
3
  _input;
4
4
  _label;
5
5
  static serial = Math.round(Math.random() * 1000);
6
- checBoxType = "checkbox";
6
+ _variant = "checkbox";
7
7
  constructor(optional) {
8
+ const label = optional?.label;
9
+ delete optional?.label;
8
10
  super(optional);
9
- this.checBoxType = optional?.checBoxType || "checkbox";
11
+ this._variant = optional?.variant || "checkbox";
10
12
  this._input = new InputElement({
11
- type: this.checBoxType,
12
- className: this.checBoxType,
13
+ type: this.variant,
14
+ className: this.variant,
13
15
  id: `checkbox-${CheckBox.serial++}-${Math.round(Math.random() * 100)}`,
14
16
  });
15
- this._label = new LabelElement({ text: optional?.placeholder });
17
+ this.input.value = optional?.value || label || "";
18
+ this._label = new LabelElement({ text: label });
16
19
  this._label.setAttribute("for", this._input.id);
17
20
  if (optional?.color)
18
21
  this._input.style.accentColor = optional.color;
@@ -24,10 +27,13 @@ export class CheckBox extends Component {
24
27
  }
25
28
  else
26
29
  this._label.style.color = labelColor;
27
- this.onChange(this._input.checked);
30
+ this.onChange(this._input.checked, this.value);
28
31
  });
29
32
  }
30
33
  onChange = () => { };
34
+ get id() {
35
+ return this.input.id;
36
+ }
31
37
  get checked() {
32
38
  return this.input.checked;
33
39
  }
@@ -46,7 +52,50 @@ export class CheckBox extends Component {
46
52
  get label() {
47
53
  return this._label;
48
54
  }
55
+ get variant() {
56
+ return this._variant;
57
+ }
58
+ set variant(value) {
59
+ this._variant = value;
60
+ this.input.type = value;
61
+ this.input.className = value;
62
+ }
49
63
  }
50
64
  // @ts-ignore
51
65
  customElements.define("check-box", CheckBox);
66
+ export class CheckBoxGroup extends Component {
67
+ constructor(...checkBoxes) {
68
+ super({ display: "flex" });
69
+ this.append(...checkBoxes);
70
+ }
71
+ append(...nodes) {
72
+ nodes.forEach((node) => {
73
+ this.check(node);
74
+ });
75
+ super.append(...nodes);
76
+ }
77
+ appendChild(node) {
78
+ this.check(node);
79
+ return super.appendChild(node);
80
+ }
81
+ onChange = () => { };
82
+ check(node) {
83
+ if (node instanceof CheckBox) {
84
+ const checkbox = node;
85
+ checkbox.addEventListener("change", () => {
86
+ if (checkbox.checked) {
87
+ this.onChange(checkbox);
88
+ this.querySelectorAll("check-box").forEach((cb) => {
89
+ if (cb !== checkbox) {
90
+ cb.checked = false;
91
+ }
92
+ });
93
+ }
94
+ console.log("checkbox: ", checkbox.id, "checked: ", checkbox.checked);
95
+ });
96
+ }
97
+ }
98
+ }
99
+ // @ts-ignore
100
+ customElements.define("check-box-group", CheckBoxGroup);
52
101
  //# sourceMappingURL=CheckBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBox.js","sourceRo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AAE,EAAE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAED,aAAa;AACb,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Component, DivElement, StyleOptional } from "../..";
2
+ type SelectionType = "closeAndClean" | "closeAndKeep" | "openAndClean" | "openAndKeep";
3
+ export declare class DropDownItem extends DivElement {
4
+ }
5
+ export declare class DropDown<T = any> extends Component {
6
+ private onSelectionAction;
7
+ private _selectionType;
8
+ private previousSelected;
9
+ private _input;
10
+ private _inputAndButtonDiv;
11
+ private _options;
12
+ private _dropdownContent;
13
+ private _idClass;
14
+ onChange: (item: T) => void;
15
+ constructor(props: StyleOptional & {
16
+ placeHolder?: string;
17
+ noContent?: string;
18
+ options?: T[];
19
+ defaultOption?: string;
20
+ selectionType?: SelectionType;
21
+ });
22
+ onInit(): void;
23
+ private handleClickOutside;
24
+ private closeAndClean;
25
+ private closeAndKeep;
26
+ private openAndClean;
27
+ get selectionType(): SelectionType;
28
+ set selectionType(selectionType: SelectionType);
29
+ get input(): DivElement;
30
+ set input(input: DivElement);
31
+ get options(): T[];
32
+ set options(options: T[]);
33
+ get inputAndButtonDiv(): DivElement;
34
+ set inputAndButtonDiv(inputAndButtonDiv: DivElement);
35
+ get dropdownContent(): DivElement;
36
+ set dropdownContent(dropdownContent: DivElement);
37
+ get idClass(): number;
38
+ set idClass(idClass: number);
39
+ }
40
+ export {};