@oslokommune/punkt-react 13.5.9 → 13.5.10

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.
@@ -27393,19 +27393,11 @@ let ta = class extends cn {
27393
27393
  this.dispatchEvent(new Event("input", { bubbles: !0 }));
27394
27394
  }
27395
27395
  valueChanged(e, t) {
27396
- if (e !== t) {
27397
- let a = [];
27398
- if (e && (typeof e == "string" ? a = e.split(",").filter(Boolean) : a = String(e).split(",").filter(Boolean)), this.min || this.max) {
27399
- const u = this.min ? new Date(this.min) : null, d = this.max ? new Date(this.max) : null;
27400
- a = a.filter((f) => {
27401
- const y = new Date(f);
27402
- return !(isNaN(y.getTime()) || u && y < u || d && y > d);
27403
- });
27404
- }
27405
- this._value = a;
27406
- const o = a.join(",");
27407
- this._valueProperty !== o && (this._valueProperty = o), super.valueChanged(o, t);
27408
- }
27396
+ if (e === t) return;
27397
+ let a = [];
27398
+ e && (typeof e == "string" ? a = e.split(",").filter(Boolean) : a = String(e).split(",").filter(Boolean)), this._value = a;
27399
+ const o = a.join(",");
27400
+ this._valueProperty !== o && (this._valueProperty = o), super.valueChanged(o, t);
27409
27401
  }
27410
27402
  attributeChangedCallback(e, t, a) {
27411
27403
  e === "value" && this.value !== t && this.valueChanged(a, t), e === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = (a == null ? void 0 : a.split(",")) ?? []), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = (a == null ? void 0 : a.split(",")) ?? []), super.attributeChangedCallback(e, t, a);
@@ -983,7 +983,7 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
983
983
  ${this.labelPosition==="right"?f():Ke}
984
984
  </div>
985
985
  </div>
