@angular/cdk
Version:
Angular Material Component Development Kit
1 lines • 2.96 kB
Source Map (JSON)
{"version":3,"file":"coercion.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/cdk/coercion/boolean-property.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/cdk/coercion/string-array.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * Type describing the allowed values for a boolean input.\n * @docs-private\n */\nexport type BooleanInput = string | boolean | null | undefined;\n\n/** Coerces a data-bound value (typically a string) to a boolean. */\nexport function coerceBooleanProperty(value: any): boolean {\n return value != null && `${value}` !== 'false';\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * Coerces a value to an array of trimmed non-empty strings.\n * Any input that is not an array, `null` or `undefined` will be turned into a string\n * via `toString()` and subsequently split with the given separator.\n * `null` and `undefined` will result in an empty array.\n * This results in the following outcomes:\n * - `null` -> `[]`\n * - `[null]` -> `[\"null\"]`\n * - `[\"a\", \"b \", \" \"]` -> `[\"a\", \"b\"]`\n * - `[1, [2, 3]]` -> `[\"1\", \"2,3\"]`\n * - `[{ a: 0 }]` -> `[\"[object Object]\"]`\n * - `{ a: 0 }` -> `[\"[object\", \"Object]\"]`\n *\n * Useful for defining CSS classes or table columns.\n * @param value the value to coerce into an array of strings\n * @param separator split-separator if value isn't an array\n */\nexport function coerceStringArray(value: any, separator: string | RegExp = /\\s+/): string[] {\n const result = [];\n\n if (value != null) {\n const sourceValues = Array.isArray(value) ? value : `${value}`.split(separator);\n for (const sourceValue of sourceValues) {\n const trimmedString = `${sourceValue}`.trim();\n if (trimmedString) {\n result.push(trimmedString);\n }\n }\n }\n\n return result;\n}\n"],"names":["coerceBooleanProperty","value","coerceStringArray","separator","result","sourceValues","Array","isArray","split","sourceValue","trimmedString","trim","push"],"mappings":";;;;;AAeM,SAAUA,qBAAqBA,CAACC,KAAU,EAAA;EAC9C,OAAOA,KAAK,IAAI,IAAI,IAAI,GAAGA,KAAK,CAAA,CAAE,KAAK,OAAO;AAChD;;SCQgBC,iBAAiBA,CAACD,KAAU,EAAEE,YAA6B,KAAK,EAAA;EAC9E,MAAMC,MAAM,GAAG,EAAE;EAEjB,IAAIH,KAAK,IAAI,IAAI,EAAE;AACjB,IAAA,MAAMI,YAAY,GAAGC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,GAAGA,KAAK,GAAG,GAAGA,KAAK,CAAA,CAAE,CAACO,KAAK,CAACL,SAAS,CAAC;AAC/E,IAAA,KAAK,MAAMM,WAAW,IAAIJ,YAAY,EAAE;MACtC,MAAMK,aAAa,GAAG,CAAGD,EAAAA,WAAW,EAAE,CAACE,IAAI,EAAE;AAC7C,MAAA,IAAID,aAAa,EAAE;AACjBN,QAAAA,MAAM,CAACQ,IAAI,CAACF,aAAa,CAAC;AAC5B;AACF;AACF;AAEA,EAAA,OAAON,MAAM;AACf;;;;"}