Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@c2dh/react-miller

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@c2dh/react-miller - npm Package Compare versions

Comparing version 1.0.0-beta.3 to 1.0.0-beta.4

59

dist/index.cjs.js

@@ -211,3 +211,5 @@ 'use strict';

_excluded11 = ["params", "mapModulesWithRelatedDocuments"],
_excluded12 = ["data"];
_excluded12 = ["data"],
_excluded13 = ["params", "mapModulesWithRelatedDocuments"],
_excluded14 = ["data"];
function Miller(_ref) {

@@ -410,3 +412,57 @@ var client = _ref.client,

}
function useStoryWithChapters(idOrSlug, options) {
var getJSON = useGetJSON();
var _ref14 = options !== null && options !== void 0 ? options : {},
givenParams = _ref14.params,
_ref14$mapModulesWith = _ref14.mapModulesWithRelatedDocuments,
mapModulesWithRelatedDocuments = _ref14$mapModulesWith === void 0 ? true : _ref14$mapModulesWith,
queryOptions = _objectWithoutProperties__default["default"](_ref14, _excluded13);
var params = _objectSpread__default["default"](_objectSpread__default["default"]({}, BASE_MILLER_PARAMS), givenParams);
var _useQuery6 = reactQuery.useQuery(['story-with-chapters', idOrSlug, params], function (_ref15) {
var signal = _ref15.signal;
return getJSON("/story/".concat(idOrSlug, "/"), {
params: params,
signal: signal
}).then(function (story) {
var _story$data$chapters;
return Promise.all(((_story$data$chapters = story.data.chapters) !== null && _story$data$chapters !== void 0 ? _story$data$chapters : []).map(function (id) {
return getJSON("/story/".concat(id, "/"), {
signal: signal,
params: BASE_MILLER_PARAMS
});
})).then(function (chapters) {
return _objectSpread__default["default"](_objectSpread__default["default"]({}, story), {}, {
data: _objectSpread__default["default"](_objectSpread__default["default"]({}, story.data), {}, {
chapters: chapters
})
});
});
});
}, queryOptions),
data = _useQuery6.data,
other = _objectWithoutProperties__default["default"](_useQuery6, _excluded14);
var mappedData = react.useMemo(function () {
if (!mapModulesWithRelatedDocuments) {
return data;
}
if (!data) {
return data;
}
var mappedData = mapStoryWithRelatedModulesDocuments(data);
return _objectSpread__default["default"](_objectSpread__default["default"]({}, mappedData), {}, {
data: _objectSpread__default["default"](_objectSpread__default["default"]({}, mappedData.data), {}, {
chapters: mappedData.data.chapters.map(mapStoryWithRelatedModulesDocuments)
})
});
}, [data, mapModulesWithRelatedDocuments]);
return [useTranslate(mappedData), other];
}
exports.Miller = Miller;

@@ -419,1 +475,2 @@ exports.useDocument = useDocument;

exports.useStory = useStory;
exports.useStoryWithChapters = useStoryWithChapters;

5

dist/index.d.ts
import { ReactNode } from 'react';
import { InfiniteData, QueryClient, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseQueryOptions, UseQueryResult } from 'react-query';
import { MillerConfig, MillerDocumenntInList, MillerDocumentDetail, MillerFacetsResponse, MillerPaginatedResponse, MillerPaginatedResponseWithFacets, MillerStory } from './types';
import { MillerConfig, MillerDocumenntInList, MillerDocumentDetail, MillerFacetsResponse, MillerPaginatedResponse, MillerPaginatedResponseWithFacets, MillerStory, MillerStoryWithChapters } from './types';
export declare function Miller({ client, apiUrl, lang, fallbackLang, langs, headers, children, }: MillerConfig & {

@@ -30,2 +30,5 @@ client: QueryClient;

}): [MillerStory | undefined, UseQueryOtherResult];
export declare function useStoryWithChapters(idOrSlug: number | string, options?: UseQueryMillerOptions & {
mapModulesWithRelatedDocuments?: boolean;
}): [MillerStoryWithChapters | undefined, UseQueryOtherResult];
export {};

@@ -200,3 +200,5 @@ import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';

