Skip to content

Commit

Permalink
export * answers-headless (#52)
Browse files Browse the repository at this point in the history
* export * answers-headless

This commit adds an export * from answers-headless statement.
This way, the sample-app doesn't have to use a transient answers-core
or answers-headless dependency for models.

J=SLAP-1684
TEST=manual

see the sample app runs

* remove answers-core dep in sample app
  • Loading branch information
oshi97 committed Nov 10, 2021
1 parent 9ec7dbb commit b159efd
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 86 deletions.
51 changes: 0 additions & 51 deletions sample-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sample-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@types/react-router-dom": "^5.3.0",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"@yext/answers-core": "^1.2.0",
"@yext/answers-headless-react": "file:..",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/AlternativeVerticals.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { processTranslation } from './utils/processTranslation';
import { ReactComponent as Chevron } from '../icons/chevron.svg';
import { ReactComponent as Star } from '../icons/star.svg';
import { useAnswersState, useAnswersActions } from '@yext/answers-headless-react';
import { VerticalResults } from '@yext/answers-core';
import { useAnswersState, useAnswersActions, VerticalResults } from '@yext/answers-headless-react';
import '../sass/AlternativeVerticals.scss';

interface VerticalConfig {
Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/DecoratedAppliedFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import AppliedFilters from "./AppliedFilters";
import { AppliedQueryFilter } from "@yext/answers-core";
import { useAnswersState } from '@yext/answers-headless-react';
import { useAnswersState, AppliedQueryFilter } from '@yext/answers-headless-react';
import { GroupedFilters } from '../models/groupedFilters';
import { getGroupedAppliedFilters } from '../utils/appliedfilterutils';

Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/Facet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAnswersUtilities } from '@yext/answers-headless-react'
import { DisplayableFacet, DisplayableFacetOption } from '@yext/answers-core';
import { useAnswersUtilities, DisplayableFacet, DisplayableFacetOption } from '@yext/answers-headless-react'
import { useState } from 'react';
import useCollapse from 'react-collapsed';
import '../sass/Facet.scss';
Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/Facets.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAnswersState, useAnswersActions } from '@yext/answers-headless-react'
import { DisplayableFacetOption } from "@yext/answers-core";
import { useAnswersState, useAnswersActions, DisplayableFacetOption } from '@yext/answers-headless-react'
import Facet, { FacetTextConfig } from './Facet';
import '../sass/Facets.scss';

Expand Down
4 changes: 1 addition & 3 deletions sample-app/src/components/LocationBias.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import { LocationBiasMethod } from '@yext/answers-core';
import { useAnswersActions, useAnswersState } from '@yext/answers-headless-react';
import { useAnswersActions, useAnswersState, LocationBiasMethod } from '@yext/answers-headless-react';

interface Props {
isVertical: boolean,
Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAnswersActions, useAnswersState, StateSelector } from '@yext/answers-headless-react';
import { AutocompleteResult } from '@yext/answers-core';
import { useAnswersActions, useAnswersState, StateSelector, AutocompleteResult } from '@yext/answers-headless-react';
import InputDropdown from './InputDropdown';
import renderWithHighlighting from './utils/renderWithHighlighting';
import { ReactComponent as MagnifyingGlassIcon } from '../icons/magnifying_glass.svg';
Expand Down
8 changes: 3 additions & 5 deletions sample-app/src/components/StaticFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Fragment } from 'react';
import { Filter, Matcher } from '@yext/answers-core';
import { useAnswersActions, useAnswersState } from '@yext/answers-headless-react';
import { useAnswersActions, useAnswersState, Filter, Matcher } from '@yext/answers-headless-react';
import { isDuplicateFilter } from '../utils/filterutils';

