@beeq/angular 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # Angular Wrapper for BEEQ
2
+
3
+ An Angular-specific wrapper on top of BEEQ web components that enables NG_VALUE_ACCESSORS and allows you to bind input events directly to a value accessor for seamless integration in Angular’s bi-directional data flow.
4
+
5
+ ## Package installation
6
+
7
+ - install the package
8
+
9
+ ```
10
+ npm install @bee-q/angular
11
+ ```
12
+
13
+ - update the package
14
+
15
+ ```
16
+ npm install @bee-q/angular@latest
17
+ ```
18
+
19
+ if the `@bee-q/core` package is added to your `package.json` should update both
20
+
21
+ ```
22
+ npm install @bee-q/{core,angular}
23
+ ```
24
+
25
+ ## Setup
26
+
27
+ ### Call `defineCustomElements`
28
+
29
+ The BEEQ core package includes the main function that is used to load the components in the collection and makes Angular aware of the custom tags of the web components. That function is called `defineCustomElements()` and it is handled by the `@bee-q/angular` wrapper itself. Yet, **if you need to support older versions of Microsoft Edge and Internet Explorer, you can apply the polyfills as follow**:
30
+
31
+ ```ts
32
+ // main.ts
33
+
34
+ import { applyPolyfills, defineCustomElements } from '@bee-q/core/dist/loader';
35
+
36
+ ...
37
+
38
+ // Apply the polyfills for Edge/IE browser support
39
+ applyPolyfills().then(() => {
40
+ defineCustomElements(window);
41
+ })
42
+ ```
43
+
44
+ ### Add BEEQ styles and assets
45
+
46
+ > ❗️The icons SVG are shipped in a separate folder. Projects will need to include `node_modules/@bee-q/core/dist/bee-q/svg` in their build and try to make it in a certain way that it respond to: `http://<domain>/svg`
47
+
48
+ ```json
49
+ /** angular.json */
50
+ {
51
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
52
+ "version": 1,
53
+ "newProjectRoot": "projects",
54
+ "projects": {
55
+ "Angular-Project": {
56
+ ...
57
+ "architect": {
58
+ "build": {
59
+ "builder": "@angular-devkit/build-angular:browser",
60
+ "options": {
61
+ ...
62
+ "assets": [
63
+ "src/favicon.ico",
64
+ "src/assets",
65
+ {
66
+ "glob": "**/*",
67
+ "input": "node_modules/@bee-q/core/dist/bee-q/svg",
68
+ "output": "/svg/"
69
+ }
70
+ ],
71
+ "styles": [
72
+ "src/styles.scss",
73
+ "node_modules/@bee-q/core/dist/bee-q/bee-q.css"
74
+ ],
75
+ ...
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ BEEQ styles can be also imported into your application's main style file:
85
+
86
+ ```css
87
+ @import '~@bee-q/core/dist/bee-q/bee-q.css';
88
+ ```
89
+
90
+ ### Add the BEEQ Angular module to your application module
91
+
92
+ You will be able to add BEEQ web components to your app by adding the `BeeQModule` exported by `@bee-q/angular`:
93
+
94
+ ```ts
95
+ import { NgModule } from '@angular/core';
96
+ import { BrowserModule } from '@angular/platform-browser';
97
+ import { BeeQModule } from '@bee-q/angular';
98
+
99
+ import { AppComponent } from './app.component';
100
+
101
+ @NgModule({
102
+ declarations: [AppComponent],
103
+ imports: [BeeQModule.forRoot(), BrowserModule],
104
+ providers: [],
105
+ bootstrap: [AppComponent],
106
+ schemas: [],
107
+ })
108
+ export class AppModule {}
109
+ ```
110
+
111
+ ### NgModel and two-way data binding
112
+
113
+ To enable two-way binding and the use of [ngModel] within BEEQ form components, you will need to add the Value Accessors in your module declarations, along with `@angular/forms`.
114
+
115
+ > ❗️❗️ *Please notice that* **you might need to disable** `aot` *for enabling two-way data binding**. Details: https://github.com/ionic-team/stencil-ds-output-targets/issues/317*
116
+
117
+ ```ts
118
+ import { NgModule } from '@angular/core';
119
+ import { FormsModule } from '@angular/forms';
120
+ import { BrowserModule } from '@angular/platform-browser';
121
+ import { BeeQModule, BooleanValueAccessor, TextValueAccessor } from '@bee-q/angular';
122
+
123
+ import { AppComponent } from './app.component';
124
+
125
+ /** 💡 More Value Accessors will be exported later and should be included as well */
126
+ const VALUE_ACCESSORS = [BooleanValueAccessor, TextValueAccessor];
127
+
128
+ @NgModule({
129
+ declarations: [AppComponent, ...VALUE_ACCESSORS],
130
+ imports: [BeeQModule.forRoot(), BrowserModule, FormsModule],
131
+ providers: [],
132
+ bootstrap: [AppComponent],
133
+ schemas: [],
134
+ })
135
+ export class AppModule {}
136
+ ```
137
+
138
+ ### Usage
139
+
140
+ ```html
141
+ <!-- Angular component template -->
142
+
143
+ <bq-checkbox name="userTermsConditions" [(ngModel)]="termsConditions" (bqChange)="onTermsConditionsChange()">
144
+ Yes, I agree with the Terms & Conditions
145
+ </bq-checkbox>
146
+
147
+ <bq-slider
148
+ min="0"
149
+ max="100"
150
+ type="range"
151
+ debounce-time="250"
152
+ [(ngModel)]="sliderValue"
153
+ (bqChange)="onSliderChange()"
154
+ ></bq-slider>
155
+ ```
156
+
157
+ ```ts
158
+ /** Angular component typescript */
159
+ import { Component } from '@angular/core';
160
+
161
+ @Component({
162
+ selector: 'app-root',
163
+ templateUrl: './app.component.html',
164
+ styleUrls: ['./app.component.scss'],
165
+ })
166
+ export class AppComponent {
167
+ termsConditions = true;
168
+ sliderValue = [20, 75];
169
+
170
+ onTermsConditionsChange() {
171
+ console.log('The terms and conditions value changed!', this.termsConditions);
172
+ }
173
+
174
+ onSliderChange() {
175
+ console.log('Slider value changed!', this.sliderValue);
176
+ }
177
+ }
178
+ ```
@@ -0,0 +1,10 @@
1
+ import { ModuleWithProviders } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ import * as i1 from "./directives/components";
4
+ import * as i2 from "@angular/common";
5
+ export declare class BeeQModule {
6
+ static forRoot(): ModuleWithProviders<BeeQModule>;
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<BeeQModule, never>;
8
+ static ɵmod: i0.ɵɵNgModuleDeclaration<BeeQModule, [typeof i1.BqAccordion, typeof i1.BqAccordionGroup, typeof i1.BqAlert, typeof i1.BqAvatar, typeof i1.BqBadge, typeof i1.BqBreadcrumb, typeof i1.BqBreadcrumbItem, typeof i1.BqButton, typeof i1.BqCard, typeof i1.BqCheckbox, typeof i1.BqDialog, typeof i1.BqDivider, typeof i1.BqDropdown, typeof i1.BqEmptyState, typeof i1.BqIcon, typeof i1.BqInput, typeof i1.BqNotification, typeof i1.BqOption, typeof i1.BqOptionGroup, typeof i1.BqOptionList, typeof i1.BqPanel, typeof i1.BqRadio, typeof i1.BqRadioGroup, typeof i1.BqSelect, typeof i1.BqSideMenu, typeof i1.BqSideMenuItem, typeof i1.BqSlider, typeof i1.BqSpinner, typeof i1.BqStatus, typeof i1.BqStepItem, typeof i1.BqSteps, typeof i1.BqSwitch, typeof i1.BqTab, typeof i1.BqTabGroup, typeof i1.BqTag, typeof i1.BqTextarea, typeof i1.BqToast, typeof i1.BqTooltip], [typeof i2.CommonModule], [typeof i1.BqAccordion, typeof i1.BqAccordionGroup, typeof i1.BqAlert, typeof i1.BqAvatar, typeof i1.BqBadge, typeof i1.BqBreadcrumb, typeof i1.BqBreadcrumbItem, typeof i1.BqButton, typeof i1.BqCard, typeof i1.BqCheckbox, typeof i1.BqDialog, typeof i1.BqDivider, typeof i1.BqDropdown, typeof i1.BqEmptyState, typeof i1.BqIcon, typeof i1.BqInput, typeof i1.BqNotification, typeof i1.BqOption, typeof i1.BqOptionGroup, typeof i1.BqOptionList, typeof i1.BqPanel, typeof i1.BqRadio, typeof i1.BqRadioGroup, typeof i1.BqSelect, typeof i1.BqSideMenu, typeof i1.BqSideMenuItem, typeof i1.BqSlider, typeof i1.BqSpinner, typeof i1.BqStatus, typeof i1.BqStepItem, typeof i1.BqSteps, typeof i1.BqSwitch, typeof i1.BqTab, typeof i1.BqTabGroup, typeof i1.BqTag, typeof i1.BqTextarea, typeof i1.BqToast, typeof i1.BqTooltip]>;
9
+ static ɵinj: i0.ɵɵInjectorDeclaration<BeeQModule>;
10
+ }
@@ -0,0 +1,9 @@
1
+ export declare const proxyInputs: (Cmp: any, inputs: string[]) => void;
2
+ export declare const proxyMethods: (Cmp: any, methods: string[]) => void;
3
+ export declare const proxyOutputs: (instance: any, el: any, events: string[]) => void;
4
+ export declare const defineCustomElement: (tagName: string, customElement: any) => void;
5
+ export declare function ProxyCmp(opts: {
6
+ defineCustomElementFn?: () => void;
7
+ inputs?: any;
8
+ methods?: any;
9
+ }): (cls: any) => any;
@@ -0,0 +1,9 @@
1
+ import { ElementRef } from '@angular/core';
2
+ import { ValueAccessor } from './value-accessor';
3
+ import * as i0 from "@angular/core";
4
+ export declare class BooleanValueAccessor extends ValueAccessor {
5
+ constructor(el: ElementRef);
6
+ writeValue(value: any): void;
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<BooleanValueAccessor, never>;
8
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BooleanValueAccessor, "bq-checkbox, bq-switch", never, {}, {}, never, never, false, never>;
9
+ }