_excluded11 = ["params", "mapModulesWithRelatedDocuments"],
_excluded12 = ["data"];
_excluded12 = ["data"],
_excluded13 = ["params", "mapModulesWithRelatedDocuments"],
_excluded14 = ["data"];
function Miller(_ref) {

@@ -399,3 +401,57 @@ var client = _ref.client,

}
function useStoryWithChapters(idOrSlug, options) {
var getJSON = useGetJSON();
export { Miller, useDocument, useDocuments, useDocumentsFacets, useInfiniteDocuments, useStories, useStory };
var _ref14 = options !== null && options !== void 0 ? options : {},
givenParams = _ref14.params,
_ref14$mapModulesWith = _ref14.mapModulesWithRelatedDocuments,
mapModulesWithRelatedDocuments = _ref14$mapModulesWith === void 0 ? true : _ref14$mapModulesWith,
queryOptions = _objectWithoutProperties(_ref14, _excluded13);
var params = _objectSpread(_objectSpread({}, BASE_MILLER_PARAMS), givenParams);
var _useQuery6 = useQuery(['story-with-chapters', idOrSlug, params], function (_ref15) {
var signal = _ref15.signal;
return getJSON("/story/".concat(idOrSlug, "/"), {
params: params,
signal: signal
}).then(function (story) {
var _story$data$chapters;
return Promise.all(((_story$data$chapters = story.data.chapters) !== null && _story$data$chapters !== void 0 ? _story$data$chapters : []).map(function (id) {
return getJSON("/story/".concat(id, "/"), {
signal: signal,
params: BASE_MILLER_PARAMS
});
})).then(function (chapters) {
return _objectSpread(_objectSpread({}, story), {}, {
data: _objectSpread(_objectSpread({}, story.data), {}, {
chapters: chapters
})
});
});
});
}, queryOptions),
data = _useQuery6.data,
other = _objectWithoutProperties(_useQuery6, _excluded14);
var mappedData = useMemo(function () {
if (!mapModulesWithRelatedDocuments) {
return data;
}
if (!data) {
return data;
}
var mappedData = mapStoryWithRelatedModulesDocuments(data);
return _objectSpread(_objectSpread({}, mappedData), {}, {
data: _objectSpread(_objectSpread({}, mappedData.data), {}, {
chapters: mappedData.data.chapters.map(mapStoryWithRelatedModulesDocuments)
})
});
}, [data, mapModulesWithRelatedDocuments]);
return [useTranslate(mappedData), other];
}
export { Miller, useDocument, useDocuments, useDocumentsFacets, useInfiniteDocuments, useStories, useStory, useStoryWithChapters };

@@ -132,2 +132,10 @@ export interface MillerConfig {

}
export interface MillerStoryWithChaptersData {
color: string;
title: string;
abstract: string;
chapters: MillerStory[];
background: string;
count_modules?: number;
}
export interface MillerModule {

@@ -140,3 +148,3 @@ module: string;

}
export interface MillerStory {
export interface BaseMillerStory<TData = any> {
id: number;

@@ -154,4 +162,6 @@ slug: string;

owner: MillerUser;
data: MillerStoryData;
data: TData;
contents?: MillerModuleContents;
}
export declare type MillerStory = BaseMillerStory<MillerStoryData>;
export declare type MillerStoryWithChapters = BaseMillerStory<MillerStoryWithChaptersData>;
import { AxiosRequestConfig } from 'axios';
import { MillerStory } from './types';
import { BaseMillerStory } from './types';
export declare function useGetJSON(): <T = any, D = any>(path: string, req: AxiosRequestConfig<D>) => Promise<T>;
export declare function useTranslator(): (data: any) => any;
export declare function useTranslate(data: any): any;
export declare function mapStoryWithRelatedModulesDocuments(story: MillerStory): MillerStory;
export declare function mapStoryWithRelatedModulesDocuments<T extends BaseMillerStory = BaseMillerStory>(story: T): T;

@@ -5,3 +5,3 @@ {

"license": "AGPL-3.0",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"author": "c2dh (https://c2dh.uni.lu)",

@@ -8,0 +8,0 @@ "main": "dist/index.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc