@wavelengthusaf/web-components 1.4.1 → 1.4.2

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/dist/esm/index.js CHANGED
@@ -5436,6 +5436,299 @@ if (!customElements.get("wavelength-child-data-table")) {
5436
5436
  customElements.define("wavelength-child-data-table", ChildDataTable);
5437
5437
  }
5438
5438
 
5439
+ // src/functions/swapCSSClass.ts
5440
+ function swapCSSClass(element, remove, add) {
5441
+ element.classList.remove(...remove);
5442
+ if (add) element.classList.add(add);
5443
+ }
5444
+
5445
+ // src/functions/getRequiredElement.ts
5446
+ function getRequiredElement(root, selector) {
5447
+ const el = root.querySelector(`${selector}`);
5448
+ if (!el) {
5449
+ throw new Error(`Missing element: ${selector}`);
5450
+ }
5451
+ return el;
5452
+ }
5453
+
5454
+ // src/web-components/wavelength-checkbox.ts
5455
+ var checkboxTemplate = document.createElement("template");
5456
+ checkboxTemplate.innerHTML = `
5457
+ <style>
5458
+
5459
+ .checkbox-container {
5460
+ position: relative;
5461
+ display: inline-flex;
5462
+ align-items: center;
5463
+ cursor: pointer;
5464
+ }
5465
+
5466
+ .checkbox-container input {
5467
+ position: absolute;
5468
+ opacity: 0;
5469
+ pointer-events: none;
5470
+ }
5471
+
5472
+
5473
+ .custom-checkbox {
5474
+ --size: 20px;
5475
+ --border: 2px;
5476
+ --check-left: 6.5px;
5477
+ --check-top: 1.5px;
5478
+ --check-width: 5px;
5479
+ --check-height: 10px;
5480
+ --halo: 12px;
5481
+
5482
+ width: var(--size);
5483
+ height: var(--size);
5484
+ border: var(--border) solid #444;
5485
+ border-radius: 4px;
5486
+ background: #fff;
5487
+ position: relative;
5488
+ z-index: 1;
5489
+ box-sizing: border-box;
5490
+ }
5491
+
5492
+
5493
+ .custom-checkbox::before {
5494
+ content: "";
5495
+ position: absolute;
5496
+ inset: calc(var(--halo) * -1); /* controls halo size */
5497
+ background: rgba(0, 0, 0, 0.15);
5498
+ border-radius: 50%; /* THIS makes it circular */
5499
+ opacity: 0;
5500
+ transition: opacity 0.2s ease;
5501
+ z-index: -1;
5502
+ }
5503
+
5504
+
5505
+ .checkbox-container:hover .custom-checkbox::before {
5506
+ opacity: 1;
5507
+ }
5508
+
5509
+
5510
+ .checkbox-container input:checked + .custom-checkbox {
5511
+ background-color: #444;
5512
+ }
5513
+
5514
+
5515
+ .checkbox-container input:checked + .custom-checkbox::after {
5516
+ content: "";
5517
+ position: absolute;
5518
+ left: 50%;
5519
+ top: 50%;
5520
+ width: var(--check-width);
5521
+ height: var(--check-height);
5522
+ border: solid white;
5523
+ border-width: 0 var(--border) var(--border) 0;
5524
+ transform: translate(-50%, -60%) rotate(45deg);
5525
+ }
5526
+
5527
+ .checkbox-container input:checked + .custom-checkbox.light::after {
5528
+ border: solid white;
5529
+ border-width: 0 2px 2px 0;
5530
+ }
5531
+
5532
+ .checkbox-container input:checked + .custom-checkbox.dark::after {
5533
+ border: solid black;
5534
+ border-width: 0 2px 2px 0;
5535
+ }
5536
+
5537
+ .primary::before {
5538
+ background: #2196F335;
5539
+ }
5540
+
5541
+ .checkbox-container input:checked + .custom-checkbox.primary {
5542
+ background-color: #2196F3;
5543
+ border-color: #2196F3;
5544
+ }
5545
+
5546
+ .secondary::before {
5547
+ background: #7B1FA235;
5548
+ }
5549
+
5550
+ .checkbox-container input:checked + .custom-checkbox.secondary {
5551
+ background-color: #7B1FA2;
5552
+ border-color: #7B1FA2;
5553
+ }
5554
+
5555
+ .error::before {
5556
+ background: #D32F2F35;
5557
+ }
5558
+
5559
+ .checkbox-container input:checked + .custom-checkbox.error {
5560
+ background-color: #D32F2F;
5561
+ border-color: #D32F2F;
5562
+ }
5563
+
5564
+ .warning::before {
5565
+ background: #EF6C0035;
5566
+ }
5567
+
5568
+ .checkbox-container input:checked + .custom-checkbox.warning {
5569
+ background-color: #EF6C00;
5570
+ border-color: #EF6C00;
5571
+ }
5572
+
5573
+ .info::before {
5574
+ background: #0288D135;
5575
+ }
5576
+
5577
+ .checkbox-container input:checked + .custom-checkbox.info {
5578
+ background-color: #0288D1;
5579
+ border-color: #0288D1;
5580
+ }
5581
+
5582
+ .success::before {
5583
+ background: #2E7D3235;
5584
+ }
5585
+
5586
+ .checkbox-container input:checked + .custom-checkbox.success {
5587
+ background-color: #2E7D32;
5588
+ border-color: #2E7D32;
5589
+ }
5590
+
5591
+ .custom-checkbox.small {
5592
+ --size: 18px;
5593
+ --check-left: 4.5px;
5594
+ --check-top: 1px;
5595
+ --check-width: 3px;
5596
+ --check-height: 7px;
5597
+ --halo: 10px;
5598
+ }
5599
+
5600
+ .custom-checkbox.medium {
5601
+
5602
+ }
5603
+
5604
+ .custom-checkbox.large {
5605
+ --size: 25px;
5606
+ --border: 2px;
5607
+ --check-left: 9px;
5608
+ --check-top: 2px;
5609
+ --check-width: 7px;
5610
+ --check-height: 14px;
5611
+ --halo: 15px;
5612
+ }
5613
+
5614
+ .custom-checkbox.disabled {
5615
+ cursor: not-allowed;
5616
+ pointer-events: none;
5617
+ border-color: rgba(128, 128, 128, 0.85);
5618
+ background: #f5f5f5;
5619
+ }
5620
+
5621
+ .custom-checkbox.disabled::before {
5622
+ opacity: 0 !important;
5623
+ display: none;
5624
+ }
5625
+
5626
+ .checkbox-container:hover .custom-checkbox.disabled::before {
5627
+ opacity: 0;
5628
+ }
5629
+
5630
+ .checkbox-container input:checked + .custom-checkbox.disabled::after {
5631
+ border-color: rgba(120, 120, 120, 0.85);
5632
+ }
5633
+
5634
+ .checkbox-container::after {
5635
+ content: attr(text);
5636
+ font-size: 14px;
5637
+ font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
5638
+ line-height: 1;
5639
+ margin-left: 8px;
5640
+ color: #333;
5641
+ user-select: none;
5642
+ }
5643
+
5644
+
5645
+ .checkbox-container.small::after {
5646
+ font-size: 14px;
5647
+ }
5648
+
5649
+ .checkbox-container.medium::after {
5650
+ font-size: 16px; /* default */
5651
+ }
5652
+
5653
+ .checkbox-container.large::after {
5654
+ font-size: 18px;
5655
+ }
5656
+
5657
+ </style>
5658
+
5659
+ <label class="checkbox-container" text="">
5660
+ <input type="checkbox"/>
5661
+ <span class="custom-checkbox"></span>
5662
+ </label>
5663
+ `;
5664
+ var BaseWavelengthCheckbox = class extends HTMLElement {
5665
+ constructor() {
5666
+ super();
5667
+ this.initialized = false;
5668
+ this.attributeHandlers = {
5669
+ size: (value) => {
5670
+ swapCSSClass(this.elements.box, ["small", "medium", "large"], value ?? "medium");
5671
+ },
5672
+ color: (value) => {
5673
+ swapCSSClass(this.elements.box, ["primary", "secondary", "error", "warning", "info", "success"], value ?? "primary");
5674
+ },
5675
+ theme: (value) => {
5676
+ swapCSSClass(this.elements.box, ["light", "dark"], value ?? "light");
5677
+ },
5678
+ disabled: (value) => {
5679
+ if (value === "") {
5680
+ this.elements.input.disabled = true;
5681
+ swapCSSClass(this.elements.box, ["enabled", "disabled"], "disabled");
5682
+ } else {
5683
+ swapCSSClass(this.elements.box, ["enabled", "disabled"], "enabled");
5684
+ this.elements.input.disabled = false;
5685
+ }
5686
+ },
5687
+ text: (value) => {
5688
+ if (value === null) {
5689
+ this.elements.label.removeAttribute("text");
5690
+ } else {
5691
+ this.elements.label.setAttribute("text", value);
5692
+ }
5693
+ },
5694
+ textSize: (value) => {
5695
+ swapCSSClass(this.elements.label, ["small", "medium", "large"], value ?? "medium");
5696
+ }
5697
+ };
5698
+ this.attachShadow({ mode: "open" });
5699
+ }
5700
+ static get observedAttributes() {
5701
+ return ["size", "color", "theme", "disabled", "text", "text-size"];
5702
+ }
5703
+ connectedCallback() {
5704
+ if (!this.initialized) {
5705
+ this.shadowRoot.innerHTML = checkboxTemplate.innerHTML;
5706
+ this.elements = {
5707
+ box: getRequiredElement(this.shadowRoot, "span"),
5708
+ input: getRequiredElement(this.shadowRoot, "input"),
5709
+ label: getRequiredElement(this.shadowRoot, "label")
5710
+ };
5711
+ this.styleCheckbox();
5712
+ this.initialized = true;
5713
+ }
5714
+ }
5715
+ attributeChangedCallback() {
5716
+ if (this.initialized) this.styleCheckbox();
5717
+ }
5718
+ styleCheckbox() {
5719
+ if (!this.initialized) return;
5720
+ for (const key in this.attributeHandlers) {
5721
+ const attr = key === "textSize" ? "text-size" : key;
5722
+ this.attributeHandlers[key](this.getAttribute(attr));
5723
+ }
5724
+ }
5725
+ };
5726
+ var WavelengthCheckbox = class extends StylingMixin(BaseWavelengthCheckbox) {
5727
+ };
5728
+ if (!customElements.get("wavelength-checkbox")) {
5729
+ customElements.define("wavelength-checkbox", WavelengthCheckbox);
5730
+ }
5731
+
5439
5732
  // src/web-components/wavelength-file-drop-zone.ts
5440
5733
  var fileDropZoneTemplate = document.createElement("template");
5441
5734
  fileDropZoneTemplate.innerHTML = `
@@ -5646,6 +5939,7 @@ export {
5646
5939
  SampleComponent,
5647
5940
  WavelengthBanner,
5648
5941
  WavelengthButton,
5942
+ WavelengthCheckbox,
5649
5943
  WavelengthDatePicker,
5650
5944
  WavelengthFileDropZone,
5651
5945
  WavelengthForm,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wavelengthusaf/web-components",
3
3
  "author": "563 EWS - Wavelength",
4
4
  "license": "MIT",
5
- "version": "1.4.1",
5
+ "version": "1.4.2",
6
6
  "description": "Common component library used by Wavelength developers (NATIVE WEB COMPONENTS)",
7
7
  "main": "/dist/cjs/index.cjs",
8
8
  "module": "/dist/esm/index.js",