-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
147 changed files
with
4,184 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
angular-workspace/projects/ni/spright-angular/.eslintrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
extends: '../../../.eslintrc.js', | ||
overrides: [ | ||
{ | ||
files: ['*.ts'], | ||
parserOptions: { | ||
project: [ | ||
'./tsconfig.lib.json', | ||
'./tsconfig.spec.json' | ||
], | ||
tsconfigRootDir: __dirname | ||
} | ||
} | ||
] | ||
}; |
3 changes: 3 additions & 0 deletions
3
angular-workspace/projects/ni/spright-angular/CONTRIBUTING.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributing to Spright Angular | ||
|
||
Contributions should follow the same [guidelines](../nimble-angular/CONTRIBUTING.md) as the Nimble Angular project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div align="center"> | ||
<p><b>ni | spright | angular</b></p> | ||
</div> | ||
|
||
# Spright Angular | ||
|
||
[![NPM Version](https://img.shields.io/npm/v/@ni/spright-angular.svg)](https://www.npmjs.com/package/@ni/spright-angular) | ||
|
||
Spright components for [Angular](https://angular.io) applications | ||
|
||
## Contributing | ||
|
||
Follow the instructions in [CONTRIBUTING.md](CONTRIBUTING.md) to modify this library. |
6 changes: 6 additions & 0 deletions
6
angular-workspace/projects/ni/spright-angular/accordion/ng-package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
angular-workspace/projects/ni/spright-angular/accordion/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './spright-accordion.directive'; | ||
export * from './spright-accordion.module'; |
13 changes: 13 additions & 0 deletions
13
angular-workspace/projects/ni/spright-angular/accordion/spright-accordion.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Directive } from '@angular/core'; | ||
import { type Accordion, accordionTag } from '@ni/spright-components/dist/esm/accordion'; | ||
|
||
export type { Accordion }; | ||
export { accordionTag }; | ||
|
||
/** | ||
* Directive to provide Angular integration for the accordion. | ||
*/ | ||
@Directive({ | ||
selector: 'spright-accordion' | ||
}) | ||
export class SprightAccordionDirective { } |
12 changes: 12 additions & 0 deletions
12
angular-workspace/projects/ni/spright-angular/accordion/spright-accordion.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SprightAccordionDirective } from './spright-accordion.directive'; | ||
|
||
import '@ni/spright-components/dist/esm/accordion'; | ||
|
||
@NgModule({ | ||
declarations: [SprightAccordionDirective], | ||
imports: [CommonModule], | ||
exports: [SprightAccordionDirective] | ||
}) | ||
export class SprightAccordionModule { } |
16 changes: 16 additions & 0 deletions
16
angular-workspace/projects/ni/spright-angular/accordion/tests/accordion.directive.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { SprightAccordionModule } from '../spright-accordion.module'; | ||
|
||
describe('Spright accordion', () => { | ||
describe('module', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [SprightAccordionModule] | ||
}); | ||
}); | ||
|
||
it('custom element is defined', () => { | ||
expect(customElements.get('spright-accordion')).not.toBeUndefined(); | ||
}); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
angular-workspace/projects/ni/spright-angular/internal-utilities/ng-package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
angular-workspace/projects/ni/spright-angular/internal-utilities/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './template-value-helpers'; |
61 changes: 61 additions & 0 deletions
61
angular-workspace/projects/ni/spright-angular/internal-utilities/template-value-helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Conversion helpers for values coming from template attributes or property bindings | ||
*/ | ||
|
||
// Values assigned to directives can come from template attributes, ie <my-element my-number="4"></my-element> | ||
// or from property bindings, ie <my-element [my-number]="someNumber"></my-element> | ||
// So setters for our directives accept both string values from template attributes and | ||
// the expected property type. This file has helpers for common property types. | ||
// More context: https://v13.angular.io/guide/template-typecheck#input-setter-coercion | ||
|
||
type BooleanAttribute = '' | null; | ||
export type BooleanValueOrAttribute = boolean | BooleanAttribute; | ||
export type NumberValueOrAttribute = number | string; | ||
|
||
/** | ||
* Converts values from templates (empty string or null) or boolean bindings to a boolean property representation | ||
*/ | ||
export const toBooleanProperty = (value: BooleanValueOrAttribute): boolean => { | ||
if (value === false || value === null) { | ||
return false; | ||
} | ||
// For boolean attributes the empty string value is true | ||
return true; | ||
}; | ||
|
||
/** | ||
* Converts values from templates (empty string or null) or boolean bindings to an Aria boolean | ||
* attribute representation (the strings "true" or "false") | ||
*/ | ||
export const toBooleanAriaAttribute = (value: BooleanValueOrAttribute): 'true' | 'false' => { | ||
if (value === false || value === null) { | ||
return 'false'; | ||
} | ||
// For boolean attributes the empty string value is true | ||
return 'true'; | ||
}; | ||
|
||
/** | ||
* Converts values from templates (number representation as a string) or number bindings to a number property representation | ||
*/ | ||
export const toNumberProperty = (value: NumberValueOrAttribute): number => { | ||
// Angular: https://github.com/angular/angular/blob/2664bc2b3ef4ee5fd671f915828cfcc274a36c77/packages/forms/src/directives/number_value_accessor.ts#L67 | ||
// And Fast: https://github.com/microsoft/fast/blob/46bb6d9aab2c37105f4434db3795e176c2354a4f/packages/web-components/fast-element/src/components/attributes.ts#L100 | ||
// Handle numeric conversions from the view differently | ||
// Since Number(val) https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number-constructor-number-value | ||
// and val * 1 https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-applystringornumericbinaryoperator | ||
// Are identical (use ToNumeric algorithm), went with Number() for clarity | ||
return Number(value); | ||
}; | ||
|
||
/** | ||
* Converts values from templates (number representation as a string) or number bindings to a number property representation. | ||
* The values of `null` and `undefined` are also supported, and they are not converted. | ||
*/ | ||
export const toNullableNumberProperty = (value: NumberValueOrAttribute | null | undefined): number | null | undefined => { | ||
if (value === undefined || value === null) { | ||
return value; | ||
} | ||
|
||
return toNumberProperty(value); | ||
}; |
53 changes: 53 additions & 0 deletions
53
angular-workspace/projects/ni/spright-angular/karma.conf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
process.env.CHROME_BIN = require('playwright').chromium.executablePath(); | ||
const karmaJasmine = require('karma-jasmine'); | ||
const karmaChromeLauncher = require('karma-chrome-launcher'); | ||
const karmaJasmineHtmlReporter = require('karma-jasmine-html-reporter'); | ||
const karmaCoverage = require('karma-coverage'); | ||
const karmaAngular = require('@angular-devkit/build-angular/plugins/karma'); | ||
const path = require('path'); | ||
|
||
module.exports = config => { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
karmaJasmine, | ||
karmaChromeLauncher, | ||
karmaJasmineHtmlReporter, | ||
karmaCoverage, | ||
karmaAngular | ||
], | ||
client: { | ||
jasmine: { | ||
// you can add configuration options for Jasmine here | ||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html | ||
// for example, you can disable the random execution with `random: false` | ||
// or set a specific seed with `seed: 4321` | ||
stopSpecOnExpectationFailure: false | ||
}, | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
jasmineHtmlReporter: { | ||
suppressAll: true // removes the duplicated traces | ||
}, | ||
coverageReporter: { | ||
dir: path.join(__dirname, '../../../coverage/ni/spright-angular-core'), | ||
subdir: '.', | ||
reporters: [ | ||
{ type: 'html' }, | ||
{ type: 'text-summary' } | ||
] | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['ChromeHeadless'], | ||
singleRun: false, | ||
restartOnFileChange: true | ||
}); | ||
}; |
Oops, something went wrong.