200 lines
11 KiB
JavaScript
200 lines
11 KiB
JavaScript
import { Directive, Input, NgModule } from '@angular/core';
|
|
import { NzTypographyModule } from 'ng-zorro-antd/typography';
|
|
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
var __typeError = (msg) => {
|
|
throw TypeError(msg);
|
|
};
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
var __decoratorStart = (base) => [, , , __create(null)];
|
|
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
var __runInitializers = (array, flags, self, value) => {
|
|
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
return value;
|
|
};
|
|
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
return __privateGet(this, extra);
|
|
}, set [name](x) {
|
|
return __privateSet(this, extra, x);
|
|
} }, name));
|
|
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
if (k) {
|
|
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
}
|
|
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
}
|
|
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
};
|
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
|
|
// src/core/classnames.ts
|
|
var BASE_CLASS = "tach-typography";
|
|
var join = (...parts) => parts.filter(Boolean).join(" ");
|
|
var tachTypographyClassName = ({
|
|
variant = "Body",
|
|
color = "primary",
|
|
weight = "normal",
|
|
clickable = false,
|
|
className
|
|
} = {}) => {
|
|
return join(
|
|
BASE_CLASS,
|
|
`${BASE_CLASS}--${variant}`,
|
|
`${BASE_CLASS}--color-${color}`,
|
|
weight === "bold" && `${BASE_CLASS}--bold`,
|
|
clickable && `${BASE_CLASS}--pointer`,
|
|
className
|
|
);
|
|
};
|
|
var tachTypographyClassList = (options = {}) => {
|
|
return tachTypographyClassName(options).split(" ").filter(Boolean);
|
|
};
|
|
|
|
// src/core/ellipsis.ts
|
|
var tachTypographyEllipsisStyle = (ellipsis) => {
|
|
if (!ellipsis) {
|
|
return void 0;
|
|
}
|
|
const rows = typeof ellipsis === "object" ? ellipsis.rows ?? 1 : 1;
|
|
return {
|
|
overflow: "hidden",
|
|
textOverflow: "ellipsis",
|
|
display: "-webkit-box",
|
|
WebkitBoxOrient: "vertical",
|
|
WebkitLineClamp: rows
|
|
};
|
|
};
|
|
|
|
// src/angular/index.ts
|
|
var camelToKebab = (value) => value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
var toCssProperty = (styleKey) => {
|
|
if (styleKey.startsWith("Webkit")) {
|
|
return `-webkit-${camelToKebab(styleKey.slice(6))}`;
|
|
}
|
|
return camelToKebab(styleKey);
|
|
};
|
|
var tachAngularTypographyClassName = (options = {}) => {
|
|
return tachTypographyClassName(options);
|
|
};
|
|
var tachAngularTypographyClassList = (options = {}) => {
|
|
return tachTypographyClassList(options);
|
|
};
|
|
var tachAngularTypographyStyles = (ellipsis, preserveStyle = {}) => {
|
|
const ellipsisStyle = tachTypographyEllipsisStyle(ellipsis);
|
|
if (!ellipsisStyle) {
|
|
return preserveStyle;
|
|
}
|
|
return {
|
|
...ellipsisStyle,
|
|
...preserveStyle
|
|
};
|
|
};
|
|
var _tachTypographyEllipsis_dec, _tachTypographyClassName_dec, _tachTypographyClickable_dec, _tachTypographyWeight_dec, _tachTypographyColor_dec, _tachTypographyVariant_dec, _tachTypography_dec, _TachTypographyDirective_decorators, _init;
|
|
_TachTypographyDirective_decorators = [Directive({
|
|
selector: "[tachTypography]",
|
|
standalone: true
|
|
})], _tachTypography_dec = [Input()], _tachTypographyVariant_dec = [Input()], _tachTypographyColor_dec = [Input()], _tachTypographyWeight_dec = [Input()], _tachTypographyClickable_dec = [Input()], _tachTypographyClassName_dec = [Input()], _tachTypographyEllipsis_dec = [Input()];
|
|
var TachTypographyDirective = class {
|
|
constructor(elementRef, renderer) {
|
|
this.elementRef = elementRef;
|
|
this.renderer = renderer;
|
|
__publicField(this, "tachTypography", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
__publicField(this, "tachTypographyVariant", __runInitializers(_init, 12, this, "Body")), __runInitializers(_init, 15, this);
|
|
__publicField(this, "tachTypographyColor", __runInitializers(_init, 16, this, "primary")), __runInitializers(_init, 19, this);
|
|
__publicField(this, "tachTypographyWeight", __runInitializers(_init, 20, this, "normal")), __runInitializers(_init, 23, this);
|
|
__publicField(this, "tachTypographyClickable", __runInitializers(_init, 24, this, false)), __runInitializers(_init, 27, this);
|
|
__publicField(this, "tachTypographyClassName", __runInitializers(_init, 28, this)), __runInitializers(_init, 31, this);
|
|
__publicField(this, "tachTypographyEllipsis", __runInitializers(_init, 32, this)), __runInitializers(_init, 35, this);
|
|
__publicField(this, "appliedClasses", /* @__PURE__ */ new Set());
|
|
__publicField(this, "appliedStyleProperties", /* @__PURE__ */ new Set());
|
|
}
|
|
ngOnChanges(_changes) {
|
|
this.syncClasses();
|
|
this.syncEllipsisStyles();
|
|
}
|
|
syncClasses() {
|
|
const nextClassList = tachTypographyClassList({
|
|
variant: this.tachTypography || this.tachTypographyVariant,
|
|
color: this.tachTypographyColor,
|
|
weight: this.tachTypographyWeight,
|
|
clickable: this.tachTypographyClickable,
|
|
className: this.tachTypographyClassName
|
|
});
|
|
const nextSet = new Set(nextClassList);
|
|
for (const className of this.appliedClasses) {
|
|
if (!nextSet.has(className)) {
|
|
this.renderer.removeClass(this.elementRef.nativeElement, className);
|
|
}
|
|
}
|
|
for (const className of nextSet) {
|
|
this.renderer.addClass(this.elementRef.nativeElement, className);
|
|
}
|
|
this.appliedClasses.clear();
|
|
for (const className of nextSet) {
|
|
this.appliedClasses.add(className);
|
|
}
|
|
}
|
|
syncEllipsisStyles() {
|
|
const nextStyles = tachTypographyEllipsisStyle(this.tachTypographyEllipsis) || {};
|
|
const nextStyleKeys = new Set(Object.keys(nextStyles));
|
|
for (const styleKey of this.appliedStyleProperties) {
|
|
if (!nextStyleKeys.has(styleKey)) {
|
|
this.renderer.removeStyle(this.elementRef.nativeElement, toCssProperty(styleKey));
|
|
}
|
|
}
|
|
for (const [styleKey, styleValue] of Object.entries(nextStyles)) {
|
|
this.renderer.setStyle(this.elementRef.nativeElement, toCssProperty(styleKey), styleValue);
|
|
}
|
|
this.appliedStyleProperties.clear();
|
|
for (const styleKey of nextStyleKeys) {
|
|
this.appliedStyleProperties.add(styleKey);
|
|
}
|
|
}
|
|
};
|
|
_init = __decoratorStart();
|
|
__decorateElement(_init, 5, "tachTypography", _tachTypography_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyVariant", _tachTypographyVariant_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyColor", _tachTypographyColor_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyWeight", _tachTypographyWeight_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyClickable", _tachTypographyClickable_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyClassName", _tachTypographyClassName_dec, TachTypographyDirective);
|
|
__decorateElement(_init, 5, "tachTypographyEllipsis", _tachTypographyEllipsis_dec, TachTypographyDirective);
|
|
TachTypographyDirective = __decorateElement(_init, 0, "TachTypographyDirective", _TachTypographyDirective_decorators, TachTypographyDirective);
|
|
__runInitializers(_init, 1, TachTypographyDirective);
|
|
var _TachTypographyNzModule_decorators, _init2;
|
|
_TachTypographyNzModule_decorators = [NgModule({
|
|
imports: [NzTypographyModule, TachTypographyDirective],
|
|
exports: [NzTypographyModule, TachTypographyDirective]
|
|
})];
|
|
var TachTypographyNzModule = class {
|
|
};
|
|
_init2 = __decoratorStart();
|
|
TachTypographyNzModule = __decorateElement(_init2, 0, "TachTypographyNzModule", _TachTypographyNzModule_decorators, TachTypographyNzModule);
|
|
__runInitializers(_init2, 1, TachTypographyNzModule);
|
|
|
|
export { TachTypographyDirective, TachTypographyNzModule, tachAngularTypographyClassList, tachAngularTypographyClassName, tachAngularTypographyStyles };
|
|
//# sourceMappingURL=index.js.map
|
|
//# sourceMappingURL=index.js.map
|