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w@1.0.7/table-saw.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@zachleat/table-saw@1.0.7/table-saw.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","class Tablesaw extends HTMLElement {\n\tstatic dupes = {};\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.autoOffset = 50;\n\t\tthis._needsStylesheet = true;\n\n\t\tthis.attrs = {\n\t\t\tbreakpoint: \"breakpoint\",\n\t\t\tbreakpointBackwardsCompat: \"media\",\n\t\t\ttype: \"type\",\n\t\t\tratio: \"ratio\",\n\t\t\tlabel: \"data-tablesaw-label\",\n\t\t\tzeropad: \"zero-padding\",\n\t\t\tforceTextAlign: \"text-align\"\n\t\t};\n\n\t\tthis.defaults = {\n\t\t\tbreakpoint: '(max-width: 39.9375em)', // same as Filament Group’s Tablesaw\n\t\t\tratio: '1fr 2fr',\n\t\t};\n\n\t\tthis.classes = {\n\t\t\twrap: \"tablesaw-wrap\"\n\t\t}\n\n\t\tthis.props = {\n\t\t\tratio: \"--table-saw-ratio\",\n\t\t\tbold: \"--table-saw-header-bold\",\n\t\t};\n\t}\n\n\tgenerateCss(breakpoint, type) {\n\t\treturn `\ntable-saw.${this._id} {\n\tdisplay: block;\n\t${type === \"container\" ? \"container-type: inline-size;\" : \"\"}\n}\n\n@${type} ${breakpoint} {\n\ttable-saw.${this._id} thead :is(th, td) {\n\t\tposition: absolute;\n\t\theight: 1px;\n\t\twidth: 1px;\n\t\toverflow: hidden;\n\t\tclip: rect(1px, 1px, 1px, 1px);\n\t}\n\ttable-saw.${this._id} :is(tbody, tfoot) tr {\n\t\tdisplay: block;\n\t}\n\ttable-saw.${this._id} :is(tbody, tfoot) :is(th, td):before {\n\t\tfont-weight: var(${this.props.bold});\n\t\tcontent: attr(${this.attrs.label});\n\t}\n\ttable-saw.${this._id} :is(tbody, tfoot) :is(th, td) {\n\t\tdisplay: grid;\n\t\tgap: 0 1em;\n\t\tgrid-template-columns: var(${this.props.ratio}, ${this.defaults.ratio});\n\t}\n\ttable-saw.${this._id}[${this.attrs.forceTextAlign}] :is(tbody, tfoot) :is(th, td) {\n\t\ttext-align: ${this.getAttribute(this.attrs.forceTextAlign) || \"left\"};\n\t}\n\ttable-saw.${this._id}[${this.attrs.zeropad}] :is(tbody, tfoot) :is(th, td) {\n\t\tpadding-left: 0;\n\t\tpadding-right: 0;\n\t}\n}`;\n\t}\n\n\tconnectedCallback() {\n\t\t// Cut-the-mustard\n\t\t// https://caniuse.com/mdn-api_cssstylesheet_replacesync\n\t\tif(!(\"replaceSync\" in CSSStyleSheet.prototype)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.addHeaders();\n\t\tthis.setRatio();\n\n\t\tif(!this._needsStylesheet) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet sheet = new CSSStyleSheet();\n\t\tlet breakpoint = this.getAttribute(this.attrs.breakpoint) || this.getAttribute(this.attrs.breakpointBackwardsCompat) || this.defaults.breakpoint;\n\t\tlet type = this.getAttribute(this.attrs.type) || \"media\";\n\n\t\tthis._id = `ts_${type.slice(0, 1)}${breakpoint.replace(/[^a-z0-9]/gi, \"_\")}`;\n\t\tthis.classList.add(this._id);\n\n\t\tif(!Tablesaw.dupes[this._id]) {\n\t\t\tlet css = this.generateCss(breakpoint, type);\n\t\t\tsheet.replaceSync(css);\n\n\t\t\tlet root = this.getRootNode();\n\t\t\troot.adoptedStyleSheets.push(sheet);\n\n\t\t\t// only add to global de-dupe if not a shadow root\n\t\t\tif(root.host && root !== root.host.shadowRoot) {\n\t\t\t\tTablesaw.dupes[this._id] = true;\n\t\t\t}\n\t\t}\n\t}\n\n\taddHeaders() {\n\t\tlet headerCells = this.querySelectorAll(\"thead th\");\n\t\tlet labels = Array.from(headerCells).map((cell, index) => {\n\t\t\t// Set headers to be bold (if headers are bold)\n\t\t\tif(index === 0) {\n\t\t\t\tlet styles = window.getComputedStyle(cell);\n\t\t\t\tif(styles) {\n\t\t\t\t\t// Copy other styles?\n\t\t\t\t\tlet bold = styles.getPropertyValue(\"font-weight\");\n\t\t\t\t\tthis.setBold(bold);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet label = cell.innerText.trim();\n\t\t\tif (label === \"\") {\n\t\t\t\tlabel = cell.textContent.trim();\n\t\t\t}\n\n\t\t\treturn label;\n\t\t});\n\n\t\tif(labels.length === 0) {\n\t\t\tthis._needsStylesheet = false;\n\t\t\tconsole.error(\"No `<th>` elements found:\", this);\n\t\t\treturn;\n\t\t}\n\n\t\tlet cells = this.querySelectorAll(\"tbody :is(td, th)\");\n\t\tfor(let cell of cells) {\n\t\t\tif(!labels[cell.cellIndex]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcell.setAttribute(this.attrs.label, labels[cell.cellIndex]);\n\n\t\t\tlet nodeCount = 0;\n\t\t\tfor(let n of cell.childNodes) {\n\t\t\t\t// text or element node\n\t\t\t\tif(n.nodeType === 3 || n.nodeType === 1) {\n\t\t\t\t\tnodeCount++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// wrap if this cell has child nodes for correct grid alignment\n\t\t\tif(nodeCount > 1) {\n\t\t\t\tlet wrapper = document.createElement(\"div\");\n\t\t\t\twrapper.classList.add(this.classes.wrap);\n\t\t\t\twhile(cell.firstChild) {\n\t\t\t\t\twrapper.appendChild(cell.firstChild);\n\t\t\t\t}\n\t\t\t\tcell.appendChild(wrapper);\n\t\t\t}\n\t\t}\n\t}\n\n\tsetBold(bold) {\n\t\tif(bold || bold === \"\") {\n\t\t\tthis.style.setProperty(this.props.bold, bold);\n\t\t}\n\t}\n\n\tsetRatio() {\n\t\tlet ratio = this.getAttribute(this.attrs.ratio);\n\t\tif(ratio) {\n\t\t\tlet ratioString = ratio.split(\"/\").join(\"fr \") + \"fr\";\n\t\t\tthis.style.setProperty(this.props.ratio, ratioString);\n\t\t}\n\t}\n}\n\nif(\"customElements\" in window) {\n\twindow.customElements.define(\"table-saw\", Tablesaw);\n}\n\nexport { Tablesaw };\n"]}