interface CheckBoxProps {
Expand Down Expand Up @@ -31,15 +29,15 @@ function CheckboxFilter({ fieldId, value, label, selected, optionHandler }: Chec
}
const id = fieldId + "_" + value
return (
<Fragment>
<>
<label htmlFor={id}>{label}</label>
<input
type="checkbox"
id={id}
checked={selected}
onChange={evt => optionHandler(filter, evt.target.checked)}
/>
</Fragment>
</>
);
}

Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/UniversalResults.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAnswersState } from "@yext/answers-headless-react";
import { VerticalResults } from "@yext/answers-core";
import { useAnswersState, VerticalResults } from "@yext/answers-headless-react";
import StandardSection from "../sections/StandardSection";
import { DecoratedAppliedFiltersConfig } from '../components/DecoratedAppliedFilters';
import SectionHeader from "../sections/SectionHeader";
Expand Down
3 changes: 1 addition & 2 deletions sample-app/src/components/VerticalResults.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CardComponent, CardConfigTypes } from '../models/cardComponent';
import { Result } from '@yext/answers-core';
import { useAnswersState } from '@yext/answers-headless-react';
import { useAnswersState, Result } from '@yext/answers-headless-react';
import classNames from 'classnames';
import '../sass/VerticalResults.scss';

Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/models/cardComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from '@yext/answers-core';
import { Result } from '@yext/answers-headless-react';
import { StandardCardConfig } from '../components/cards/StandardCard';

/**
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/models/displayableFilter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filter } from '@yext/answers-core';
import { Filter } from '@yext/answers-headless-react';

export interface DisplayableFilter {
filterType: 'NLP_FILTER' | 'STATIC_FILTER' | 'FACET',
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/models/sectionComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from "@yext/answers-core";
import { Result } from "@yext/answers-headless-react";
import { CardConfig } from './cardComponent';

export interface SectionConfig {
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/utils/appliedfilterutils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppliedQueryFilter } from "@yext/answers-core";
import { AppliedQueryFilter } from "@yext/answers-headless-react";
import { FiltersState } from "@yext/answers-headless/lib/esm/models/slices/filters";
import { DisplayableFilter } from "../models/displayableFilter";
import { GroupedFilters } from "../models/groupedFilters";
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/utils/displayablefilterutils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppliedQueryFilter, DisplayableFacet } from '@yext/answers-core';
import { AppliedQueryFilter, DisplayableFacet } from '@yext/answers-headless-react';
import { SelectableFilter } from '@yext/answers-headless/lib/esm/models/utils/selectablefilter';
import { DisplayableFilter } from '../models/displayableFilter';
import { getFilterDisplayValue } from './filterutils';
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/utils/filterutils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NearFilterValue, CombinedFilter, Filter } from '@yext/answers-core';
import { NearFilterValue, CombinedFilter, Filter } from '@yext/answers-headless-react';

/**
* Check if the object follows NearFilterValue interface
Expand Down
3 changes: 1 addition & 2 deletions src/AnswersHeadlessProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ReactChild, ReactChildren } from 'react';
import { provideAnswersHeadless, AnswersHeadless } from '@yext/answers-headless';
import { AnswersConfig } from '@yext/answers-core';
import { provideAnswersHeadless, AnswersHeadless, AnswersConfig } from '@yext/answers-headless';
import { AnswersHeadlessContext } from './AnswersHeadlessContext';

interface Props extends AnswersConfig {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { subscribeToStateUpdates } from './subscribeToStateUpdates';
import { AnswersHeadlessProvider } from './AnswersHeadlessProvider';
import { AnswersHeadlessContext } from './AnswersHeadlessContext';

export * from '@yext/answers-headless';
export {
AnswersHeadlessContext,
subscribeToStateUpdates,
Expand Down
3 changes: 1 addition & 2 deletions tests/components/appliedFilters.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { act, render } from '@testing-library/react';
import { provideAnswersHeadless } from '@yext/answers-headless';
import { provideAnswersHeadless, Matcher } from '@yext/answers-headless';
import { AnswersHeadlessContext } from '../../src';
import DecoratedAppliedFilters from '../../sample-app/src/components/DecoratedAppliedFilters';
import { Matcher } from '@yext/answers-core';
import { useCallback } from 'react';
import { verticalQueryResponseWithNlpFilters } from '../setup/responses/vertical-query';

Expand Down
3 changes: 1 addition & 2 deletions tests/useAnswersState.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Result } from '@yext/answers-core';
import { provideAnswersHeadless } from '@yext/answers-headless';
import { provideAnswersHeadless, Result } from '@yext/answers-headless';
import { State } from '@yext/answers-headless/lib/esm/models/state';
import React, { useCallback, useReducer } from 'react';
import { AnswersHeadlessContext, useAnswersActions, useAnswersState } from '../src';
Expand Down

0 comments on commit b159efd

Please sign in to comment.