@hpcc-js/form 3.5.0 → 3.5.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/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IInput as e } from "@hpcc-js/api";
|
|
2
2
|
import { HTMLWidget as t, SVGWidget as n, WidgetArray as r, d3Event as i, drag as a, format as o, rgb as s, scaleLinear as c, select as l, timeFormat as u, timeParse as d } from "@hpcc-js/common";
|
|
3
3
|
//#region \0rolldown/runtime.js
|
|
4
|
-
var f = "@hpcc-js/form", p = "3.5.
|
|
4
|
+
var f = "@hpcc-js/form", p = "3.5.2", m = "3.27.0", Button = class extends t {
|
|
5
5
|
_inputElement = [];
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), e.call(this), this._tag = "div";
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/api`,`@hpcc-js/common`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/form`]={},e[`@hpcc-js/api`],e[`@hpcc-js/common`]))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=`@hpcc-js/form`,i=`3.5.
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/api`,`@hpcc-js/common`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/form`]={},e[`@hpcc-js/api`],e[`@hpcc-js/common`]))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=`@hpcc-js/form`,i=`3.5.2`,a=`3.27.0`,Button=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this;this._inputElement[0]=t.append(`button`).attr(`name`,this.name()).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){n.value([n._inputElement[0].property(`value`)]),e.change(e,!0)})}update(e,t){super.update(e,t),this._inputElement[0].text(this.value())}};Button.prototype._class+=` form_Button`,Button.prototype.implements(t.IInput.prototype);var CheckBox=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this,r=t.append(`ul`);this.selectOptions().length||this.selectOptions().push(``),this.selectOptions().forEach(function(e,t){n._inputElement[t]=r.append(`li`).append(`input`).attr(`type`,`checkbox`),n._inputElement[t].node().insertAdjacentHTML(`afterend`,`<text>`+e+`</text>`)}),this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){let t=[];n._inputElement.forEach(function(e){e.property(`checked`)&&t.push(e.property(`value`))}),n.value(t),e.change(e,!0)})})}update(e,t){super.update(e,t);let n=this;this._inputElement.forEach(function(e,t){e.property(`value`,n.selectOptions()[t]),n.value().indexOf(n.selectOptions()[t])!==-1&&n.value()!==`false`?e.property(`checked`,!0):e.property(`checked`,!1)})}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};CheckBox.prototype._class+=` form_CheckBox`,CheckBox.prototype.implements(t.IInput.prototype),CheckBox.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`);var ColorInput=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let r=this;this._inputElement[0]=t.append(`input`).attr(`type`,`text`),this._inputElement[0].classed(`color-text`,!0),this._inputElement[1]=t.append(`input`).attr(`type`,`color`),this._inputElement.forEach(function(e,t){e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){t===0?(r._inputElement[1].property(`value`,(0,n.rgb)(r._inputElement[0].property(`value`)).toString()),r.value(r._inputElement[0].property(`value`))):(r._inputElement[0].property(`value`,r._inputElement[1].property(`value`)),r.value((0,n.rgb)(r._inputElement[1].property(`value`)).toString())),e.change(e,!0)})})}update(e,t){super.update(e,t);let r=this;this._inputElement.forEach(function(e){e.attr(`name`,r.name())}),this._inputElement[0].attr(`type`,`text`),this._inputElement[1].attr(`type`,`color`),this._inputElement[0].property(`value`,this.value()),this._inputElement[1].property(`value`,(0,n.rgb)(this.value()).toString());let i=this._inputElement[0].node().getBoundingClientRect();this._inputElement[1].style(`height`,i.height-2+`px`)}};ColorInput.prototype._class+=` form_ColorInput`,ColorInput.prototype.implements(t.IInput.prototype);var Form=class extends n.HTMLWidget{tbody;tfoot;btntd;_controls;_maxCols;constructor(){super(),this._tag=`form`}data(e){if(arguments.length)this.inputsForEach(function(t,n){e&&e.length>n&&t.value(e[n]).render()});else{let e=[];return this.inputsForEach(function(t){e.push(t.value())}),e}return this}inputsForEach(e,t){let r=0;this.inputs().forEach(function(i){(i instanceof n.WidgetArray?i.content():[i]).forEach(function(n){t?e.call(t,n,r++):e(n,r++)})})}inputsMap(){let e={};return this.inputs().forEach(function(t){e[t.name()]=t}),e}calcMaxColumns(){let e=0;return this.inputs().forEach(function(t){let r=t instanceof n.WidgetArray?t.content():[t];r.length>e&&(e=r.length)}),e}values(e){if(arguments.length)this.inputsForEach(function(t){e[t.name()]?t.value(e[t.name()]):this.omitBlank()&&t.value(``)},this);else{let e={};return this.inputsForEach(function(t){let n=t.type?t.type():`text`;if(t.value()||!this.omitBlank())switch(n){case`checkbox`:e[t.name()]=t.value_exists()?!!t.value():void 0;break;case`number`:let n=t.value();e[t.name()]=n===``?void 0:+n;break;default:e[t.name()]=t.value_exists()?t.value():void 0;break}},this),e}return this}submit(){let e=!0;this.validate()&&(e=this.checkValidation()),!(!this.allowEmptyRequest()&&!this.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))&&this.click(e?this.values():null,null,e)}clear(){this.inputsForEach(function(e){switch(e.classID()){case`form_Slider`:e.allowRange()?e.value([e.low(),e.low()]).render():e.value(e.low()).render();break;case`form_CheckBox`:e.value(!1).render();break;case`form_Button`:break;default:e.value(void 0).render();break}})}checkValidation(){let e=!0,t=[];return this.inputsForEach(function(e){e.isValid()||t.push(`'`+e.label()+`' value is invalid.`)}),t.length>0&&(alert(t.join(`
|
|
2
2
|
`)),e=!1),e}enter(e,t){super.enter(e,t),t.on(`submit`,function(){(0,n.d3Event)().preventDefault()}),this._placeholderElement.style(`overflow`,`auto`);let r=t.append(`table`);this.tbody=r.append(`tbody`),this.tfoot=r.append(`tfoot`),this.btntd=this.tfoot.append(`tr`).append(`td`).attr(`colspan`,2);let i=this;this._controls=[new Button().classed({default:!0}).value(`Submit`).on(`click`,function(){i.submit()},!0),new Button().value(`Clear`).on(`click`,function(){i.clear()},!0)];let a=i.btntd.append(`div`).style(`float`,`right`);this._controls.forEach(function(e){let t=a.append(`span`).style(`float`,`left`);e.target(t.node()).render()})}update(e,t){super.update(e,t),this._maxCols=this.calcMaxColumns();let r=this,i=this.tbody.selectAll(`tr`).data(this.inputs());i.enter().append(`tr`).each(function(e,t){let i=(0,n.select)(this),a=e instanceof n.WidgetArray?e.content():[e];a.forEach(function(e,t){i.append(`td`).attr(`class`,`prompt`);let o=i.append(`td`).attr(`class`,`input`);if(t===a.length-1&&a.length<r._maxCols&&o.attr(`colspan`,(r._maxCols-a.length+1)*2),e.target(o.node()).render(),e instanceof n.SVGWidget){let t=e.element().node().getBBox();o.style(`height`,t.height+`px`),e.resize().render()}e._inputElement instanceof Array&&e._inputElement.forEach(function(e){e.on(`keyup.form`,function(e){setTimeout(function(){r._controls[0].disable(!r.allowEmptyRequest()&&!r.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))},100)})})})}).merge(i).each(function(e,t){let r=(0,n.select)(this);(e instanceof n.WidgetArray?e.content():[e]).forEach(function(e,t){r.select(`td.prompt`).text(e.label()+`:`)})}),i.each(function(e,t){t===0&&e.setFocus&&e.setFocus()}),i.exit().each(function(e,t){(e instanceof n.WidgetArray?e.content():[e]).forEach(function(e,t){e.target(null)})}).remove(),this.tfoot.style(`display`,this.showSubmit()?`table-footer-group`:`none`),this.btntd.attr(`colspan`,this._maxCols*2),this.allowEmptyRequest()||setTimeout(function(){r._controls[0].disable(!r.allowEmptyRequest()&&!r.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))},100)}exit(e,t){this.inputsForEach(e=>e.target(null)),super.exit(e,t)}click(e,t,n){}};Form.prototype._class+=` form_Form`,Form.prototype.publish(`validate`,!0,`boolean`,`Enable/Disable input validation`),Form.prototype.publish(`inputs`,[],`widgetArray`,`Array of input widgets`,null,{render:!1}),Form.prototype.publish(`showSubmit`,!0,`boolean`,`Show Submit/Cancel Controls`),Form.prototype.publish(`omitBlank`,!1,`boolean`,`Drop Blank Fields From Submit`),Form.prototype.publish(`allowEmptyRequest`,!1,`boolean`,`Allow Blank Form to be Submitted`);var Input=class extends n.HTMLWidget{_inputElement=[];_labelElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}checked(e){return arguments.length?(this._inputElement[0]&&this._inputElement[0].property(`checked`,e),this):this._inputElement[0]?this._inputElement[0].property(`checked`):!1}enter(e,t){super.enter(e,t),this._labelElement[0]=t.append(`label`).attr(`for`,this.id()+`_input`).style(`visibility`,this.inlineLabel_exists()?`visible`:`hidden`);let n=this;switch(this.type()){case`button`:this._inputElement[0]=t.append(`button`).attr(`id`,this.id()+`_input`);break;case`textarea`:this._inputElement[0]=t.append(`textarea`).attr(`id`,this.id()+`_input`);break;default:this._inputElement[0]=t.append(`input`).attr(`id`,this.id()+`_input`).attr(`type`,this.type());break}this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(t){n.value([e.property(`value`)]),t.change(t,!0)}),e.on(`keyup`,function(t){n.value([e.property(`value`)]),t.change(t,!1)})})}update(e,t){switch(super.update(e,t),this._labelElement[0].style(`visibility`,this.inlineLabel_exists()?`visible`:`hidden`).text(this.inlineLabel()),this.type()){case`button`:this._inputElement[0].text(this.value());break;case`textarea`:this._inputElement[0].property(`value`,this.value());break;default:this._inputElement[0].attr(`type`,this.type()),this._inputElement[0].property(`value`,this.value());break}}blur(e){}keyup(e){}focus(e){}click(e){}dblclick(e){}change(e,t){}};Input.prototype._class+=` form_Input`,Input.prototype.implements(t.IInput.prototype),Input.prototype.publish(`type`,`text`,`set`,`Input type`,[`string`,`number`,`boolean`,`date`,`time`,`hidden`,`nested`,`button`,`checkbox`,`text`,`textarea`,`search`,`email`,`datetime`]),Input.prototype.publish(`inlineLabel`,null,`string`,`Input Label`,null,{optional:!0});var FieldForm=class extends Form{constructor(){super(),this._tag=`form`}fields(e){let t=super.fields.apply(this,arguments);if(arguments.length){let t=this.inputsMap();this.inputs(e.map(e=>t[e.id()]||new Input().name(e.id()).label(e.label()).type(e.type())))}return t}data(e){if(!arguments.length)return super.data();if(super.data(e[0]),e[0]){let t=this.inputs(),n=e[0][this.columns().length],r=0;for(let e in n)t[r].name(e),++r}return this}};FieldForm.prototype._class+=` form_FieldForm`;var InputRange=class extends n.HTMLWidget{_inputElement=[];_labelElement=[];_rangeData=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t),this._labelElement[0]=t.append(`label`).attr(`for`,this.id()+`_input`).style(`visibility`,this.inlineLabel_exists()?`visible`:`hidden`),this._inputElement.push(t.append(`input`).attr(`id`,this.id()+`_input_min`).attr(`type`,this.type())),this._inputElement.push(t.append(`input`).attr(`id`,this.id()+`_input_max`).attr(`type`,this.type()));let n=this;this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(r){n._rangeData[t]=e.property(`value`),n.value(n._rangeData),r.change(r,!0)})})}update(e,t){super.update(e,t),this._labelElement[0].style(`visibility`,this.inlineLabel_exists()?`visible`:`hidden`).text(this.inlineLabel()),this._rangeData=this.value(),this._inputElement.forEach(function(e,t){e.attr(`type`,this.type()).property(`value`,this._rangeData.length>t?this._rangeData[t]:``)},this)}};InputRange.prototype._class+=` form_InputRange`,InputRange.prototype.implements(t.IInput.prototype),InputRange.prototype.publish(`type`,`text`,`set`,`InputRange type`,[`number`,`date`,`text`,`time`,`datetime`,`hidden`]),InputRange.prototype.publish(`inlineLabel`,null,`string`,`InputRange Label`,null,{optional:!0}),InputRange.prototype.publish(`value`,[``,``],`array`,`Input Current Value`,null,{override:!0});var OnOff=class extends n.HTMLWidget{_inputElement=[];_input;constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t),t.classed(`onoffswitch`,!0);let n=this;this._input=t.append(`input`).attr(`class`,`onoffswitch-checkbox`).attr(`type`,`checkbox`).attr(`id`,this.id()+`_onOff`).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){let t=[];n._inputElement.forEach(function(e,n){e.property(`checked`)&&t.push(e.property(`value`))}),n.value(t),e.change(e,!0)});let r=t.append(`label`).attr(`class`,`onoffswitch-label`).attr(`for`,this.id()+`_onOff`),i=r.append(`div`).attr(`class`,`onoffswitch-inner`);i.append(`div`).attr(`class`,`onoffswitch-offText`).style(`padding-right`,this.containerRadius()/2+`px`).text(this.offText()),i.append(`div`).attr(`class`,`onoffswitch-onText`).style(`padding-left`,this.containerRadius()/2+`px`).style(`width`,`calc(100% - ${this.containerRadius()/2}px)`).text(this.onText()),r.append(`div`).attr(`class`,`onoffswitch-switch`)}update(e,t){super.update(e,t),this._input.attr(`name`,this.name()),t.style(`margin-left`,this.marginLeft()+`px`).style(`margin-bottom`,this.marginBottom()+`px`).style(`width`,this.minWidth()+`px`);let n=this.minHeight()-this.gutter()*4;t.select(`.onoffswitch-switch`).style(`height`,n+`px`).style(`width`,n+`px`).style(`top`,this.gutter()*2+1+`px`).style(`border-radius`,this.switchRadius()+`px`),t.select(`.onoffswitch-inner`).style(`min-height`,this.minHeight()+`px`),t.select(`.onoffswitch-label`).style(`border-radius`,this.containerRadius()+`px`),t.select(`.onoffswitch-offText`).style(`color`,this.offFontColor()).style(`background-color`,this.offColor()),t.select(`.onoffswitch-onText`).style(`color`,this.onFontColor()).style(`background-color`,this.onColor())}};OnOff.prototype._class+=` form_OnOff`,OnOff.prototype.implements(t.IInput.prototype),OnOff.prototype.publish(`marginLeft`,0,`number`,`Margin left of OnOff`),OnOff.prototype.publish(`marginBottom`,0,`number`,`Margin bottom of OnOff`),OnOff.prototype.publish(`minWidth`,100,`number`,`Minimum width of OnOff (pixels)`),OnOff.prototype.publish(`minHeight`,20,`number`,`Minimum height of OnOff (pixels)`),OnOff.prototype.publish(`gutter`,1,`number`,`Space between switch and border of OnOff (pixels)`),OnOff.prototype.publish(`onText`,`Save`,`string`,`Text to display when 'ON'`),OnOff.prototype.publish(`offText`,`Properties`,`string`,`Text to display when 'OFF'`),OnOff.prototype.publish(`switchRadius`,10,`number`,`Border radius of switch (pixels)`),OnOff.prototype.publish(`containerRadius`,10,`number`,`Border radius of OnOff (pixels)`),OnOff.prototype.publish(`onColor`,`#2ecc71`,`html-color`,`Background color when 'ON'`),OnOff.prototype.publish(`offColor`,`#ecf0f1`,`html-color`,`Background color when 'OFF'`),OnOff.prototype.publish(`onFontColor`,`#2c3e50`,`html-color`,`Font color when 'ON'`),OnOff.prototype.publish(`offFontColor`,`#7f8c8d`,`html-color`,`Font color when 'OFF'`);var Radio=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this,r=t.append(`ul`);this.selectOptions().length||this.selectOptions().push(``),this.selectOptions().forEach(function(e,t){n._inputElement[t]=r.append(`li`).append(`input`).attr(`type`,`radio`),n._inputElement[t].node().insertAdjacentHTML(`afterend`,`<text>`+e+`</text>`)}),this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(t){n.value([e.property(`value`)]),t.change(t,!0)})})}update(e,t){super.update(e,t);let n=this;this._inputElement.forEach(function(e,t){e.property(`value`,n.selectOptions()[t]),n.value().indexOf(n.selectOptions()[t])!==-1&&n.value()!==`false`?e.property(`checked`,!0):e.property(`checked`,!1)})}};Radio.prototype._class+=` form_Radio`,Radio.prototype.implements(t.IInput.prototype),Radio.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`);var Range=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let r=this;this._inputElement[0]=t.append(`input`).attr(`type`,`range`),this._inputElement[1]=t.append(`input`).attr(`type`,`number`),this._inputElement.forEach(function(e,t){e.attr(`name`,r.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){t===0?(r._inputElement[1].property(`value`,(0,n.rgb)(r._inputElement[0].property(`value`)).toString()),r.value(r._inputElement[0].property(`value`))):(r._inputElement[0].property(`value`,r._inputElement[1].property(`value`)),r.value((0,n.rgb)(r._inputElement[1].property(`value`)).toString())),e.change(e,!0)})})}update(e,t){super.update(e,t),this._inputElement[0].attr(`type`,`range`),this._inputElement[0].property(`value`,this.value()),this._inputElement[0].attr(`min`,this.low()),this._inputElement[0].attr(`max`,this.high()),this._inputElement[0].attr(`step`,this.step()),this._inputElement[1].attr(`type`,`number`),this._inputElement[1].property(`value`,this.value()),this._inputElement[1].attr(`min`,this.low()),this._inputElement[1].attr(`max`,this.high()),this._inputElement[1].attr(`step`,this.step())}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};Range.prototype._class+=` form_Range`,Range.prototype.implements(t.IInput.prototype),Range.prototype.publish(`type`,`text`,`set`,`Input type`,[`html-color`,`number`,`checkbox`,`button`,`select`,`textarea`,`date`,`text`,`range`,`search`,`email`,`time`,`datetime`]),Range.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`),Range.prototype.publish(`low`,null,`number`,`Minimum value for Range input`),Range.prototype.publish(`high`,null,`number`,`Maximum value for Range input`),Range.prototype.publish(`step`,null,`number`,`Step value for Range input`);var Select=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this;this._inputElement[0]=t.append(`select`).attr(`name`,this.name()).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){n.value([n._inputElement[0].property(`value`)]),e.change(e,!0)})}update(e,t){super.update(e,t),this.insertSelectOptions(this.selectOptions()),this._inputElement[0].property(`value`,this.value()).style(`max-width`,this.maxWidth_exists()?this.maxWidth()+`px`:null)}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};Select.prototype._class+=` form_Select`,Select.prototype.implements(t.IInput.prototype),Select.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`),Select.prototype.publish(`maxWidth`,120,`number`,`Width`,null,{optional:!0});var Slider=class extends n.SVGWidget{xScale;moveMode;moveStartPos;prevValue;slider;handleLeft;handleLeftPos=0;handleLeftStartPos;handleRight;handleRightPos=0;handleRightStartPos;constructor(){super(),t.IInput.call(this)}enter(e,t){if(super.enter(e,t),this.resize({width:this.width(),height:50}),this.xScale=(0,n.scaleLinear)().clamp(!0),this.slider=t.append(`g`).attr(`class`,`slider`),this.low()===null&&this.high()===null&&this.lowDatetime()!==null&&this.highDatetime()!==null){let e=(0,n.timeParse)(this.timePattern()?this.timePattern():`%Q`);this.low(e(this.lowDatetime()).getTime()),this.high(e(this.highDatetime()).getTime())}this.slider.append(`line`).attr(`class`,`track`).select(function(){return this.parentNode.appendChild(this.cloneNode(!0))}).attr(`class`,`track-inset`).select(function(){return this.parentNode.appendChild(this.cloneNode(!0))}).attr(`class`,`track-overlay`).call((0,n.drag)().on(`start`,()=>{let e=(0,n.d3Event)();this.moveStartPos=e.x,this.handleLeftStartPos=this.handleLeftPos,this.handleRightStartPos=this.handleRightPos,this.allowRange()&&this.handleLeftPos<=e.x&&e.x<=this.handleRightPos?this.moveMode=`both`:Math.abs(e.x-this.handleLeftPos)<Math.abs(e.x-this.handleRightPos)?this.moveMode=`left`:this.moveMode=`right`,this.moveHandleTo(e.x)}).on(`drag`,()=>{this.moveHandleTo((0,n.d3Event)().x)}).on(`end`,()=>{this.moveHandleTo((0,n.d3Event)().x),this.data([[this.xScale.invert(this.handleLeftPos),this.xScale.invert(this.handleRightPos)]]),this.checkChangedValue()})),this.slider.insert(`g`,`.track-overlay`).attr(`class`,`ticks`).attr(`transform`,`translate(0, ${this.fontSize()+this.tickHeight()/2})`),this.handleRight=this.slider.insert(`path`,`.track-overlay`).attr(`class`,`handle`),this.handleLeft=this.slider.insert(`path`,`.track-overlay`).attr(`class`,`handle`)}update(e,t){super.update(e,t);let r=this;this.xScale.domain([this.low(),this.high()]).range([0,this.width()-this.padding()*2]),this.slider.attr(`transform`,`translate(`+(-this.width()/2+this.padding())+`,0)`),this.slider.selectAll(`line.track,line.track-inset,line.track-overlay`).attr(`x1`,this.xScale.range()[0]).attr(`x2`,this.xScale.range()[1]);let i=(this.width()-this.padding()*2)/(this.tickCount()-1),a=[];if(this.tickDateFormat()!==null&&this.timePattern()!==null){let e=(0,n.timeParse)(`%Q`),t=(0,n.timeFormat)(this.tickDateFormat()),r=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){let i=e(``+(this.low()+r*n));a.push(t(i))}}else{let e=(0,n.format)(this.tickValueFormat()),t=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){let r=this.low()+t*n;a.push(e(r))}}let o=this.slider.selectAll(`g.tick`).data(a),s=o.enter().append(`g`).attr(`class`,`tick`);s.append(`text`).attr(`class`,`tick-text`),s.append(`line`).attr(`class`,`tick-line`),s.merge(o).each(function(e,t){let a=i*t;(0,n.select)(this).select(`text.tick-text`).style(`font-size`,r.fontSize()).attr(`x`,function(){return t===0?a-2:t===r.tickCount()-1?a+2:a}).attr(`y`,r.tickHeight()+r.tickOffset()/2+r.fontSize()).attr(`text-basline`,`text-before-edge`).attr(`text-anchor`,function(){return t===0?`start`:t===r.tickCount()-1?`end`:`middle`}).text(()=>e),(0,n.select)(this).select(`line.tick-line`).attr(`x1`,a).attr(`x2`,a).attr(`y1`,r.tickOffset()-1).attr(`y2`,r.tickOffset()+r.tickHeight()).style(`stroke`,`#000`).style(`stroke-width`,1)}),this.slider.node().appendChild(this.handleRight.node()),this.slider.node().appendChild(this.handleLeft.node()),this.handleLeftPos=this.lowPos(),this.handleRightPos=this.highPos(),this.updateHandles(),this.checkChangedValue()}checkChangedValue(){this.prevValue!==this.value()&&this.prevValue!==void 0&&this.change(this),this.prevValue=this.value()}updateHandles(){this.handleLeft.attr(`transform`,`translate(${this.handleLeftPos}, -28)`).attr(`d`,e=>this.handlePath(`l`)),this.handleRight.attr(`transform`,`translate(${this.handleRightPos}, -28)`).attr(`d`,e=>this.handlePath(`r`))}lowPos(){let e=[[this.low(),this.high()]];return this.data().length>0&&typeof this.data()[0][0]==`number`&&typeof this.data()[0][1]==`number`&&(e=this.data()),this.xScale(e[0][0])}highPos(){let e=[[this.low(),this.high()]];return this.data().length>0&&typeof this.data()[0][0]==`number`&&typeof this.data()[0][1]==`number`&&(e=this.data()),this.xScale(e[0][+!!this.allowRange()])}moveHandleTo(e){if(this.allowRange())switch(this.moveMode){case`both`:this.handleLeftPos=this.handleLeftStartPos+e-this.moveStartPos,this.handleRightPos=this.handleRightStartPos+e-this.moveStartPos;break;case`left`:this.handleLeftPos=e,this.handleLeftPos>this.handleRightPos&&(this.handleRightPos=this.handleLeftPos);break;case`right`:this.handleRightPos=e,this.handleRightPos<this.handleLeftPos&&(this.handleLeftPos=this.handleRightPos);break}else this.handleLeftPos=this.handleRightPos=e;this.handleLeftPos=this.constrain(this.handleLeftPos),this.handleRightPos=this.constrain(this.handleRightPos),this.value(this.allowRange()?[this.xScale.invert(this.handleLeftPos),this.xScale.invert(this.handleRightPos)]:this.xScale.invert(this.handleLeftPos)),this.updateHandles()}constrain(e){let t=this.xScale.range();return e<t[0]&&(e=t[0]),e>t[1]&&(e=t[1]),this.nearestStep(e)}nearestStep(e){let t=this.xScale.invert(e);return this.xScale(this.low()+Math.round((t-this.low())/this.step())*this.step())}handlePath=function(e){let t=+(e===`r`),n=t?1:-1,r=this.allowRange()?.5:0,i=`M`+r*n+`,18A6,6 0 0 `+t+` `+6.5*n+`,24V30A6,6 0 0 `+t+` `+r*n+`,36`;return this.allowRange()?i+=`ZM`+2.5*n+`,26V28M`+4.5*n+`,26V28`:i+=`M`+1*n+`,26V28`,i}};Slider.prototype._class+=` form_Slider`,Slider.prototype.implements(t.IInput.prototype),Slider.prototype.publish(`padding`,16,`number`,`Outer Padding`,null,{tags:[`Basic`]}),Slider.prototype.publish(`fontSize`,12,`number`,`Font Size`,null,{tags:[`Basic`]}),Slider.prototype.publish(`fontFamily`,null,`string`,`Font Name`,null,{tags:[`Basic`]}),Slider.prototype.publish(`fontColor`,null,`html-color`,`Font Color`,null,{tags:[`Basic`]}),Slider.prototype.publish(`allowRange`,!1,`boolean`,`Allow Range Selection`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`low`,null,`number`,`Low`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`high`,null,`number`,`High`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`step`,10,`number`,`Step`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`lowDatetime`,null,`string`,`Low`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`highDatetime`,null,`string`,`High`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`selectionLabel`,``,`string`,`Selection Label`,null,{tags:[`Intermediate`]}),Slider.prototype.publish(`timePattern`,`%Y-%m-%d`,`string`),Slider.prototype.publish(`tickCount`,10,`number`),Slider.prototype.publish(`tickOffset`,5,`number`),Slider.prototype.publish(`tickHeight`,8,`number`),Slider.prototype.publish(`tickDateFormat`,null,`string`),Slider.prototype.publish(`tickValueFormat`,`,.0f`,`string`);var o=Slider.prototype.name;Slider.prototype.name=function(e){let t=o.apply(this,arguments);if(arguments.length){let t=e instanceof Array?e:[e];n.SVGWidget.prototype.columns.call(this,t)}return t};var s=Slider.prototype.value;Slider.prototype.value=function(e){let t=s.apply(this,arguments);if(arguments.length)n.SVGWidget.prototype.data.call(this,[this.allowRange()?e:[e,e]]);else return this.allowRange()?n.SVGWidget.prototype.data.call(this)[0]:n.SVGWidget.prototype.data.call(this)[0][0];return t};var TextArea=class extends Input{constructor(){super(),this._tag=`div`,this.type(`textarea`)}enter(e,t){super.enter(e,t)}calcHeight(){return Math.max(this.minHeight_exists()?this.minHeight():0,this.height())}update(e,t){super.update(e,t),this._inputElement[0].attr(`rows`,this.rows()).attr(`cols`,this.cols()).attr(`wrap`,this.wrap()).attr(`spellcheck`,this.spellcheck()).style(`height`,this.calcHeight()+`px`)}};TextArea.prototype._class+=` form_TextArea`,TextArea.prototype.publish(`rows`,null,`number`,`Rows`,null,{optional:!0}),TextArea.prototype.publish(`cols`,null,`number`,`Columns`,null,{optional:!0}),TextArea.prototype.publish(`wrap`,`off`,`set`,`Wrap`,[`off`,`on`]),TextArea.prototype.publish(`minHeight`,null,`number`,`Minimum Height`,null,{optional:!0}),TextArea.prototype.publish(`spellcheck`,null,`boolean`,`Input spell checking`,{optional:!0}),e.BUILD_VERSION=a,e.Button=Button,e.CheckBox=CheckBox,e.ColorInput=ColorInput,e.FieldForm=FieldForm,e.Form=Form,e.Input=Input,e.InputRange=InputRange,e.OnOff=OnOff,e.PKG_NAME=r,e.PKG_VERSION=i,e.Radio=Radio,e.Range=Range,e.Select=Select,e.Slider=Slider,e.TextArea=TextArea});
|
|
3
3
|
//# sourceMappingURL=index.umd.cjs.map
|
|
4
4
|
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.form_Input input,.form_Input select,.form_Input button,.form_Input textarea{padding:2px}.form_Input button{cursor:pointer}.form_Input input.color-text{width:120px}.form_Input input.color-text+input{width:57px;position:absolute}.form_Input textarea,.form_Input input[type=textbox]{box-sizing:border-box;width:100%;display:block}.form_Input ul{float:left;margin:0;padding:0;list-style-type:none}.form_Input li{float:left;list-style-position:inside}.form_Form{color:#404040}.form_Form tbody td{white-space:nowrap;border:1px solid #e5e5e5}.form_Form td.prompt{vertical-align:middle;background-color:#e5e5e5;padding:2px}.form_Form td.input{vertical-align:middle;width:100%;padding:2px}.form_Form td.input .common_HTMLWidget ul{margin:0}.form_Form tfoot button{margin:5px}.form_Form tbody tr:hover{background-color:#fafafa}.form_Form .form_Button button{box-sizing:border-box;color:#24292e;cursor:pointer;overflow-wrap:break-word;vertical-align:middle;white-space:nowrap;word-wrap:break-word;column-rule-color:#24292e;perspective-origin:57.2938px 14px;transform-origin:57.2938px 14px;-webkit-user-select:none;user-select:none;background:#eff3f6 linear-gradient(-180deg,#fafbfc 0%,#eff3f6 90%) -1px -1px/110% 110% repeat-x;border:1px solid #1b1f2333;border-radius:3px;outline:0 #24292e;height:28px;padding:3px 10px;-webkit-text-decoration:none;text-decoration:none;position:relative;inset:0}.form_Form .form_Button button[disabled=disabled]{background:#dbdfe2}.form_Form .form_Button button:focus{box-shadow:0 0 0 .2em #0366d64d}.form_Form .form_Button button:hover{background:#dbdfe2}.form_Form .form_Button.default button{color:#fff;word-wrap:break-word;column-rule-color:#fff;perspective-origin:44.975px 17px;transform-origin:44.975px 17px;background:#28a745 linear-gradient(-180deg,#34d058 0%,#28a745 90%) -1px -1px/110% 110% repeat-x;outline:0 #fff;-webkit-text-decoration:none;text-decoration:none}.form_Form .form_Button.default button[disabled=disabled],.form_Form .form_Button.default button[disabled=disabled]:hover{background:#dbdfe2}.form_Form .form_Button.default button:hover{background:#149331}.onoffswitch-checkbox{display:none}.onoffswitch{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;width:100px;height:20px;position:relative}.onoffswitch-label{cursor:pointer;border:1px solid #999;height:20px;display:block;overflow:hidden}.onoffswitch-inner{transition:margin .3s ease-in;display:block;position:relative}.onoffswitch-inner>.onoffswitch-offText,.onoffswitch-inner>.onoffswitch-onText{height:100%}.onoffswitch-inner>.onoffswitch-offText{text-align:right;width:100%;font-weight:700;transition:all .3s ease-in;position:absolute;right:0}.onoffswitch-inner>.onoffswitch-onText{text-align:left;width:100%;font-weight:700;transition:all .3s ease-in;position:absolute;left:-100%}.onoffswitch-switch{background:#fff;border:1px solid #999;width:20px;margin:-1px;transition:all .3s ease-in;display:block;position:absolute;inset:0 78px 0 4px}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner>.onoffswitch-offText{right:-100%}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner>.onoffswitch-onText{left:0}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-switch{left:calc(100% - 20px)}.form_Slider .ticks{font:10px sans-serif}.form_Slider .track,.form_Slider .track-inset,.form_Slider .track-overlay{stroke-linecap:round}.form_Slider .track{stroke:#000;stroke-opacity:.3;stroke-width:10px}.form_Slider .track-inset{stroke:#ddd;stroke-width:8px}.form_Slider .track-overlay{pointer-events:stroke;stroke-width:50px;stroke:#0000;cursor:crosshair}.form_Slider .handle{fill:#fff;stroke:#000;stroke-opacity:.5;stroke-width:1.25px}.form_Slider .tick-line{stroke:#000;stroke-opacity:.5;stroke-width:1px;shape-rendering:crispedges}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/form",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "hpcc-js - Viz Form",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"types/*"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
|
|
24
|
+
"clean": "rimraf --glob lib* types types-3.4 dist *.tsbuildinfo .turbo",
|
|
25
25
|
"bundle": "vite build",
|
|
26
26
|
"bundle-watch": "vite build --watch",
|
|
27
27
|
"bundle-serve": "vite --port 5508",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"update-major": "npx --yes npm-check-updates -u"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@hpcc-js/api": "^3.5.
|
|
43
|
-
"@hpcc-js/chart": "^3.8.
|
|
44
|
-
"@hpcc-js/common": "^3.8.
|
|
42
|
+
"@hpcc-js/api": "^3.5.2",
|
|
43
|
+
"@hpcc-js/chart": "^3.8.2",
|
|
44
|
+
"@hpcc-js/common": "^3.8.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@hpcc-js/esbuild-plugins": "^1.9.
|
|
47
|
+
"@hpcc-js/esbuild-plugins": "^1.9.2",
|
|
48
48
|
"d3-brush": "^1",
|
|
49
49
|
"d3-color": "3.1.0",
|
|
50
50
|
"d3-drag": "^1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "9d31241482c78decca86e3bf624244ce5b40f3d6"
|
|
66
66
|
}
|