UNPKG

angular-material

Version:

**[Support for legacy AngularJS ended on January 1st, 2022](https://goo.gle/angularjs-end-of-life). [See `@angular/core` for the actively supported Angular](https://npmjs.com/@angular/core).**

7 lines 2.91 kB
/*! * AngularJS Material Design * https://github.com/angular/material * @license MIT * v1.2.4-master-bfc8ae7 */ !function(e,d){"use strict";!function(){r.$inject=["$mdColors","$mdUtil","$log","$parse"],e.$inject=["$mdTheming","$mdUtil","$log"];var s=/^{((\s|,)*?["'a-zA-Z-]+?\s*?:\s*?(['"])[a-zA-Z0-9-.]*(['"]))+\s*}$/,l=null;function e(a,s,o){return l=l||Object.keys(a.PALETTES),{applyThemeColors:function(e,r){try{r&&e.css(function(e){var t={},a=e.hasOwnProperty("color");return d.forEach(e,function(e,r){var o=u(e),n=-1<r.indexOf("background");t[r]=i(o),n&&!a&&(t.color=i(o,!0))}),t}(r))}catch(e){o.error(e.message)}},getThemeColor:function(e){return i(u(e))},hasTheme:function(e){return d.isDefined(a.THEMES[e.split("-")[0]])}};function i(e,r){r=r||!1;var o=a.PALETTES[e.palette][e.hue];return o=r?o.contrast:o.value,s.supplant("rgba({0}, {1}, {2}, {3})",[o[0],o[1],o[2],o[3]||e.opacity])}function u(e){var r=e.split("-"),o=d.isDefined(a.THEMES[r[0]])?r.splice(0,1)[0]:a.defaultTheme();return{theme:o,palette:function(e,r){var o=1<e.length&&-1!==l.indexOf(e[1]),n=e[0].replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();o&&(n=e[0]+"-"+e.splice(1,1));if(-1===l.indexOf(n)){var t=a.THEMES[r].colors[n];if(!t)throw new Error(s.supplant("mdColors: couldn't find '{palette}' in the palettes.",{palette:n}));n=t.name}return n}(r,o),hue:function(e,r){var o=a.THEMES[r].colors;if("hue"!==e[1])return e[1]||o[e[0]in o?e[0]:"primary"].hues.default;var n=parseInt(e.splice(2,1)[0],10);if(n<1||3<n)throw new Error(s.supplant("mdColors: 'hue-{hueNumber}' is not a valid hue, can be only 'hue-1', 'hue-2' and 'hue-3'",{hueNumber:n}));if(e[1]="hue-"+n,e[0]in o)return o[e[0]].hues[e[1]];throw new Error(s.supplant("mdColors: 'hue-x' can only be used with [{availableThemes}], but was used with '{usedTheme}'",{availableThemes:Object.keys(o).join(", "),usedTheme:e[0]}))}(r,o),opacity:r[2]||1}}}function r(c,a,h,m){return{restrict:"A",require:["^?mdTheme"],compile:function(e,t){var l=function(){var e=t.mdColors,r=-1<e.indexOf("::"),o=r||s.test(t.mdColors);t.mdColors=e.replace("::","");var n=d.isDefined(t.mdColorsWatch);return!r&&!o&&(!n||a.parseAttributeBoolean(t.mdColorsWatch))}();return function(e,o,r,n){function t(o){"string"!=typeof o&&(o=""),r.mdColors||(r.mdColors="{}");var n=m(r.mdColors)(e);return a&&Object.keys(n).forEach(function(e){var r=n[e];c.hasTheme(r)||(n[e]=(o||a.$mdTheme)+"-"+r)}),i(n),n}var a=n[0],s={},i=function(e){if(!d.equals(e,s)){var r=Object.keys(s);s.background&&!r.color&&r.push("color"),r.forEach(function(e){o.css(e,"")})}s=e},u=d.noop;a&&(u=a.registerChanges(function(e){c.applyThemeColors(o,t(e))})),e.$on("$destroy",function(){u()});try{l?e.$watch(t,d.bind(this,c.applyThemeColors,o),!0):c.applyThemeColors(o,t())}catch(e){h.error(e.message)}}}}}d.module("material.components.colors",["material.core"]).directive("mdColors",r).service("$mdColors",e)}()}(window,window.angular);