@govtechsg/sgds-web-component 3.15.1-rc.2 → 3.15.1-rc.3

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.
Files changed (56) hide show
  1. package/components/ComboBox/index.umd.min.js.map +1 -1
  2. package/components/ComboBox/sgds-combo-box.d.ts +3 -3
  3. package/components/ComboBox/sgds-combo-box.js +1 -0
  4. package/components/ComboBox/sgds-combo-box.js.map +1 -1
  5. package/components/ComboBox/types.d.ts +3 -0
  6. package/components/FileUpload/index.umd.min.js.map +1 -1
  7. package/components/FileUpload/sgds-file-upload.d.ts +3 -0
  8. package/components/FileUpload/sgds-file-upload.js +1 -0
  9. package/components/FileUpload/sgds-file-upload.js.map +1 -1
  10. package/components/FileUpload/types.d.ts +1 -0
  11. package/components/Pagination/index.umd.min.js.map +1 -1
  12. package/components/Pagination/sgds-pagination.d.ts +3 -0
  13. package/components/Pagination/sgds-pagination.js +1 -0
  14. package/components/Pagination/sgds-pagination.js.map +1 -1
  15. package/components/Pagination/types.d.ts +3 -0
  16. package/components/Radio/index.umd.min.js.map +1 -1
  17. package/components/Radio/sgds-radio-group.d.ts +3 -0
  18. package/components/Radio/sgds-radio-group.js +1 -0
  19. package/components/Radio/sgds-radio-group.js.map +1 -1
  20. package/components/Radio/types.d.ts +3 -0
  21. package/components/Stepper/index.umd.min.js.map +1 -1
  22. package/components/Stepper/sgds-stepper.d.ts +2 -5
  23. package/components/Stepper/sgds-stepper.js.map +1 -1
  24. package/components/Stepper/types.d.ts +5 -0
  25. package/components/Switch/index.umd.min.js.map +1 -1
  26. package/components/Switch/sgds-switch.d.ts +3 -0
  27. package/components/Switch/sgds-switch.js +1 -0
  28. package/components/Switch/sgds-switch.js.map +1 -1
  29. package/components/Switch/types.d.ts +3 -0
  30. package/components/index.umd.min.js.map +1 -1
  31. package/custom-elements.json +26391 -0
  32. package/index.umd.min.js.map +1 -1
  33. package/package.json +5 -3
  34. package/react/components/ComboBox/sgds-combo-box.cjs.js +1 -0
  35. package/react/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
  36. package/react/components/ComboBox/sgds-combo-box.js +1 -0
  37. package/react/components/ComboBox/sgds-combo-box.js.map +1 -1
  38. package/react/components/FileUpload/sgds-file-upload.cjs.js +1 -0
  39. package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
  40. package/react/components/FileUpload/sgds-file-upload.js +1 -0
  41. package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
  42. package/react/components/Pagination/sgds-pagination.cjs.js +1 -0
  43. package/react/components/Pagination/sgds-pagination.cjs.js.map +1 -1
  44. package/react/components/Pagination/sgds-pagination.js +1 -0
  45. package/react/components/Pagination/sgds-pagination.js.map +1 -1
  46. package/react/components/Radio/sgds-radio-group.cjs.js +1 -0
  47. package/react/components/Radio/sgds-radio-group.cjs.js.map +1 -1
  48. package/react/components/Radio/sgds-radio-group.js +1 -0
  49. package/react/components/Radio/sgds-radio-group.js.map +1 -1
  50. package/react/components/Stepper/sgds-stepper.cjs.js.map +1 -1
  51. package/react/components/Stepper/sgds-stepper.js.map +1 -1
  52. package/react/components/Switch/sgds-switch.cjs.js +1 -0
  53. package/react/components/Switch/sgds-switch.cjs.js.map +1 -1
  54. package/react/components/Switch/sgds-switch.js +1 -0
  55. package/react/components/Switch/sgds-switch.js.map +1 -1
  56. package/types/react.d.ts +1623 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-stepper.js","sources":["../../../../src/components/Stepper/sgds-stepper.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { watch } from \"../../utils/watch\";\nimport stepperStyle from \"./stepper.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nexport interface IStepMetaData {\n component: unknown;\n stepHeader: string;\n iconName?: string;\n}\n/**\n * @summary Steppers are used to inform users which step they are at in a form or a process\n *\n * @event sgds-next-step - Emitted right before the next step is reached. Event is fired when nextStep method is called.\n * @event sgds-previous-step - Emitted right before the previous step is reached. Event is fired when previousStep method is called.\n * @event sgds-last-step - Emitted right before the last step is reached. Event is fired when lastStep method is called.\n * @event sgds-first-step - Emitted on hide after animation has completed. Event is fired when firstStep method is called.\n * @event sgds-arrived - Emitted right after the activeStep has updated its state, when upcoming step has arrived. Call `getMethod()` on this event to get the current step's component.\n * @event sgds-reset - Emitted right before the step is reset to its defaultActiveStep. Event is fired when reset method is called.\n *\n */\nexport class SgdsStepper extends SgdsElement {\n static styles = [...SgdsElement.styles, stepperStyle];\n /** @internal */\n static dependencies = { \"sgds-icon\": SgdsIcon };\n /** The metadata of stepper, type `IStepMetaData`, that consist of `stepHeader: string`, `component:unknown`, `iconName:string`. `stepHeader` is the name of the step and `component` is the content that should appear at the each step. `component` is set to `unknown` to allow users to pass in their desired component based on the framework of choice. e.g. pass in your own react/angular/vue component or it can also be a text content.\n * It is required to populate this array to properly render the stepper. By default, stepper markers will render numbers. For icon stepper markers, pass the name of sgds icon via `iconName` key. `iconName` is optional.\n */\n @property({ type: Array })\n steps: IStepMetaData[] = [];\n\n /** The current state of active step. Defaults to 0 */\n @property({ type: Number, reflect: true })\n activeStep = 0;\n\n /** The orientation of stepper. By default, the stepper is of horizontal orientation */\n @property({ type: String, reflect: true }) orientation: StepperOrientation = \"horizontal\";\n\n /** When true, the stepper's steps will be clickable */\n @property({ type: Boolean, reflect: true }) clickable = false;\n\n /** @internal Gets or sets the default activeStep used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"activeStep\")\n defaultActiveStep = 0;\n\n /** By default, it returns the corresponding component of the current activeStep as defined in the steps metadata. To get other components, pass in your desired step number as the parameter*/\n public getComponent(step: number = this.activeStep) {\n return this.steps[step].component;\n }\n /** Moves the active step forward one step */\n public nextStep() {\n this.emit(\"sgds-next-step\");\n if (this.activeStep < this.steps.length - 1) {\n this.activeStep++;\n }\n }\n\n /** Moves the active step back one step */\n public previousStep() {\n this.emit(\"sgds-previous-step\");\n\n if (this.activeStep > 0) {\n this.activeStep--;\n }\n }\n\n /** Changes the active step to the last step */\n public lastStep() {\n this.emit(\"sgds-last-step\");\n if (this.activeStep !== this.steps.length - 1) {\n this.activeStep = this.steps.length - 1;\n }\n }\n\n /** Changes active step to the first step */\n public firstStep() {\n this.emit(\"sgds-first-step\");\n if (this.activeStep > 0) {\n this.activeStep = 0;\n }\n }\n\n /** Resets the Stepper to its initial active step state */\n public reset() {\n this.emit(\"sgds-reset\");\n this.activeStep = this.defaultActiveStep;\n }\n\n /**@internal */\n _onStepperItemClick(index: number) {\n //emit an event before moving to next step\n if (this.activeStep > index) {\n this.activeStep = index;\n }\n }\n\n /**@internal */\n @watch(\"activeStep\", { waitUntilFirstUpdate: true })\n _handleActiveStepChange() {\n this.emit(\"sgds-arrived\");\n }\n\n /**@internal */\n _handleKeyDown(event: KeyboardEvent, index: number) {\n if (event.key === \"Enter\") {\n this._onStepperItemClick(index);\n }\n }\n\n render() {\n return html`\n <div\n class=\"stepper ${classMap({\n [`${this.orientation}`]: this.orientation,\n clickable: this.clickable\n })}\"\n >\n ${this.steps.map(({ stepHeader: step, iconName }, index) => {\n return html`\n <div class=\"stepper-item-container\">\n <div\n class=\"stepper-item ${classMap({\n \"is-active\": this.activeStep === index,\n \"is-completed\": this.activeStep > index,\n \"is-clickable\": this.clickable && this.activeStep > index\n })}\"\n tabindex=${this.clickable && this.activeStep > index ? \"0\" : \"-1\"}\n aria-current=${this.activeStep === index ? \"step\" : \"false\"}\n aria-disabled=${this.activeStep <= index ? \"true\" : \"false\"}\n @click=\"${this.clickable ? () => this._onStepperItemClick(index) : null}\"\n @keydown=${this.clickable ? (e: KeyboardEvent) => this._handleKeyDown(e, index) : null}\n >\n <div class=\"stepper-marker\">\n ${iconName ? html`<sgds-icon name=${iconName} size=\"md\"></sgds-icon>` : index + 1}\n </div>\n <div class=\"stepper-detail\">${step}</div>\n </div>\n </div>\n `;\n })}\n </div>\n `;\n }\n}\n\nexport type StepperOrientation = \"horizontal\" | \"vertical\";\n\nexport default SgdsStepper;\n"],"names":["stepperStyle"],"mappings":";;;;;;;;;;;AAaA;;;;;;;;;;AAUG;AACG,MAAO,WAAY,SAAQ,WAAW,CAAA;AAA5C,IAAA,WAAA,GAAA;;AAIE;;AAEG;QAEH,IAAK,CAAA,KAAA,GAAoB,EAAE,CAAC;;QAI5B,IAAU,CAAA,UAAA,GAAG,CAAC,CAAC;;QAG4B,IAAW,CAAA,WAAA,GAAuB,YAAY,CAAC;;QAG9C,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;;QAI9D,IAAiB,CAAA,iBAAA,GAAG,CAAC,CAAC;KAoGvB;;AAjGQ,IAAA,YAAY,CAAC,IAAA,GAAe,IAAI,CAAC,UAAU,EAAA;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;KACnC;;IAEM,QAAQ,GAAA;AACb,QAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC5B,QAAA,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;KACF;;IAGM,YAAY,GAAA;AACjB,QAAA,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAEhC,QAAA,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE;YACvB,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;KACF;;IAGM,QAAQ,GAAA;AACb,QAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC5B,QAAA,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,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3B,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG4B,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAgD,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG9C,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI9D,UAAA,CAAA;IADC,YAAY,CAAC,YAAY,CAAC;AACL,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAuDtB,UAAA,CAAA;IADC,KAAK,CAAC,YAAY,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAGnD,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,yBAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"sgds-stepper.js","sources":["../../../../src/components/Stepper/sgds-stepper.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport { watch } from \"../../utils/watch\";\nimport stepperStyle from \"./stepper.css\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport { IStepMetaData } from \"./types\";\nexport type { IStepMetaData };\n/**\n * @summary Steppers are used to inform users which step they are at in a form or a process\n *\n * @event sgds-next-step - Emitted right before the next step is reached. Event is fired when nextStep method is called.\n * @event sgds-previous-step - Emitted right before the previous step is reached. Event is fired when previousStep method is called.\n * @event sgds-last-step - Emitted right before the last step is reached. Event is fired when lastStep method is called.\n * @event sgds-first-step - Emitted on hide after animation has completed. Event is fired when firstStep method is called.\n * @event sgds-arrived - Emitted right after the activeStep has updated its state, when upcoming step has arrived. Call `getMethod()` on this event to get the current step's component.\n * @event sgds-reset - Emitted right before the step is reset to its defaultActiveStep. Event is fired when reset method is called.\n *\n */\nexport class SgdsStepper extends SgdsElement {\n static styles = [...SgdsElement.styles, stepperStyle];\n /** @internal */\n static dependencies = { \"sgds-icon\": SgdsIcon };\n /** The metadata of stepper, type `IStepMetaData`, that consist of `stepHeader: string`, `component:unknown`, `iconName:string`. `stepHeader` is the name of the step and `component` is the content that should appear at the each step. `component` is set to `unknown` to allow users to pass in their desired component based on the framework of choice. e.g. pass in your own react/angular/vue component or it can also be a text content.\n * It is required to populate this array to properly render the stepper. By default, stepper markers will render numbers. For icon stepper markers, pass the name of sgds icon via `iconName` key. `iconName` is optional.\n */\n @property({ type: Array })\n steps: IStepMetaData[] = [];\n\n /** The current state of active step. Defaults to 0 */\n @property({ type: Number, reflect: true })\n activeStep = 0;\n\n /** The orientation of stepper. By default, the stepper is of horizontal orientation */\n @property({ type: String, reflect: true }) orientation: StepperOrientation = \"horizontal\";\n\n /** When true, the stepper's steps will be clickable */\n @property({ type: Boolean, reflect: true }) clickable = false;\n\n /** @internal Gets or sets the default activeStep used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"activeStep\")\n defaultActiveStep = 0;\n\n /** By default, it returns the corresponding component of the current activeStep as defined in the steps metadata. To get other components, pass in your desired step number as the parameter*/\n public getComponent(step: number = this.activeStep) {\n return this.steps[step].component;\n }\n /** Moves the active step forward one step */\n public nextStep() {\n this.emit(\"sgds-next-step\");\n if (this.activeStep < this.steps.length - 1) {\n this.activeStep++;\n }\n }\n\n /** Moves the active step back one step */\n public previousStep() {\n this.emit(\"sgds-previous-step\");\n\n if (this.activeStep > 0) {\n this.activeStep--;\n }\n }\n\n /** Changes the active step to the last step */\n public lastStep() {\n this.emit(\"sgds-last-step\");\n if (this.activeStep !== this.steps.length - 1) {\n this.activeStep = this.steps.length - 1;\n }\n }\n\n /** Changes active step to the first step */\n public firstStep() {\n this.emit(\"sgds-first-step\");\n if (this.activeStep > 0) {\n this.activeStep = 0;\n }\n }\n\n /** Resets the Stepper to its initial active step state */\n public reset() {\n this.emit(\"sgds-reset\");\n this.activeStep = this.defaultActiveStep;\n }\n\n /**@internal */\n _onStepperItemClick(index: number) {\n //emit an event before moving to next step\n if (this.activeStep > index) {\n this.activeStep = index;\n }\n }\n\n /**@internal */\n @watch(\"activeStep\", { waitUntilFirstUpdate: true })\n _handleActiveStepChange() {\n this.emit(\"sgds-arrived\");\n }\n\n /**@internal */\n _handleKeyDown(event: KeyboardEvent, index: number) {\n if (event.key === \"Enter\") {\n this._onStepperItemClick(index);\n }\n }\n\n render() {\n return html`\n <div\n class=\"stepper ${classMap({\n [`${this.orientation}`]: this.orientation,\n clickable: this.clickable\n })}\"\n >\n ${this.steps.map(({ stepHeader: step, iconName }, index) => {\n return html`\n <div class=\"stepper-item-container\">\n <div\n class=\"stepper-item ${classMap({\n \"is-active\": this.activeStep === index,\n \"is-completed\": this.activeStep > index,\n \"is-clickable\": this.clickable && this.activeStep > index\n })}\"\n tabindex=${this.clickable && this.activeStep > index ? \"0\" : \"-1\"}\n aria-current=${this.activeStep === index ? \"step\" : \"false\"}\n aria-disabled=${this.activeStep <= index ? \"true\" : \"false\"}\n @click=\"${this.clickable ? () => this._onStepperItemClick(index) : null}\"\n @keydown=${this.clickable ? (e: KeyboardEvent) => this._handleKeyDown(e, index) : null}\n >\n <div class=\"stepper-marker\">\n ${iconName ? html`<sgds-icon name=${iconName} size=\"md\"></sgds-icon>` : index + 1}\n </div>\n <div class=\"stepper-detail\">${step}</div>\n </div>\n </div>\n `;\n })}\n </div>\n `;\n }\n}\n\nexport type StepperOrientation = \"horizontal\" | \"vertical\";\n\nexport default SgdsStepper;\n"],"names":["stepperStyle"],"mappings":";;;;;;;;;;;AAUA;;;;;;;;;;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AAI,EAAE,CAAC;AAAgD,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG9C,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI9D,UAAA,CAAA;IADC,YAAY,CAAC,YAAY,CAAC;AACL,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAuDtB,UAAA,CAAA;IADC,KAAK,CAAC,YAAY,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAGnD,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,yBAAA,EAAA,IAAA,CAAA;;;;"}