986
- `}handleClick(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1}handleChange(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1;this.toggleChecked(t)}toggleChecked(t){if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}const a=t.target;if(a&&a.disabled){t.preventDefault(),t.stopImmediatePropagation();return}t.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(":checked"),this.valueChecked(this.checked))}};Xi([G({type:String,reflect:!0})],_i.prototype,"value",2),Xi([G({type:String})],_i.prototype,"checkHelptext",2),Xi([G({type:Boolean})],_i.prototype,"defaultChecked",2),Xi([G({type:Boolean})],_i.prototype,"hasTile",2),Xi([G({type:Boolean})],_i.prototype,"isSwitch",2),Xi([G({type:String})],_i.prototype,"labelPosition",2),Xi([G({type:Boolean})],_i.prototype,"hideLabel",2),Xi([G({type:Boolean,reflect:!0})],_i.prototype,"checked",2),Xi([G({type:String,reflect:!0})],_i.prototype,"type",2),Xi([G({type:String})],_i.prototype,"tagText",2),Xi([G({type:Boolean})],_i.prototype,"optionalTag",2),Xi([G({type:String})],_i.prototype,"optionalText",2),Xi([G({type:Boolean})],_i.prototype,"requiredTag",2),Xi([G({type:String})],_i.prototype,"requiredText",2),_i=Xi([hr("pkt-checkbox")],_i);const RH={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},Yp={props:RH};var NH=Object.defineProperty,IH=Object.getOwnPropertyDescriptor,fa=(e,t,a,o)=>{for(var u=o>1?void 0:o?IH(t,a):t,d=e.length-1,f;d>=0;d--)(f=e[d])&&(u=(o?f(t,a,u):f(u))||u);return o&&u&&NH(t,a,u),u};const OI=e=>new Promise(t=>setTimeout(t,e));let Xr=class extends cn{constructor(){super(),this._valueProperty="",this._value=[],this.label="Datovelger",this.dateformat=Yp.props.dateformat.default,this.multiple=Yp.props.multiple.default,this.maxlength=null,this.range=Yp.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=Yp.props.weeknumbers.default,this.withcontrols=Yp.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=gn(),this.inputRefTo=gn(),this.btnRef=gn(),this.calRef=gn(),this.popupRef=gn(),this.helptextSlot=gn(),this.addToSelected=t=>{const a=t.target;if(!a.value)return;const o=this.min?Os(this.min):null,u=this.max?Os(this.max):null,d=Os(a.value.split(",")[0]);d&&!isNaN(d.getTime())&&(!o||d>=o)&&(!u||d<=u)&&this.calRef.value&&this.calRef.value.handleDateSelect(d),a.value=""},this.slotController=new qa(this,this.helptextSlot)}get value(){return this._valueProperty}set value(t){const a=this._valueProperty;this._valueProperty=Array.isArray(t)?t.join(","):t||"",this.valueChanged(this._valueProperty,a),this.requestUpdate("value",a)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,a=/iP(hone|od|ad)/.test(t);this.inputType=a?"text":"date",document&&document.body.addEventListener("click",o=>{var u,d;(u=this.inputRef)!=null&&u.value&&(d=this.btnRef)!=null&&d.value&&!this.inputRef.value.contains(o.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(o.target))&&!this.btnRef.value.contains(o.target)&&!o.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),document&&document.body.addEventListener("keydown",o=>{o.key==="Escape"&&this.calendarOpen&&this.hideCalendar()}),this.value&&(this._value=Array.isArray(this.value)?this.value.filter(Boolean):this.value.split(",").filter(Boolean)),this.min=this.min||Yp.props.min.default,this.max=this.max||Yp.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await OI(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var a,o;(a=this.inputRef)!=null&&a.value&&(o=this.btnRef)!=null&&o.value&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(t,a){if(t!==a){let o=[];if(t&&(typeof t=="string"?o=t.split(",").filter(Boolean):o=String(t).split(",").filter(Boolean)),this.min||this.max){const d=this.min?new Date(this.min):null,f=this.max?new Date(this.max):null;o=o.filter(y=>{const E=new Date(y);return!(isNaN(E.getTime())||d&&E<d||f&&E>f)})}this._value=o;const u=o.join(",");this._valueProperty!==u&&(this._valueProperty=u),super.valueChanged(u,a)}}attributeChangedCallback(t,a,o){t==="value"&&this.value!==a&&this.valueChanged(o,a),t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(o==null?void 0:o.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(o==null?void 0:o.split(","))??[]),super.attributeChangedCallback(t,a,o)}updated(t){if(t.has("value")){const a=Array.isArray(this.value)?this.value.join(","):this.value,o=t.get("value"),u=Array.isArray(o)?o.join(","):o;this.valueChanged(a,u)}t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return Se`
986
+ `}handleClick(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1}handleChange(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1;this.toggleChecked(t)}toggleChecked(t){if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}const a=t.target;if(a&&a.disabled){t.preventDefault(),t.stopImmediatePropagation();return}t.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(":checked"),this.valueChecked(this.checked))}};Xi([G({type:String,reflect:!0})],_i.prototype,"value",2),Xi([G({type:String})],_i.prototype,"checkHelptext",2),Xi([G({type:Boolean})],_i.prototype,"defaultChecked",2),Xi([G({type:Boolean})],_i.prototype,"hasTile",2),Xi([G({type:Boolean})],_i.prototype,"isSwitch",2),Xi([G({type:String})],_i.prototype,"labelPosition",2),Xi([G({type:Boolean})],_i.prototype,"hideLabel",2),Xi([G({type:Boolean,reflect:!0})],_i.prototype,"checked",2),Xi([G({type:String,reflect:!0})],_i.prototype,"type",2),Xi([G({type:String})],_i.prototype,"tagText",2),Xi([G({type:Boolean})],_i.prototype,"optionalTag",2),Xi([G({type:String})],_i.prototype,"optionalText",2),Xi([G({type:Boolean})],_i.prototype,"requiredTag",2),Xi([G({type:String})],_i.prototype,"requiredText",2),_i=Xi([hr("pkt-checkbox")],_i);const RH={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},Yp={props:RH};var NH=Object.defineProperty,IH=Object.getOwnPropertyDescriptor,fa=(e,t,a,o)=>{for(var u=o>1?void 0:o?IH(t,a):t,d=e.length-1,f;d>=0;d--)(f=e[d])&&(u=(o?f(t,a,u):f(u))||u);return o&&u&&NH(t,a,u),u};const OI=e=>new Promise(t=>setTimeout(t,e));let Xr=class extends cn{constructor(){super(),this._valueProperty="",this._value=[],this.label="Datovelger",this.dateformat=Yp.props.dateformat.default,this.multiple=Yp.props.multiple.default,this.maxlength=null,this.range=Yp.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=Yp.props.weeknumbers.default,this.withcontrols=Yp.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=gn(),this.inputRefTo=gn(),this.btnRef=gn(),this.calRef=gn(),this.popupRef=gn(),this.helptextSlot=gn(),this.addToSelected=t=>{const a=t.target;if(!a.value)return;const o=this.min?Os(this.min):null,u=this.max?Os(this.max):null,d=Os(a.value.split(",")[0]);d&&!isNaN(d.getTime())&&(!o||d>=o)&&(!u||d<=u)&&this.calRef.value&&this.calRef.value.handleDateSelect(d),a.value=""},this.slotController=new qa(this,this.helptextSlot)}get value(){return this._valueProperty}set value(t){const a=this._valueProperty;this._valueProperty=Array.isArray(t)?t.join(","):t||"",this.valueChanged(this._valueProperty,a),this.requestUpdate("value",a)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,a=/iP(hone|od|ad)/.test(t);this.inputType=a?"text":"date",document&&document.body.addEventListener("click",o=>{var u,d;(u=this.inputRef)!=null&&u.value&&(d=this.btnRef)!=null&&d.value&&!this.inputRef.value.contains(o.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(o.target))&&!this.btnRef.value.contains(o.target)&&!o.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),document&&document.body.addEventListener("keydown",o=>{o.key==="Escape"&&this.calendarOpen&&this.hideCalendar()}),this.value&&(this._value=Array.isArray(this.value)?this.value.filter(Boolean):this.value.split(",").filter(Boolean)),this.min=this.min||Yp.props.min.default,this.max=this.max||Yp.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await OI(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var a,o;(a=this.inputRef)!=null&&a.value&&(o=this.btnRef)!=null&&o.value&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(t,a){if(t===a)return;let o=[];t&&(typeof t=="string"?o=t.split(",").filter(Boolean):o=String(t).split(",").filter(Boolean)),this._value=o;const u=o.join(",");this._valueProperty!==u&&(this._valueProperty=u),super.valueChanged(u,a)}attributeChangedCallback(t,a,o){t==="value"&&this.value!==a&&this.valueChanged(o,a),t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(o==null?void 0:o.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(o==null?void 0:o.split(","))??[]),super.attributeChangedCallback(t,a,o)}updated(t){if(t.has("value")){const a=Array.isArray(this.value)?this.value.join(","):this.value,o=t.get("value"),u=Array.isArray(o)?o.join(","):o;this.valueChanged(a,u)}t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return Se`
987
987
  <input
988
988
  class="${Jt(this.inputClasses)}"
989
989
  .type=${this.inputType}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "13.5.9",
3
+ "version": "13.5.10",
4
4
  "description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@lit-labs/ssr-dom-shim": "^1.2.1",
40
40
  "@lit/react": "^1.0.7",
41
- "@oslokommune/punkt-elements": "^13.5.9",
41
+ "@oslokommune/punkt-elements": "^13.5.10",
42
42
  "prettier": "^3.3.3",
43
43
  "react-element-to-jsx-string": "^15.0.0",
44
44
  "react-hook-form": "^7.53.0",
@@ -110,5 +110,5 @@
110
110
  "url": "https://github.com/oslokommune/punkt/issues"
111
111
  },
112
112
  "license": "MIT",
113
- "gitHead": "92ee2058dae920d5ab968d8a1691f435a795e2ca"
113
+ "gitHead": "620a533438712c433484060ce628f538354c2c55"
114
114
  }