ng-cw-v12
Version:
Angular UI component library
145 lines (136 loc) • 14.1 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms')) :
typeof define === 'function' && define.amd ? define('ng-cw-v12/emoji-switch', ['exports', '@angular/core', '@angular/common', '@angular/forms'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["ng-cw-v12"] = global["ng-cw-v12"] || {}, global["ng-cw-v12"]["emoji-switch"] = {}), global.ng.core, global.ng.common, global.ng.forms));
})(this, (function (exports, i0, i1, i2) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
var EmojiSwitchComponent = /** @class */ (function () {
function EmojiSwitchComponent(cd) {
this.cd = cd;
this.ncSize = 'default';
this.disabledMode = false;
this.innerValue = false;
this.onChangeCallback = function () { };
this.onTouchedCallback = function () { };
}
Object.defineProperty(EmojiSwitchComponent.prototype, "ncDisabled", {
set: function (value) {
this.disabledMode = value !== null && value !== undefined && value !== false && value !== 'false';
},
enumerable: false,
configurable: true
});
Object.defineProperty(EmojiSwitchComponent.prototype, "value", {
get: function () {
return this.innerValue;
},
set: function (v) {
if (v !== this.innerValue) {
this.innerValue = v;
this.onChangeCallback(v);
}
},
enumerable: false,
configurable: true
});
// 从模型写入值到视图
EmojiSwitchComponent.prototype.writeValue = function (value) {
if (value !== this.innerValue) {
this.innerValue = value;
this.cd.markForCheck();
}
};
// 注册 onChange 事件
EmojiSwitchComponent.prototype.registerOnChange = function (fn) {
this.onChangeCallback = fn;
};
// 注册 onTouched 事件
EmojiSwitchComponent.prototype.registerOnTouched = function (fn) {
this.onTouchedCallback = fn;
};
EmojiSwitchComponent.prototype.onInputChange = function (event) {
this.value = event;
};
return EmojiSwitchComponent;
}());
EmojiSwitchComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: EmojiSwitchComponent, deps: [{ token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
EmojiSwitchComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: EmojiSwitchComponent, selector: "nc-emoji-switch", inputs: { ncDisabled: "ncDisabled", ncSize: "ncSize" }, providers: [
{
provide: i2.NG_VALUE_ACCESSOR,
useExisting: i0.forwardRef(function () { return EmojiSwitchComponent; }),
multi: true
}
], ngImport: i0__namespace, template: "<div class=\"nc-emoji-switch\" [ngClass]=\"'nc-emoji-switch-' + ncSize\">\r\n <div class=\"switch-disabled\" *ngIf=\"disabledMode\"></div>\r\n <span class=\"switch__wrapper\">\r\n <input class=\"switch__input\" type=\"checkbox\" [ngModel]=\"value\" (ngModelChange)=\"onInputChange($event)\"/>\r\n <span class=\"switch__emoji\">\r\n <span class=\"switch__emoji-face switch__emoji-face--sad\">\r\n <span class=\"switch__emoji-eye\"></span>\r\n <span class=\"switch__emoji-eye\"></span>\r\n <span class=\"switch__emoji-mouth\"></span>\r\n </span>\r\n <span class=\"switch__emoji-face\">\r\n <span class=\"switch__emoji-eye\"></span>\r\n <span class=\"switch__emoji-eye\"></span>\r\n <span class=\"switch__emoji-mouth\"></span>\r\n </span>\r\n </span>\r\n </span>\r\n</div>", styles: [".nc-emoji-switch-default{font-size:16px}.nc-emoji-switch-small{font-size:14px}.nc-emoji-switch-large{font-size:18px}.nc-emoji-switch{position:relative;width:-moz-fit-content;width:fit-content;display:flex;--hue: 223;--bg: hsl(var(--hue), 10%, 90%);--fg: hsl(var(--hue), 10%, 10%);--trans-dur: .5s;--trans-timing1: cubic-bezier(.65, 0, .35, 1);--trans-timing2: cubic-bezier(.65, 0, .35, 1.5)}.nc-emoji-switch .switch-disabled{position:absolute;top:0;left:0;right:0;bottom:0;cursor:not-allowed;-webkit-user-select:none;user-select:none;background-color:#f0f0f0;color:#888;opacity:.6;z-index:1;border-radius:.75em}.nc-emoji-switch .switch__wrapper{display:block;position:relative}.nc-emoji-switch .switch__wrapper input{box-sizing:border-box;margin:0;padding:0;border:0;color:var(--fg);font:1em/1.5 sans-serif;transition:background-color var(--trans-dur) var(--trans-timing1),color var(--trans-dur) var(--trans-timing1)}.nc-emoji-switch .switch__wrapper .switch__input{-webkit-tap-highlight-color:transparent}.nc-emoji-switch .switch__wrapper .switch__input{background-color:hsl(var(--hue),10%,80%);border-radius:.75em;box-shadow:.0625em .0625em .0625em #e3e4e8 inset,-.0625em -.0625em .0625em hsl(var(--hue),10%,80%) inset,0 0 0 .125em hsl(var(--hue),10%,90%) inset,.25em .25em .125em #0000004d inset,.0625em .0625em .0625em #0000004d;cursor:pointer;display:block;width:2.5em;height:1.5em;-webkit-appearance:none;appearance:none;transition:background-color var(--trans-dur) var(--trans-timing1),box-shadow var(--trans-dur) var(--trans-timing1)}.nc-emoji-switch .switch__wrapper .switch__input:checked{background-color:#0ac213}.nc-emoji-switch .switch__wrapper .switch__input:checked+.switch__emoji{transform:translate(100%)}.nc-emoji-switch .switch__wrapper [dir=rtl] .switch__input:checked+.switch__emoji{transform:translate(-100%)}.nc-emoji-switch .switch__wrapper .switch__input:checked+.switch__emoji .switch__emoji-face{transform:rotateY(179.99deg)}.nc-emoji-switch .switch__wrapper [dir=rtl] .switch__input:checked+.switch__emoji .switch__emoji-face{transform:rotateY(-179.99deg)}.nc-emoji-switch .switch__wrapper .switch__input:checked+.switch__emoji .switch__emoji-face+.switch__emoji-face{transform:rotateY(0)}.nc-emoji-switch .switch__wrapper [dir=rtl] .switch__input:checked+.switch__emoji .switch__emoji-face+.switch__emoji-face{transform:rotateY(-360deg)}.nc-emoji-switch .switch__wrapper .switch__emoji{box-shadow:.25em .25em .125em #0000004d;overflow:hidden;pointer-events:none;top:.25em;left:.25em;width:1em;height:1em}.nc-emoji-switch .switch__wrapper [dir=rtl] .switch__emoji{right:.25em;left:auto}.nc-emoji-switch .switch__wrapper .switch__emoji,.nc-emoji-switch .switch__wrapper .switch__emoji:before,.nc-emoji-switch .switch__wrapper .switch__emoji:after,.nc-emoji-switch .switch__wrapper .switch__emoji-eye,.nc-emoji-switch .switch__wrapper .switch__emoji-mouth,.nc-emoji-switch .switch__wrapper .switch__emoji-face{display:block;position:absolute}.nc-emoji-switch .switch__wrapper .switch__emoji,.nc-emoji-switch .switch__wrapper .switch__emoji:before,.nc-emoji-switch .switch__wrapper .switch__emoji:after,.nc-emoji-switch .switch__wrapper .switch__emoji-eye,.nc-emoji-switch .switch__wrapper .switch__emoji-mouth{border-radius:50%}.nc-emoji-switch .switch__wrapper .switch__emoji:before,.nc-emoji-switch .switch__wrapper .switch__emoji:after{content:\"\";width:100%;height:100%;transform:translateZ(0)}.nc-emoji-switch .switch__wrapper .switch__emoji:before{background-color:#f2c40d;box-shadow:-.25em -.25em .25em #c29d0a inset,.1875em .1875em .25em #f9e286 inset}.nc-emoji-switch .switch__wrapper .switch__emoji:after{box-shadow:0 0 .125em .0625em #f5d03d80 inset}.nc-emoji-switch .switch__wrapper .switch__emoji,.nc-emoji-switch .switch__wrapper .switch__emoji-face{transform-style:preserve-3d;transition:transform var(--trans-dur) var(--trans-timing2)}.nc-emoji-switch .switch__wrapper .switch__emoji-eye,.nc-emoji-switch .switch__wrapper .switch__emoji-mouth{-webkit-backface-visibility:hidden;backface-visibility:hidden}.nc-emoji-switch .switch__wrapper .switch__emoji-eye{border:.0625em solid hsl(var(--hue),10%,10%);border-right-color:transparent;border-bottom-color:transparent;border-radius:50%;top:50%;left:50%;width:.25em;height:.25em;transform:translate(-50%,-50%) rotateY(-22.5deg) translateZ(.5em) rotate(45deg)}.nc-emoji-switch .switch__wrapper .switch__emoji-eye+.switch__emoji-eye{transform:translate(-50%,-50%) rotateY(22.5deg) translateZ(.5em) rotate(45deg)}.nc-emoji-switch .switch__wrapper .switch__emoji-mouth{background-image:radial-gradient(100% 100% at 50% 100%,#f2180d 20%,#f5463d 33%,rgba(245,70,61,0) 35%),radial-gradient(100% 100% at 75% 113%,black 26%,rgba(0,0,0,0) 35%),linear-gradient(rgba(0,0,0,0) 50%,black 50% 55%,hsl(var(--hue),10%,10%) 65%);top:50%;left:50%;width:.5em;height:.5em;transform:translate(-50%,-50%) rotateX(-15deg) translateZ(.5em)}.nc-emoji-switch .switch__wrapper .switch__emoji-face{top:0;left:0;width:100%;height:100%;transform:rotateY(0)}.nc-emoji-switch .switch__wrapper .switch__emoji-face+.switch__emoji-face{transform:rotateY(-180deg)}.nc-emoji-switch .switch__wrapper .switch__emoji-face--sad .switch__emoji-eye{background-color:hsl(var(--hue),10%,10%);border:0;width:.1875em;height:.1875em}.nc-emoji-switch .switch__wrapper .switch__emoji-face--sad .switch__emoji-mouth{background-image:none;border:.0625em solid transparent;border-top-color:hsl(var(--hue),10%,10%);transform:translate(-50%) rotateX(-20deg) translateZ(.5em)}\n"], directives: [{ type: i1__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i2__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: EmojiSwitchComponent, decorators: [{
type: i0.Component,
args: [{
selector: 'nc-emoji-switch',
templateUrl: './emoji-switch.component.html',
styleUrls: ['./emoji-switch.component.less'],
providers: [
{
provide: i2.NG_VALUE_ACCESSOR,
useExisting: i0.forwardRef(function () { return EmojiSwitchComponent; }),
multi: true
}
]
}]
}], ctorParameters: function () { return [{ type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { ncDisabled: [{
type: i0.Input
}], ncSize: [{
type: i0.Input
}] } });
var NcEmojiSwitchModule = /** @class */ (function () {
function NcEmojiSwitchModule() {
}
return NcEmojiSwitchModule;
}());
NcEmojiSwitchModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcEmojiSwitchModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
NcEmojiSwitchModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcEmojiSwitchModule, declarations: [EmojiSwitchComponent], imports: [i1.CommonModule,
i2.FormsModule], exports: [EmojiSwitchComponent] });
NcEmojiSwitchModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcEmojiSwitchModule, imports: [[
i1.CommonModule,
i2.FormsModule
]] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcEmojiSwitchModule, decorators: [{
type: i0.NgModule,
args: [{
declarations: [
EmojiSwitchComponent
],
imports: [
i1.CommonModule,
i2.FormsModule
],
exports: [
EmojiSwitchComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
exports.EmojiSwitchComponent = EmojiSwitchComponent;
exports.NcEmojiSwitchModule = NcEmojiSwitchModule;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=ng-cw-v12-emoji-switch.umd.js.map