@@ -22,6 +22,7 @@ var _switch = require('./switch.cjs.js');
22
22
  * @slot leftLabel - The label on the left side of the switch
23
23
  *
24
24
  * @event sgds-change - Emitted when the checked state changes.
25
+ * @eventDetail {ISgdsSwitchChangeEventDetail} sgds-change
25
26
  *
26
27
  */
27
28
  class SgdsSwitch extends sgdsElement["default"] {
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-switch.cjs.js","sources":["../../../../src/components/Switch/sgds-switch.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport formLabelStyles from \"../../styles/form-label.css\";\nimport switchStyle from \"./switch.css\";\n\n/**\n * @summary Switch component is used to toggle on and off or yes or no action.\n *\n * @slot default - The default label of switch on the right side of the switch\n * @slot leftLabel - The label on the left side of the switch\n *\n * @event sgds-change - Emitted when the checked state changes.\n *\n */\nexport class SgdsSwitch extends SgdsElement {\n static styles = [...SgdsElement.styles, formLabelStyles, switchStyle];\n\n /** The size of the switch. By default, it is small size */\n @property({ reflect: true, type: String }) size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\n /** When enabled, icon appears in the switch */\n @property({ reflect: true, type: Boolean }) icon = false;\n\n /** Draws the switch in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** Disables the switch (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Used only for SSR to indicate the presence of the `default` slot. */\n @property({ type: Boolean }) hasDefaultSlot = false;\n\n /** Used only for SSR to indicate the presence of the `leftLabel` slot. */\n @property({ type: Boolean }) hasLeftLabelSlot = false;\n\n /** @internal Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"checked\")\n defaultChecked = false;\n\n /**@internal */\n @query('input[type=\"checkbox\"]') input: HTMLInputElement;\n\n /** @internal */\n private readonly hasSlotController = new HasSlotController(this, \"[default]\", \"leftLabel\");\n\n updated() {\n if (!this.hasDefaultSlot) this.hasDefaultSlot = this.hasSlotController.test(\"[default]\");\n if (!this.hasLeftLabelSlot) this.hasLeftLabelSlot = this.hasSlotController.test(\"leftLabel\");\n }\n\n /** Simulates a click on the switch. */\n public click() {\n this.input.click();\n }\n /** Sets focus on the switch. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the switch. */\n public blur() {\n this.input.blur();\n }\n\n private _handleChange() {\n this.checked = !this.checked;\n this.emit(\"sgds-change\", { detail: { checked: this.checked } });\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.click();\n }\n }\n\n /** @internal For Id/For pair of the HTML form control and label. */\n private _inputId = genId(\"switch\");\n\n /** @internal */\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.input.disabled = this.disabled;\n }\n\n render() {\n const noLabel = !this.hasDefaultSlot && !this.hasLeftLabelSlot;\n\n return html`\n <div class=\"form-check\">\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"left-label\": true,\n \"d-none\": this.hasDefaultSlot || noLabel\n })}\n >\n <slot name=\"leftLabel\"></slot>\n </label>\n <input\n class=${classMap({\n \"form-check-input\": true\n })}\n type=\"checkbox\"\n id=${this._inputId}\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-checked=${this.checked ? \"true\" : \"false\"}\n @change=${this._handleChange}\n @keydown=${this._handleKeyDown}\n />\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"d-none\": this.hasLeftLabelSlot || noLabel\n })}\n >\n <slot></slot>\n </label>\n </div>\n `;\n }\n}\n\nexport default SgdsSwitch;\n"],"names":["SgdsElement","HasSlotController","genId","html","classMap","formLabelStyles","switchStyle","__decorate","property","defaultValue","query","watch"],"mappings":";;;;;;;;;;;;;;;;;AAWA;;;;;;;;AAQG;AACG,MAAO,UAAW,SAAQA,sBAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;;QAI6C,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAG/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;;QAGhB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGhC,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAGvB,IAAgB,CAAA,gBAAA,GAAG,KAAK,CAAC;;QAItD,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAMN,IAAiB,CAAA,iBAAA,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC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,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAIjD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,uBAAA,EAAA,IAAA,CAAA;;;;;"}
1
+ {"version":3,"file":"sgds-switch.cjs.js","sources":["../../../../src/components/Switch/sgds-switch.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport formLabelStyles from \"../../styles/form-label.css\";\nimport switchStyle from \"./switch.css\";\nimport type { ISgdsSwitchChangeEventDetail } from \"./types\";\nexport type { ISgdsSwitchChangeEventDetail };\n\n/**\n * @summary Switch component is used to toggle on and off or yes or no action.\n *\n * @slot default - The default label of switch on the right side of the switch\n * @slot leftLabel - The label on the left side of the switch\n *\n * @event sgds-change - Emitted when the checked state changes.\n * @eventDetail {ISgdsSwitchChangeEventDetail} sgds-change\n *\n */\nexport class SgdsSwitch extends SgdsElement {\n static styles = [...SgdsElement.styles, formLabelStyles, switchStyle];\n\n /** The size of the switch. By default, it is small size */\n @property({ reflect: true, type: String }) size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\n /** When enabled, icon appears in the switch */\n @property({ reflect: true, type: Boolean }) icon = false;\n\n /** Draws the switch in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** Disables the switch (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Used only for SSR to indicate the presence of the `default` slot. */\n @property({ type: Boolean }) hasDefaultSlot = false;\n\n /** Used only for SSR to indicate the presence of the `leftLabel` slot. */\n @property({ type: Boolean }) hasLeftLabelSlot = false;\n\n /** @internal Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"checked\")\n defaultChecked = false;\n\n /**@internal */\n @query('input[type=\"checkbox\"]') input: HTMLInputElement;\n\n /** @internal */\n private readonly hasSlotController = new HasSlotController(this, \"[default]\", \"leftLabel\");\n\n updated() {\n if (!this.hasDefaultSlot) this.hasDefaultSlot = this.hasSlotController.test(\"[default]\");\n if (!this.hasLeftLabelSlot) this.hasLeftLabelSlot = this.hasSlotController.test(\"leftLabel\");\n }\n\n /** Simulates a click on the switch. */\n public click() {\n this.input.click();\n }\n /** Sets focus on the switch. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the switch. */\n public blur() {\n this.input.blur();\n }\n\n private _handleChange() {\n this.checked = !this.checked;\n this.emit<ISgdsSwitchChangeEventDetail>(\"sgds-change\", { detail: { checked: this.checked } });\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.click();\n }\n }\n\n /** @internal For Id/For pair of the HTML form control and label. */\n private _inputId = genId(\"switch\");\n\n /** @internal */\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.input.disabled = this.disabled;\n }\n\n render() {\n const noLabel = !this.hasDefaultSlot && !this.hasLeftLabelSlot;\n\n return html`\n <div class=\"form-check\">\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"left-label\": true,\n \"d-none\": this.hasDefaultSlot || noLabel\n })}\n >\n <slot name=\"leftLabel\"></slot>\n </label>\n <input\n class=${classMap({\n \"form-check-input\": true\n })}\n type=\"checkbox\"\n id=${this._inputId}\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-checked=${this.checked ? \"true\" : \"false\"}\n @change=${this._handleChange}\n @keydown=${this._handleKeyDown}\n />\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"d-none\": this.hasLeftLabelSlot || noLabel\n })}\n >\n <slot></slot>\n </label>\n </div>\n `;\n }\n}\n\nexport default SgdsSwitch;\n"],"names":["SgdsElement","HasSlotController","genId","html","classMap","formLabelStyles","switchStyle","__decorate","property","defaultValue","query","watch"],"mappings":";;;;;;;;;;;;;;;;;AAaA;;;;;;;;;AASG;AACG,MAAO,UAAW,SAAQA,sBAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;;QAI6C,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAG/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;;QAGhB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGhC,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAGvB,IAAgB,CAAA,gBAAA,GAAG,KAAK,CAAC;;QAItD,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAMN,IAAiB,CAAA,iBAAA,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;;AAkCnF,QAAA,IAAA,CAAA,QAAQ,GAAGC,qBAAK,CAAC,QAAQ,CAAC,CAAC;KAiDpC;IAjFC,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzF,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC9F;;IAGM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;KACpB;;AAEM,IAAA,KAAK,CAAC,OAAsB,EAAA;AACjC,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAA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EAAA,UAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGhCD,gBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAwB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGvBD,gBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAA0B,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAItDD,gBAAA,CAAA;IADCE,yBAAY,CAAC,SAAS,CAAC;AACD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGUF,gBAAA,CAAA;IAAhCG,mBAAK,CAAC,wBAAwB,CAAC;AAAyB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAyCzDH,gBAAA,CAAA;IADCI,WAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAIjD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,uBAAA,EAAA,IAAA,CAAA;;;;;"}
@@ -18,6 +18,7 @@ import css_248z$1 from './switch.js';
18
18
  * @slot leftLabel - The label on the left side of the switch
