UNPKG

@codegouvfr/react-dsfr

Version:

French State Design System React integration library

4 lines (3 loc) 5.37 kB
/*! DSFR v1.13.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */ !function(){"use strict";var t=window.dsfr,e={SCROLLABLE:t.internals.ns.emission("table","scrollable"),CHANGE:t.internals.ns.emission("table","change"),CAPTION_HEIGHT:t.internals.ns.emission("table","captionheight"),CAPTION_WIDTH:t.internals.ns.emission("table","captionwidth")},n=function(t){function n(){t.apply(this,arguments)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"Table"},n.prototype.init=function(){this.addAscent(e.CAPTION_HEIGHT,this.setCaptionHeight.bind(this))},n.prototype.setCaptionHeight=function(t){this.setProperty("--table-offset",t)},Object.defineProperties(n,s),n}(t.core.Instance),s=function(t){function n(){t.apply(this,arguments)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TableWrapper"},n.prototype.init=function(){this.addAscent(e.CAPTION_HEIGHT,this.setCaptionHeight.bind(this))},n.prototype.setCaptionHeight=function(t){var n=this;requestAnimationFrame((function(){return n.ascend(e.CAPTION_HEIGHT,0)})),this.setProperty("--table-offset",t)},Object.defineProperties(n,s),n}(t.core.Instance),i={TABLE:t.internals.ns.selector("table"),TABLE_WRAPPER:[t.internals.ns.selector("table")+" "+t.internals.ns.selector("table__wrapper")],SHADOW:t.internals.ns.selector("table__shadow"),SHADOW_LEFT:t.internals.ns.selector("table__shadow--left"),SHADOW_RIGHT:t.internals.ns.selector("table__shadow--right"),ELEMENT:[t.internals.ns.selector("table")+":not("+t.internals.ns.selector("table--no-scroll")+") table"],CAPTION:t.internals.ns.selector("table")+" table caption",ROW:t.internals.ns.selector("table")+" tbody tr",COL:t.internals.ns.selector("table")+" thead th"},o=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={isScrolling:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TableElement"},e.prototype.init=function(){this.listen("scroll",this.scroll.bind(this)),this.content=this.querySelector("tbody"),this.tableOffsetHeight=0,this.isResizing=!0},n.isScrolling.get=function(){return this._isScrolling},n.isScrolling.set=function(t){this._isScrolling!==t&&(this._isScrolling=t,t?(this.addClass(i.SHADOW),this.scroll()):(this.removeClass(i.SHADOW),this.removeClass(i.SHADOW_LEFT),this.removeClass(i.SHADOW_RIGHT)))},e.prototype.scroll=function(){var t=this.node.scrollLeft<=0,e=this.content.offsetWidth-this.node.offsetWidth-0,n=Math.abs(this.node.scrollLeft)>=e,s="rtl"===document.documentElement.getAttribute("dir"),o=s?i.SHADOW_RIGHT:i.SHADOW_LEFT,r=s?i.SHADOW_LEFT:i.SHADOW_RIGHT;t?this.removeClass(o):this.addClass(o),n?this.removeClass(r):this.addClass(r)},e.prototype.resize=function(){this.isScrolling=this.content.offsetWidth>this.node.offsetWidth},e.prototype.dispose=function(){this.isScrolling=!1},Object.defineProperties(e.prototype,n),Object.defineProperties(e,s),e}(t.core.Instance),r=function(t){function n(){t.apply(this,arguments)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TableCaption"},n.prototype.init=function(){this.height=0,this.isResizing=!0},n.prototype.resize=function(){var t=this.getRect().height;this.height!==t&&(this.height=t,this.ascend(e.CAPTION_HEIGHT,"calc("+t+"px + 1rem)"))},Object.defineProperties(n,s),n}(t.core.Instance),a={CHANGE:t.internals.ns.emission("checkbox","change"),RETRIEVE:t.internals.ns.emission("checkbox","retrieve")},l=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var s={isSelected:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"TableRow"},n.prototype.init=function(){t.checkbox&&(this.addAscent(a.CHANGE,this._handleCheckboxChange.bind(this)),this.descend(a.RETRIEVE))},n.prototype._handleCheckboxChange=function(e){"row-select"!==e.name&&"true"!==e.getAttribute(t.internals.ns.attr("row-select"))||(this.isSelected=!0===e.checked)},n.prototype.render=function(){var t=this.getRect().height+2;this._height!==t&&(this._height=t,this.setProperty("--row-height",this._height+"px"))},s.isSelected.get=function(){return this._isSelected},s.isSelected.set=function(t){this._isSelected!==t&&(this.isRendering=t,this._isSelected=t,this.setAttribute("aria-selected",t))},Object.defineProperties(n.prototype,s),Object.defineProperties(n,i),n}(t.core.Instance);t.table={Table:n,TableWrapper:s,TableElement:o,TableCaption:r,TableSelector:i,TableRow:l},t.internals.register(t.table.TableSelector.TABLE,t.table.Table),t.internals.register(t.table.TableSelector.TABLE_WRAPPER,t.table.TableWrapper),t.internals.register(t.table.TableSelector.ELEMENT,t.table.TableElement),t.internals.register(t.table.TableSelector.CAPTION,t.table.TableCaption),t.internals.register(t.table.TableSelector.ROW,t.table.TableRow)}(); //# sourceMappingURL=table.nomodule.min.js.map