19
19
  *
20
20
  * @event sgds-change - Emitted when the checked state changes.
21
+ * @eventDetail {ISgdsSwitchChangeEventDetail} sgds-change
21
22
  *
22
23
  */
23
24
  class SgdsSwitch extends SgdsElement {
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-switch.js","sources":["../../../../src/components/Switch/sgds-switch.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport formLabelStyles from \"../../styles/form-label.css\";\nimport switchStyle from \"./switch.css\";\n\n/**\n * @summary Switch component is used to toggle on and off or yes or no action.\n *\n * @slot default - The default label of switch on the right side of the switch\n * @slot leftLabel - The label on the left side of the switch\n *\n * @event sgds-change - Emitted when the checked state changes.\n *\n */\nexport class SgdsSwitch extends SgdsElement {\n static styles = [...SgdsElement.styles, formLabelStyles, switchStyle];\n\n /** The size of the switch. By default, it is small size */\n @property({ reflect: true, type: String }) size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\n /** When enabled, icon appears in the switch */\n @property({ reflect: true, type: Boolean }) icon = false;\n\n /** Draws the switch in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** Disables the switch (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Used only for SSR to indicate the presence of the `default` slot. */\n @property({ type: Boolean }) hasDefaultSlot = false;\n\n /** Used only for SSR to indicate the presence of the `leftLabel` slot. */\n @property({ type: Boolean }) hasLeftLabelSlot = false;\n\n /** @internal Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"checked\")\n defaultChecked = false;\n\n /**@internal */\n @query('input[type=\"checkbox\"]') input: HTMLInputElement;\n\n /** @internal */\n private readonly hasSlotController = new HasSlotController(this, \"[default]\", \"leftLabel\");\n\n updated() {\n if (!this.hasDefaultSlot) this.hasDefaultSlot = this.hasSlotController.test(\"[default]\");\n if (!this.hasLeftLabelSlot) this.hasLeftLabelSlot = this.hasSlotController.test(\"leftLabel\");\n }\n\n /** Simulates a click on the switch. */\n public click() {\n this.input.click();\n }\n /** Sets focus on the switch. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the switch. */\n public blur() {\n this.input.blur();\n }\n\n private _handleChange() {\n this.checked = !this.checked;\n this.emit(\"sgds-change\", { detail: { checked: this.checked } });\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.click();\n }\n }\n\n /** @internal For Id/For pair of the HTML form control and label. */\n private _inputId = genId(\"switch\");\n\n /** @internal */\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.input.disabled = this.disabled;\n }\n\n render() {\n const noLabel = !this.hasDefaultSlot && !this.hasLeftLabelSlot;\n\n return html`\n <div class=\"form-check\">\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"left-label\": true,\n \"d-none\": this.hasDefaultSlot || noLabel\n })}\n >\n <slot name=\"leftLabel\"></slot>\n </label>\n <input\n class=${classMap({\n \"form-check-input\": true\n })}\n type=\"checkbox\"\n id=${this._inputId}\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-checked=${this.checked ? \"true\" : \"false\"}\n @change=${this._handleChange}\n @keydown=${this._handleKeyDown}\n />\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"d-none\": this.hasLeftLabelSlot || noLabel\n })}\n >\n <slot></slot>\n </label>\n </div>\n `;\n }\n}\n\nexport default SgdsSwitch;\n"],"names":["formLabelStyles","switchStyle"],"mappings":";;;;;;;;;;;;;AAWA;;;;;;;;AAQG;AACG,MAAO,UAAW,SAAQ,WAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;;QAI6C,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAG/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;;QAGhB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGhC,IAAc,CAAA,cA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KAAK,CAAC,wBAAwB,CAAC;AAAyB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAyCzD,UAAA,CAAA;IADC,KAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAIjD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,uBAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"sgds-switch.js","sources":["../../../../src/components/Switch/sgds-switch.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { defaultValue } from \"../../utils/defaultvalue\";\nimport genId from \"../../utils/generateId\";\nimport { watch } from \"../../utils/watch\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport formLabelStyles from \"../../styles/form-label.css\";\nimport switchStyle from \"./switch.css\";\nimport type { ISgdsSwitchChangeEventDetail } from \"./types\";\nexport type { ISgdsSwitchChangeEventDetail };\n\n/**\n * @summary Switch component is used to toggle on and off or yes or no action.\n *\n * @slot default - The default label of switch on the right side of the switch\n * @slot leftLabel - The label on the left side of the switch\n *\n * @event sgds-change - Emitted when the checked state changes.\n * @eventDetail {ISgdsSwitchChangeEventDetail} sgds-change\n *\n */\nexport class SgdsSwitch extends SgdsElement {\n static styles = [...SgdsElement.styles, formLabelStyles, switchStyle];\n\n /** The size of the switch. By default, it is small size */\n @property({ reflect: true, type: String }) size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\n /** When enabled, icon appears in the switch */\n @property({ reflect: true, type: Boolean }) icon = false;\n\n /** Draws the switch in a checked state. */\n @property({ type: Boolean, reflect: true }) checked = false;\n\n /** Disables the switch (so the user can't check / uncheck it). */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Used only for SSR to indicate the presence of the `default` slot. */\n @property({ type: Boolean }) hasDefaultSlot = false;\n\n /** Used only for SSR to indicate the presence of the `leftLabel` slot. */\n @property({ type: Boolean }) hasLeftLabelSlot = false;\n\n /** @internal Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */\n @defaultValue(\"checked\")\n defaultChecked = false;\n\n /**@internal */\n @query('input[type=\"checkbox\"]') input: HTMLInputElement;\n\n /** @internal */\n private readonly hasSlotController = new HasSlotController(this, \"[default]\", \"leftLabel\");\n\n updated() {\n if (!this.hasDefaultSlot) this.hasDefaultSlot = this.hasSlotController.test(\"[default]\");\n if (!this.hasLeftLabelSlot) this.hasLeftLabelSlot = this.hasSlotController.test(\"leftLabel\");\n }\n\n /** Simulates a click on the switch. */\n public click() {\n this.input.click();\n }\n /** Sets focus on the switch. */\n public focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the switch. */\n public blur() {\n this.input.blur();\n }\n\n private _handleChange() {\n this.checked = !this.checked;\n this.emit<ISgdsSwitchChangeEventDetail>(\"sgds-change\", { detail: { checked: this.checked } });\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n if (event.key === \"Enter\" && !hasModifier) {\n this.click();\n }\n }\n\n /** @internal For Id/For pair of the HTML form control and label. */\n private _inputId = genId(\"switch\");\n\n /** @internal */\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabledChange() {\n // Disabled form controls are always valid, so we need to recheck validity when the state changes\n this.input.disabled = this.disabled;\n }\n\n render() {\n const noLabel = !this.hasDefaultSlot && !this.hasLeftLabelSlot;\n\n return html`\n <div class=\"form-check\">\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"left-label\": true,\n \"d-none\": this.hasDefaultSlot || noLabel\n })}\n >\n <slot name=\"leftLabel\"></slot>\n </label>\n <input\n class=${classMap({\n \"form-check-input\": true\n })}\n type=\"checkbox\"\n id=${this._inputId}\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-checked=${this.checked ? \"true\" : \"false\"}\n @change=${this._handleChange}\n @keydown=${this._handleKeyDown}\n />\n <label\n for=\"${this._inputId}\"\n class=${classMap({\n \"form-check-label\": true,\n \"d-none\": this.hasLeftLabelSlot || noLabel\n })}\n >\n <slot></slot>\n </label>\n </div>\n `;\n }\n}\n\nexport default SgdsSwitch;\n"],"names":["formLabelStyles","switchStyle"],"mappings":";;;;;;;;;;;;;AAaA;;;;;;;;;AASG;AACG,MAAO,UAAW,SAAQ,WAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;;QAI6C,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAG/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;;QAGhB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGhC,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAGvB,IAAgB,CAAA,gBAAA,GAAG,KAAK,CAAC;;QAItD,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAMN,IAAiB,CAAA,iBAAA,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;;AAkCnF,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;KAiDpC;IAjFC,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzF,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC9F;;IAGM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;KACpB;;AAEM,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